Reading and writing genbank files
Ulrik Stervbo <[email protected]> Sat, 7 Sep 2013 20:42:58 +0200
| Newsgroups | gmane.comp.java.bio.general |
|---|---|
| Message-ID | <CAKVAULOSh1ym9V_3eTPdspLkfZ5dk5uxWqgrnhR7O1kq=84ZAw@mail.gmail.com> |
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 - [email protected]
http://lists.open-bio.org/mailman/listinfo/biojava-l
test-genbank.gb
(application/octet-stream, 544 B) - not displayed