[Biojava-l] RichSequenceIterator.hasNext from empty file return true!!!
George Waldon
gwaldon at geneinfinity.org
Tue Apr 12 18:02:28 UTC 2011
Hi Khali,
In my hands I found "java.io.FileNotFoundException: emptyFile.txt (The
system cannot find the file specified)", which is not exactly the same
thing as an empty file. Anyway, I think you are right and
RichStreamReader should switch the moreSequenceAvailable flag before
throwing the exception. In your case just get out of the loop and you
should be safe. Thanks for reporting.
George
Quoting Khalil El Mazouari <khalil.elmazouari at gmail.com>:
> Hi,
>
> RichSequenceIterator.hasNext from empty file return true!!! and
> throws an infinite BioException loop!!!
> Any explanation?? Thanks
>
> khalil
>
> test using the following code
>
> public static void main(String[] args) {
> String path = "emptyFile.txt";
>
> BufferedReader br = null;
> try {
> br = new BufferedReader(new FileReader(path));
> } catch (FileNotFoundException ex) {
> ex.printStackTrace();
> }
> RichSequenceIterator seqs =
> RichSequence.IOTools.readFastaProtein(br, null);
> while (seqs.hasNext()) {
> try {
> RichSequence seq = seqs.nextRichSequence();
> } catch (NoSuchElementException ex) {
> ex.printStackTrace();
> } catch (BioException ex) {
> ex.printStackTrace();
> }
> }
>
> ====
>
> org.biojava.bio.BioException: Could not read sequence
> at
> org.biojavax.bio.seq.io.RichStreamReader.nextRichSequence(RichStreamReader.java:113)
> at com.kem.ae.core.Empty.main(Empty.java:51)
> Caused by: java.io.IOException: Premature stream end
> at
> org.biojavax.bio.seq.io.FastaFormat.readRichSequence(FastaFormat.java:178)
> at
> org.biojavax.bio.seq.io.RichStreamReader.nextRichSequence(RichStreamReader.java:110)
> ... 1 more
> org.biojava.bio.BioException: Could not read sequence
> at
> org.biojavax.bio.seq.io.RichStreamReader.nextRichSequence(RichStreamReader.java:113)
> at com.kem.ae.core.Empty.main(Empty.java:51)
> Caused by: java.io.IOException: Premature stream end
> at
> org.biojavax.bio.seq.io.FastaFormat.readRichSequence(FastaFormat.java:178)
> at
> org.biojavax.bio.seq.io.RichStreamReader.nextRichSequence(RichStreamReader.java:110)
>
> infinite loop....
>
>
> _______________________________________________
> Biojava-l mailing list - Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
>
More information about the Biojava-l
mailing list