[Biojava-l] 2 problems found in org.biojava.bio.seq.db.biosql code
Frederik Decouttere
sherpa at coresoft.be
Tue Jan 27 13:55:39 EST 2004
Hi,
After doing some tests with the biojava - biosql code I think there are
2 (little) bugs in there:
- when persisting a Sequence which contains a Feature with
BetweenLocation this Location gets converted to a RangeLocation upon
retrieval
- when persisting a Sequence which contains (a) Feature(s) in 2
different biodatabases an exception is thrown in the ontology code part
of biojava
You can find an example for both cases below
Environment: biojava.jar build from cvs, hsqldb database + biosql
schema, jdk1.4
If someone with knowledge of the biosql persistence code finds some time
to have a look...
Dont think it's very hard to fix
Ciao
Frederik
######test
code##################################################################
import java.util.*;
import org.biojava.bio.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.db.biosql.*;
import org.biojava.bio.seq.impl.*;
import org.biojava.bio.symbol.*;
public class BioSqlTest {
String driver = "org.hsqldb.jdbcDriver" ;
String user = "sa";
String pass = "";
String url = "jdbc:hsqldb:file:./database/biosqldb" ;
public BioSqlTest() {
}
/**
* demonstrates the switch from between to range location after
persistence code
*/
public void generateFeaturePersistenceProblem() throws Exception
{
BioSQLSequenceDB db1 = new BioSQLSequenceDB(driver, url,
user, pass
, "testbiosqldb_1", true);
db1.addSequence(getSequence()) ;
Sequence seq = db1.getSequence("test_seq") ;
for (Iterator iter = seq.features(); iter.hasNext();) {
StrandedFeature f = (StrandedFeature)
iter.next();
Location loc = f.getLocation() ;
/*
* ERROR: Location is now a RangeLocation and
not a BetweenLocation !
*/
if(loc instanceof BetweenLocation) {
// ok
System.out.println("[feature] location
is still a BetweenLocation: "
+ loc.getClass().getName());
}
else {
// problem
System.out.println("[feature] location
is now an instance of: "
+
loc.getClass().getName());
}
}
}
public void generateOntolgyPersistenceProblem() throws Exception
{
BioSQLSequenceDB db2 = new BioSQLSequenceDB(driver, url,
user, pass
, "testbiosqldb_2", true);
/*
EXCEPTION: the second addSequence will cause a
exception
in the ontology persistence code
Caused by: java.sql.SQLException: Failed to
persist term: ATYPE from ontology: ontology: __biojava_guano with error:
-9 : 23000
at
org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:5
06)
at
org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:4
68)
... 12 more
Caused by: java.sql.SQLException: Violation of
unique index: SYS_IDX_SYS_CT_9_10 in statement [insert into term
(name, definition, ontology_id) values (?, ?, ?)]
at
org.hsqldb.jdbcDriver.throwError(Unknown Source)
at
org.hsqldb.jdbcPreparedStatement.executeUpdate(Unknown Source)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega
tingPreparedStatement.java:233)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega
tingPreparedStatement.java:233)
at
org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:4
98)
... 13 more
*/
db2.addSequence(getSequence()) ;
}
public static Sequence getSequence() throws Exception {
SymbolList sl =
DNATools.createDNA("ACTGGTGTACCCCAATGGGAATATC") ;
Sequence sequence = new SimpleSequence(sl, null,
"test_seq", null);
sequence.createFeature(getFeature());
return sequence ;
}
private static StrandedFeature.Template getFeature() throws
Exception {
SimpleAnnotation annotation = new SimpleAnnotation();
annotation.setProperty("Comment", "comment line");
StrandedFeature.Template templ = new
StrandedFeature.Template();
templ.annotation = annotation;
templ.location = new BetweenLocation(new
RangeLocation(3,4));
templ.strand = StrandedFeature.POSITIVE;
templ.type = "ATYPE";
templ.source = "ASRC";
return templ ;
}
public static void main(String[] args) {
BioSqlTest test = new BioSqlTest() ;
try {
test.generateFeaturePersistenceProblem() ;
}
catch(Throwable t) {
t.printStackTrace();
}
try {
//test.generateOntolgyPersistenceProblem() ;
}
catch(Throwable t) {
t.printStackTrace();
}
finally {
System.exit(0);
}
}
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.569 / Virus Database: 360 - Release Date: 26/01/2004
More information about the Biojava-l
mailing list