[Biojava-l] extracting genome sequence from Genbank file

Schreiber, Mark mark.schreiber@agresearch.co.nz
Fri, 12 Apr 2002 09:54:49 +1200


Hi -

The following should do it:

     File gbFile = new File("myGBFile.gbk");
     SequenceIterator si = SeqIOTools.readGenbank( new BufferedReader(
new FileReader(gbFile),1024));
     Sequence s = si.next();

This returns a sequence iterator that iterates through all the sequences
in the GenBank file. In most GB files there is only one sequence so you
can get away with one call to si.next(); If there is more than one then
you could do this.

   ArrayList seqs = new ArrayList();
   while(si.hasNext()){
      seqs.add(si.next());
   }

Or if you want you could use a biojava SeqDB object rather than an array
list. The SeqDB allows you to retreive a specific sequence by ID.

Mark


> -----Original Message-----
> From: Ikro Yoon [mailto:ikro@cs.stanford.edu] 
> Sent: Friday, 12 April 2002 9:11 a.m.
> To: biojava-l@biojava.org
> Subject: [Biojava-l] extracting genome sequence from Genbank file
> 
> 
> Hello,
> 
> I have just started using biojava and find it extremely useful. 
> Particularly, I am using it for parsing Genbank files. I took 
> a look at the documentation as well as TestGenbank.java under 
> demos/seq directory to get an idea of how to extract various 
> information from Genbank files.
> 
> One thing that I am still having trouble is extracting the 
> genome sequence at the end of Genbank file. How could I do that?
> 
> Thank you for your help.
> 
> Ikro
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l@biojava.org 
> http://biojava.org/mailman/listinfo/biojava-l
> 
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================