[Biojava-l] Exception not being caught.
Richard HOLLAND
hollandr at gis.a-star.edu.sg
Tue Dec 28 20:56:43 EST 2004
I am getting an exception thrown by my code that never seems to get
caught. I am not sure if this is because of BioJava or because of a lack
of understanding of Exceptions on my part? The exception causes the
program to grind to an immediate halt. My method throws the general
Exception class, but the exception thrown by BioJava seems to escape
that detail and treats it as though my method were not handling
exceptions at all. I would expect the calling method which wraps the
call in a try{}catch{Exception e} statement to catch it? But apparently
not? Why not?!!
The method in BioJava I am using is DNATools.createDNASequence.
Here is the exception:
Exception in thread "main" org.biojava.bio.BioError: Something has gone
badly wrong with DNA
at org.biojava.bio.seq.DNATools.createDNA(DNATools.java:158)
at
org.biojava.bio.seq.DNATools.createDNASequence(DNATools.java:176)
at
gis.aads.pipeline.LibraryFastaBuilder.run(LibraryFastaBuilder.java:234)
at gis.pipeline.Main.main(Main.java:125)
Caused by: org.biojava.bio.symbol.IllegalSymbolException: This
tokenization doesn't contain character: ''
at
org.biojava.bio.seq.io.CharacterTokenization.parseTokenChar(CharacterTok
enization.java:175)
at
org.biojava.bio.seq.io.CharacterTokenization$TPStreamParser.characters(C
haracterTokenization.java:246)
at
org.biojava.bio.symbol.SimpleSymbolList.<init>(SimpleSymbolList.java:179
)
at org.biojava.bio.seq.DNATools.createDNA(DNATools.java:156)
... 3 more
And here is the method that calls it (or bits of it anyhow, and an
example calling method):
public void doTheThing() {
MyClass otherClass = new MyClass();
try {
int rc = otherClass.run();
System.out.println("rc was "+rc);
} catch (Exception e) {
System.out.println("oops!");
}
}
public int run() throws Exception {
....
// For each library, get all trimmed seqs.
for (String lib : libs) {
log.info("Processing library "+lib);
....
// Get the sequences.
seqq.execute(lib);
rs = seqq.results();
// Log info.
log.info("Processing fasta.");
while (rs.next()) {
// Get details.
String seqID = rs.getString(1);
char direction = UserSampleID.getDirection(seqID);
Clob seqclob = rs.getClob(2);
String seqstr =
seqclob.getSubString((long)1,(int)seqclob.length());
if (seqstr.length()<minLength) continue;
// Create the sequence and format it into fasta.
Sequence seq = DNATools.createDNASequence(seqstr,
seqID);
ByteArrayOutputStream baos = new
ByteArrayOutputStream();
SeqIOTools.writeFasta(baos,seq);
baos.flush();
// For each seq, if reverse, add to reverse temp file.
// Else, add to forward temp file.
switch (direction) {
case 'R':
reverseWriter.write(baos.toString());
break;
case 'F':
forwardWriter.write(baos.toString());
break;
default:
log.warning("Unknown direction "+direction+"
received for sequence "+seqID);
rc = PipelineApp.FAILURE;
continue;
}
....
}
....
}
....
}
I understand that the exception is thrown because of an invalid
sequence, but I don't understand why it isn't being caught.
Richard Holland
Bioinformatics Specialist
GIS extension 8199
---------------------------------------------
This email is confidential and may be privileged. If you are not the
intended recipient, please delete it and notify us immediately. Please
do not copy or use it for any purpose, or disclose its content to any
other person. Thank you.
---------------------------------------------
More information about the Biojava-l
mailing list