hi friends, I tried to read the fasta file through biojava manyways. All the time it turns out as depricated API. Please help me to find out the problem. Folowing is the error
symbol : method readFasta(java.io.BufferedInputStream,org.biojava.bio.symbol.Alphabet)
location: class org.biojavax.bio.seq.RichSequence.IOTools
SequenceDB db = org.biojavax.bio.seq.RichSequence.IOTools.readFasta(is, alpha);
^
Here it is my code
import java.io.*;
import java.util.*;
import org.biojava.bio.*;
import org.biojava.bio.seq.db.*;
import org.biojava.bio.seq.io.*;
import org.biojava.bio.symbol.*;
import org.biojavax.bio.seq.RichSequenceIterator;
import org.biojavax.bio.seq.io.FastaHeader;
import static org.biojavax.bio.seq.RichSequence.IOTools;
public class ReadFasta {
/**
* The program takes two args: the first is the file name of the Fasta file.
* The second is the name of the Alphabet. Acceptable names are DNA RNA or PROTEIN.
*/
public static void main(String[] args) {
try {
//setup file input
String filename = args[0];
BufferedInputStream is =
new BufferedInputStream(new FileInputStream(filename));
//get the appropriate Alphabet
Alphabet alpha = AlphabetManager.alphabetForName(args[1]);
//get a SequenceDB of all sequences in the file
SequenceDB db = org.biojavax.bio.seq.RichSequence.IOTools.readFasta(is, alpha);
//SequenceDB db = org.biojava.bio.seq.io.SeqIOTools.readFasta(is, alpha);
//org.biojavax.bio.seq.RichSequence.IOTools
}
catch (BioException ex) {
//not in fasta format or wrong alphabet
ex.printStackTrace();
}catch (NoSuchElementException ex) {
//no fasta sequences in the file
ex.printStackTrace();
}catch (FileNotFoundException ex) {
//problem reading file
ex.printStackTrace();
}
}
}
thank you for your help. its working propely
hi brad, expected to get sequence infomation too..!!!!
Muhammad -- you might want the seqString method. Check out the full API documentation for RichSequence: http://www.biojava.org/docs/api/org/biojavax/bio/seq/RichSequence.html