[Biojava-l] readFasta problem

Richard Holland holland at eaglegenomics.com
Thu Apr 8 11:41:25 UTC 2010


You have passed null into the tokenizer parameter of RichSequence.IOTools.readFasta() - this is not allowed. The parser cannot guess the type of sequence, it must be told what to expect by specifying the tokenizer to use. (Importantly this also means that you cannot mix different types of sequence within the same file to be parsed.)


On 8 Apr 2010, at 12:30, xyz wrote:

> Hello,
> I would like to read fasta file without to specify whether it is DNA,
> RNA or Protein in code and I wrote this code
> 
> import java.io.BufferedReader;
> import java.io.FileNotFoundException;
> import java.io.FileReader;
> import org.biojava.bio.BioException;
> import org.biojavax.SimpleNamespace;
> import org.biojavax.bio.seq.RichSequence;
> import org.biojavax.bio.seq.RichSequenceIterator;
> 
> public class SortFasta {
> 
>  public static void main(String[] args) throws FileNotFoundException,
>  BioException {
> 
> 
>    BufferedReader br = new BufferedReader(new
>    FileReader("sortFasta.fasta")); 
>    SimpleNamespace ns = new SimpleNamespace("biojava");
> 
>    // You can use any of the convenience methods found in the BioJava 1.6 API 
>    //RichSequenceIterator rsi = RichSequence.IOTools.readFastaDNA(br,  ns); 
>    RichSequenceIterator rsi = RichSequence.IOTools.readFasta(br, null, ns);
> 
>    // Since a single file can contain more than a sequence, you need
>    // to iterate over rsi to get the information.
>    while (rsi.hasNext()) {
>      RichSequence rs = rsi.nextRichSequence();
>      System.out.println(rs.getComments());
>      System.out.println(rs.seqString());
>    }
>  }
> }
> but unfortunately it I have got following error:
> it the details that follow to biojava-l at biojava.org or post a bug
>    report to http://bugzilla.open-bio.org/ 
> 
> Format_object=org.biojavax.bio.seq.io.FastaFormat
> Accession=
> Id=
> Comments=problem parsing symbols
> Parse_block=atccccc
> Stack trace follows ....
> 
> 
>        at
>        org.biojavax.bio.seq.io.FastaFormat.readRichSequence(FastaFormat.java:222)
>        at
>        org.biojavax.bio.seq.io.RichStreamReader.nextRichSequence(RichStreamReader.java:110) ...
>        1 more Caused by: java.lang.NullPointerException at
>        org.biojava.bio.symbol.SimpleSymbolList.<init>(SimpleSymbolList.java:165)
>        at
>        org.biojavax.bio.seq.io.FastaFormat.readRichSequence(FastaFormat.java:213) ...
>        2 more Java Result: 1
> 
> What did I wrong?
> 
> Thank you in advance.
> 
> Best regards,
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l

--
Richard Holland, BSc MBCS
Operations and Delivery Director, Eagle Genomics Ltd
T: +44 (0)1223 654481 ext 3 | E: holland at eaglegenomics.com
http://www.eaglegenomics.com/





More information about the Biojava-l mailing list