I am in grade 11 computer science, and I'm experiencing difficulty with an assignment. My task is:
Write a program which reads in a file containing a DNA sequence. Stores it as a String, and produces its DNA complement or builds the RNA.
What I have so far is:
After compiling and running, I get this:
My specific confusion with this is that I do not know how get it to import my file, which is a txt. I also can't figure out how to convert the DNA letters into RNA letters.
I would really appreciate it if someone could guide me through this assignment and help me figure out what I am supposed to do. Thanks.
Write a program which reads in a file containing a DNA sequence. Stores it as a String, and produces its DNA complement or builds the RNA.
What I have so far is:
Code:
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
class BioInformaticsLevel1
{
public static void main(String args[]) throws Exception
{
File file = new File("NC_003197_fna.mht");
Scanner sc = new Scanner(file);
String line = "";
while( sc.hasNextLine() )
{
line = sc.nextLine();
System.out.println(line);
}
}
}
Code:
Exception in thread "main" java.io.FileNotFoundException: NC_003197_fna.mht (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at BioInformaticsLevel1.main(BioInformaticsLevel1.java:12)
I would really appreciate it if someone could guide me through this assignment and help me figure out what I am supposed to do. Thanks.
Last edited by a moderator: