[Biojava-l] Reading and writing genbank files

Ulrik Stervbo ulrik.stervbo at gmail.com
Sat Sep 7 18:42:58 UTC 2013


Hello Everyone,

I am new to Biojava and quite new to java it sel (have not worked with it
in years).

I am trying to figure out how to read and later write a genbank file.

It seems that writing genbank is not supported?

What about all the different features annotated in the genbank file? When I
use getFeatures() I have 0 elements?

How can I access each sequence annotation/feature?

The genbank file is attached, and my code below.

Thanks
Ulrik

import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;

import org.biojava3.core.sequence.DNASequence;
import org.biojava3.core.sequence.compound.NucleotideCompound;
import org.biojava3.core.sequence.features.FeatureInterface;
import org.biojava3.core.sequence.io.GenbankReaderHelper;
import org.biojava3.core.sequence.template.AbstractSequence;


public class bioTest{

/**
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception{

File dnaFile = new File("test-genbank.gb");
 LinkedHashMap<String, DNASequence> dnaSequences =
GenbankReaderHelper.readGenbankDNASequence( dnaFile );
 for (DNASequence sequence : dnaSequences.values()) {
     System.out.println( sequence.getSequenceAsString() );

System.out.println("Length: " + sequence.getLength());
List<FeatureInterface<AbstractSequence<NucleotideCompound>,NucleotideCompound>>
 features = sequence.getFeatures();

 System.out.println(features.size());
}
 }

}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-genbank.gb
Type: application/octet-stream
Size: 544 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/biojava-l/attachments/20130907/9e9b78c4/attachment-0002.obj>


More information about the Biojava-l mailing list