[Biojava-l] Genbank SeqIO question

Neill White nk_white@yahoo.com
Mon, 29 Jul 2002 18:30:15 -0700 (PDT)


Hello-

I'm a new user of biojava and have a small problem that
I'm hoping someone can help me with - that is, I'm trying 
to read in and write out genbank files such 
that what I write out is somewhat close to what I read in
(it's acceptable if some info is lost - not all parsers
are perfect).  The problem is that some information
(the annotation) is lost after the first iteration.  Not
a huge problem, but if I now modify the program to read in
this freshly created genbank file ('file.dat'), and write
it out again - it's now missing the feature table.  Any
advice would be greatly appreciated.

Thanks-
neill

my program:

import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.FileReader;

import org.biojava.bio.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.impl.*;
import org.biojava.bio.seq.io.*;
import org.biojava.bio.symbol.*;

public class SimpleBioJava{
    public static void main(String args[]) throws Exception{

        // First, make, or read in a simple DNA sequence
        //Sequence sequence = nwSequence( "gattaca", "DNA" );
        // This line reads in the first sequence from a fasta file
        //Sequence sequence = nwReadFastaSequence( "test.fa" );
        // This line reads in the first sequence from a genbank file
        Sequence sequence = nwReadGenbankSequence( "gi20537285.gbk" );

        // Phew, now that that's done, let's write it to a file
        SequenceFormat seqFormat = new GenbankFormat();
        PrintStream stream = new PrintStream( new FileOutputStream( "test.dat" ) );
        seqFormat.writeSequence( sequence, stream );
    }
 
    public static Sequence nwReadGenbankSequence( String fileName ) throws Exception{

        Sequence sequence = null;

        BufferedReader br = new BufferedReader( new FileReader( fileName ) );
        SequenceIterator stream = SeqIOTools.readGenbank( br );

        if ( stream.hasNext() ){
            sequence = stream.nextSequence();
        }

        return sequence;
    }
}


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com