Hi,
Thomas,
As I saw the doc
says you are the author of SimpleSequenceBuilder class, I am asking for
help with the following problem?
I am in the way of
using biojava GenbankFormat class, the code is as following:
{
SequenceFormat gFormat = new GenbankFormat();
SequenceBuilderFactory sbFact =
new GenbankProcessor.Factory(SimpleSequenceBuilder.FACTORY);
//Alphabet alpha = DNATools.getDNA();
//this following line does not work for protein, need more work to figure out the library
Alphabet alpha = ProteinTools.getAlphabet();
SymbolParser rParser = alpha.getParser("token");
seqI =
new StreamReader(gReader, gFormat, rParser, sbFact);
SequenceFormat gFormat = new GenbankFormat();
SequenceBuilderFactory sbFact =
new GenbankProcessor.Factory(SimpleSequenceBuilder.FACTORY);
//Alphabet alpha = DNATools.getDNA();
//this following line does not work for protein, need more work to figure out the library
Alphabet alpha = ProteinTools.getAlphabet();
SymbolParser rParser = alpha.getParser("token");
seqI =
new StreamReader(gReader, gFormat, rParser, sbFact);
}
see the commented
out part, if I am using a DNA genbank file as the one sample in the demo part it
works fine. But if I want to use the above code to use PROTEIN alphabet
and parse a protein record in genbank format such as:
it gives the
exception shown at the end of the email.
I have traced down
and problem is at:
SimpleSequenceBuilder class TemplateWithChildren.
It seems by default it assumes this is a DNA genbank record. that is why it is
trying to create a strand feature which protein record does not have
it.
public Sequence makeSequence()
{
SymbolList symbols = slBuilder.makeSymbolList();
Sequence seq = new SimpleSequence(symbols, uri, name, annotation);
try {
for (Iterator i = rootFeatures.iterator(); i.hasNext(); ) {
TemplateWithChildren twc = (TemplateWithChildren) i.next();
Feature f = seq.createFeature(twc.template);
if (twc.children != null) {
makeChildFeatures(f, twc.children);
}
}
} catch (Exception ex) {
throw new BioError(ex, "Couldn't create feature");
}
return seq;
}
SymbolList symbols = slBuilder.makeSymbolList();
Sequence seq = new SimpleSequence(symbols, uri, name, annotation);
try {
for (Iterator i = rootFeatures.iterator(); i.hasNext(); ) {
TemplateWithChildren twc = (TemplateWithChildren) i.next();
Feature f = seq.createFeature(twc.template);
if (twc.children != null) {
makeChildFeatures(f, twc.children);
}
}
} catch (Exception ex) {
throw new BioError(ex, "Couldn't create feature");
}
return seq;
}
==================================
java
Exceptions
==================================
java.lang.reflect.InvocationTargetException:
org.biojava.bio.symbol.IllegalAlphabetException: Can not create a stranded
feature within a sequence of type PROTEIN
at
org.biojava.bio.seq.impl.SimpleStrandedFeature.<init>(SimpleStrandedFeature.java:76)
at
java.lang.reflect.Constructor.newInstance(Native Method)
at
org.biojava.bio.seq.SimpleFeatureRealizer$TemplateImpl.realize(SimpleFeatureRealizer.java:136)
rethrown as org.biojava.bio.BioException: Couldn't
realize feature
at
org.biojava.bio.seq.SimpleFeatureRealizer$TemplateImpl.realize(SimpleFeatureRealizer.java:138)
at
org.biojava.bio.seq.SimpleFeatureRealizer.realizeFeature(SimpleFeatureRealizer.java:92)
at
org.biojava.bio.seq.impl.SimpleSequence.realizeFeature(SimpleSequence.java:176)
at
org.biojava.bio.seq.impl.SimpleSequence.createFeature(SimpleSequence.java:182)
at
org.biojava.bio.seq.io.SimpleSequenceBuilder.makeSequence(SimpleSequenceBuilder.java:154)
rethrown as org.biojava.bio.BioError: Couldn't
create feature
at
org.biojava.bio.seq.io.SimpleSequenceBuilder.makeSequence(SimpleSequenceBuilder.java:160)
at
org.biojava.bio.seq.io.SequenceBuilderFilter.makeSequence(SequenceBuilderFilter.java:98)
at
org.biojava.bio.seq.io.StreamReader.nextSequence(StreamReader.java:100)
Thanks.
Bruce Ling, Ph.D.
Director,
Bioinformatics
Tularik, Inc -- http://www.tularik.com
Email: [EMAIL PROTECTED]
Phone:
650-825-7143
fax: 1-435-804-4009