[Biojava-l] Genbank SeqIO question

Emig, Robin Robin.Emig@maxygen.com
Tue, 30 Jul 2002 10:55:45 -0700


Are you using the latest source from the CVS? We should have recently cleaned up a lot of the genbank and msf parsing code.
-Robin

-----Original Message-----
From: Neill White [mailto:nk_white@yahoo.com]
Sent: Monday, July 29, 2002 6:30 PM
To: biojava-l@biojava.org
Subject: [Biojava-l] Genbank SeqIO question


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
_______________________________________________
Biojava-l mailing list  -  Biojava-l@biojava.org
http://biojava.org/mailman/listinfo/biojava-l