[Biojava-l] Genbank format -- StreamWriter problems

David Waring dwaring@u.washington.edu
Mon, 14 May 2001 10:32:19 -0700


I have found 2 realated problems.
System:
biojava 1.10
Both Unix and DOS both running jdk1.3

If I read a file in genbank format that has DOS endings and try to iterate
through the SequenceIterator
    sI1 = SeqIOTools.readGenbank(br1);
    while(sI1.hasNext()){
	seq = sI1.nextSequence();
	.....
     }

It gets the one sequence that the file contains then the nextSequence method
chokes on the second pass.


Exception in thread "main" java.io.IOException: Premature end of
stream for GENBANK
        at
org.biojava.bio.seq.io.GenbankFormat.readSequence(GenbankFormat.java:112)
        at
org.biojava.bio.seq.io.StreamReader.nextSequence(StreamReader.java:99)
rethrown as org.biojava.bio.BioException: Could not read sequence
        at
org.biojava.bio.seq.io.StreamReader.nextSequence(StreamReader.java:102)
        at GenbankTest.main(GenbankTest.java:39)


the same genbank file with Unix line endings has no problem. True on both
Unix and DOS

You might ask why I was doing this since the file only had one file in it.
Well I really wasn't, but StreamWriter does. This is where the problem
really comes in. StreamWriter wraps the nextSequence call in a try block
inside a while hasNext loop.

so passing a SequenceIterator that chokes in the middle as above to
StreamWriter is equivalent to:

        while (seqI.hasNext()){
           try{
                seq1 = seqI.nextSequence(); //choke here
           }catch (Exception

                System.out.println(e.getMessage());
           }
        }

OOOPS the try keeps hasNext from returning false -- this takes a good long
while on my machine.


Finally just wondering what the plans are for implementing writeSequence for
Genbank?

David



|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|   David Waring
|   Systems Programmer
|   University of Washington Genome Center
|   dwaring@u.washington.edu
|   (206) 221-6902
|||||||||||||||||||||||||||||||||||||||||||||||||||||||