Entering edit mode
4.6 years ago
delcophantom8491
•
0
I am new to biojava and am trying to convert a user inputted DNA sequence and get the protein sequence with 6 ORFs as the output. Below is the code that I have so far.I am at the point where it can read the file and output the DNA sequence. I am having trouble figuring out how to include the translation to protein with open reading frames in there.
import org.biojava.bio.BioException;
import org.biojavax.bio.seq.RichSequence;
import org.biojavax.bio.seq.RichSequence.IOTools;
import org.biojavax.bio.seq.RichSequenceIterator;
import java.io.*;
import java.util.Scanner;
import javax.swing.JFileChooser;
public class translate {
private static JFileChooser ourChooser = new JFileChooser(".");
public static BufferedReader openFile() {
int value = ourChooser.showOpenDialog(null);
BufferedReader br = null;
if(value == JFileChooser.APPROVE_OPTION) {
File file = ourChooser.getSelectedFile();
try {
br = new BufferedReader(new FileReader(file));
}
catch(FileNotFoundException e) {
System.out.println("Program has trouble reading the file" +
file.getName());
e.printStackTrace();
}
}
return br;
}
public static void main(String[] args) throws BioException {
BufferedReader br = openFile();
RichSequenceIterator it = IOTools.readFastaDNA(br, null);
int count = 0;
while (it.hasNext()) {
count++;
RichSequence seq = it.nextRichSequence();
System.out.println(seq.getAccession());
System.out.println(seq.seqString());
}
System.out.println("The number of sequences read is: " + count);