[Biojava-l] Reading and writing genbank files

Andreas Prlic andreas at sdsc.edu
Tue Sep 10 17:26:13 UTC 2013


Hi Ulrik,

Can you send me your .gb file off list?

Thanks,

Andreas


On Sat, Sep 7, 2013 at 11:42 AM, Ulrik Stervbo <ulrik.stervbo at gmail.com>wrote:

> 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());
> }
>  }
>
> }
>
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
>
>



More information about the Biojava-l mailing list