From hollandr at gis.a-star.edu.sg Thu Dec 2 01:16:31 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Thu Dec 2 01:15:01 2004 Subject: [Biojava-l] Ontology and BioSQL Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D5601267F47@BIONIC.biopolis.one-north.com> Hi all, I am trying to use the Ontology class in Biojava 1.4rc1 to create terms and triples, which are automatically persisted using the BioSQL links in BioJava. Here is my code: BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, dbUser, dbPass, biodatabase, createIfMissing); Ontology o = db.createOntology("MyOntology","An ontology"); // Use getOntology to update Term MyGroup = o.createTerm("MyGroup","My favourite terms."); Term Boo = o.createTerm("Boo","A fright"); Term ISA = o.createTerm("ISA","Is a"); Term Joke = o.createTerm("Joke","Something funny"); o.createTriple(Boo,Joke,ISA,null,null); I get the following exception (NB. the ontology does not exist yet but the database connection is just fine): Exception in thread "main" org.biojava.bio.BioRuntimeException: Error removing from BioSQL tables (rolled back successfully) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :588) at org.biojava.bio.seq.db.biosql.OntologySQL.access$300(OntologySQL.java:61 ) at org.biojava.bio.seq.db.biosql.OntologySQL$OntologyMonitor.postChange(Ont ologySQL.java:512) at org.biojava.utils.ChangeSupport.firePostChangeEvent(ChangeSupport.java:3 38) at org.biojava.ontology.Ontology$Impl.createTriple(Ontology.java:497) at testapp.LoadOntology.main(LoadOntology.java:61) Caused by: java.sql.SQLException: Failed to persist term: ISA(Boo, Joke) from ontology: ontology: MyOntology with error: 1 : 23000 at org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:5 62) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :595) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :576) ... 5 more Caused by: java.sql.SQLException: ORA-00001: unique constraint (BIOSQL_OWNER.XAK1TERM) violated at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:12 5) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.jav a:181) at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStat ement.java:543) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement. java:1028) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrepare dStatement.java:2888) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedS tatement.java:2960) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega tingPreparedStatement.java:101) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega tingPreparedStatement.java:101) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:5 54) ... 7 more Java Result: 1 When I check in the database, I find that the ontology has been created, and entries made in term for each of the terms, and also an entry has been made in term for the triple itself. So why the exception? Is it trying to insert the triple twice? cheers, Richard Richard Holland Bioinformatics Specialist Genome Institute of Singapore 60 Biopolis Street, #02-01 Genome, Singapore 138672 Tel: (65) 6478 8000 DID: (65) 6478 8199 Email: hollandr@gis.a-star.edu.sg --------------------------------------------- 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. --------------------------------------------- From mark.schreiber at group.novartis.com Thu Dec 2 03:18:24 2004 From: mark.schreiber at group.novartis.com (mark.schreiber@group.novartis.com) Date: Thu Dec 2 03:16:31 2004 Subject: [Biojava-l] Ontology and BioSQL Message-ID: Hi - The code responsible for the insert is: private void persistTriple(Connection conn, Ontology ont, Triple triple) throws SQLException { persistTerm(conn, triple); PreparedStatement import_trip = conn.prepareStatement( "insert into term_relationship " + " (subject_term_id, predicate_term_id, object_term_id, ontology_id) " + "values (?, ?, ?, ?)" ); import_trip.setInt(1, termID(triple.getSubject())); import_trip.setInt(2, termID(triple.getPredicate())); import_trip.setInt(3, termID(triple.getObject())); import_trip.setInt(4, ontologyID(ont)); import_trip.executeUpdate(); import_trip.close(); int tripID = dbHelper.getInsertID(conn, "term_relationship", "term_relationship_id"); PreparedStatement link_trip_to_term = conn.prepareStatement( "insert into term_relationship_term " + " (term_relationship_id, term_id) " + "values (?, ?)" ); link_trip_to_term.setInt(1, tripID); link_trip_to_term.setInt(2, termID(triple)); link_trip_to_term.executeUpdate(); link_trip_to_term.close(); //System.err.println("Persisted triple: " + triple); } I can't immediately see any attempt to write it twice. Are you removing the old triples before running the program again? - Mark "Richard HOLLAND" Sent by: biojava-l-bounces@portal.open-bio.org 12/02/2004 02:16 PM To: cc: (bcc: Mark Schreiber/GP/Novartis) Subject: [Biojava-l] Ontology and BioSQL Hi all, I am trying to use the Ontology class in Biojava 1.4rc1 to create terms and triples, which are automatically persisted using the BioSQL links in BioJava. Here is my code: BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, dbUser, dbPass, biodatabase, createIfMissing); Ontology o = db.createOntology("MyOntology","An ontology"); // Use getOntology to update Term MyGroup = o.createTerm("MyGroup","My favourite terms."); Term Boo = o.createTerm("Boo","A fright"); Term ISA = o.createTerm("ISA","Is a"); Term Joke = o.createTerm("Joke","Something funny"); o.createTriple(Boo,Joke,ISA,null,null); I get the following exception (NB. the ontology does not exist yet but the database connection is just fine): Exception in thread "main" org.biojava.bio.BioRuntimeException: Error removing from BioSQL tables (rolled back successfully) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :588) at org.biojava.bio.seq.db.biosql.OntologySQL.access$300(OntologySQL.java:61 ) at org.biojava.bio.seq.db.biosql.OntologySQL$OntologyMonitor.postChange(Ont ologySQL.java:512) at org.biojava.utils.ChangeSupport.firePostChangeEvent(ChangeSupport.java:3 38) at org.biojava.ontology.Ontology$Impl.createTriple(Ontology.java:497) at testapp.LoadOntology.main(LoadOntology.java:61) Caused by: java.sql.SQLException: Failed to persist term: ISA(Boo, Joke) from ontology: ontology: MyOntology with error: 1 : 23000 at org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:5 62) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :595) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :576) ... 5 more Caused by: java.sql.SQLException: ORA-00001: unique constraint (BIOSQL_OWNER.XAK1TERM) violated at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:12 5) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.jav a:181) at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStat ement.java:543) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement. java:1028) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrepare dStatement.java:2888) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedS tatement.java:2960) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega tingPreparedStatement.java:101) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega tingPreparedStatement.java:101) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:5 54) ... 7 more Java Result: 1 When I check in the database, I find that the ontology has been created, and entries made in term for each of the terms, and also an entry has been made in term for the triple itself. So why the exception? Is it trying to insert the triple twice? cheers, Richard Richard Holland Bioinformatics Specialist Genome Institute of Singapore 60 Biopolis Street, #02-01 Genome, Singapore 138672 Tel: (65) 6478 8000 DID: (65) 6478 8199 Email: hollandr@gis.a-star.edu.sg --------------------------------------------- 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. --------------------------------------------- _______________________________________________ Biojava-l mailing list - Biojava-l@biojava.org http://biojava.org/mailman/listinfo/biojava-l From hollandr at gis.a-star.edu.sg Thu Dec 2 03:52:59 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Thu Dec 2 03:51:17 2004 Subject: [Biojava-l] Ontology and BioSQL Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D5601267F7D@BIONIC.biopolis.one-north.com> Yup, this problem happened since the very first time I ran it on an empty database. The terms get created in term, the term representing the triple gets created in term, but it does not create the relationship in term_relationship. The exception is being thrown by the persistTerm call on the very first line of persistTriple. I'm thinking that this is something to do with the OntologyMonitor? That it is seeing the Triple get created, but because the Triple is an instanceof Term it is firing two change events - one for the Term representation, the other for the Triple representation? That's the only way I can see the Triple being created in the term table but not in the term_relationship table, as otherwise we'd be getting exceptions halfway through persistTriple way after that call to persistTerm at the beginning, which we're not. In other words, the Triple already exists in the term table _before_ persistTriple is getting called. Why? How? Hmm. cheers, Richard 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. --------------------------------------------- > -----Original Message----- > From: mark.schreiber@group.novartis.com > [mailto:mark.schreiber@group.novartis.com] > Sent: Thursday, December 02, 2004 4:18 PM > To: Richard HOLLAND > Cc: biojava-l@biojava.org; biojava-l-bounces@portal.open-bio.org > Subject: Re: [Biojava-l] Ontology and BioSQL > > > Hi - > > The code responsible for the insert is: > > private void persistTriple(Connection conn, Ontology ont, > Triple triple) > throws SQLException > { > persistTerm(conn, triple); > > PreparedStatement import_trip = conn.prepareStatement( > "insert into term_relationship " + > " (subject_term_id, predicate_term_id, > object_term_id, > ontology_id) " + > "values (?, ?, ?, ?)" > ); > import_trip.setInt(1, termID(triple.getSubject())); > import_trip.setInt(2, termID(triple.getPredicate())); > import_trip.setInt(3, termID(triple.getObject())); > import_trip.setInt(4, ontologyID(ont)); > import_trip.executeUpdate(); > import_trip.close(); > int tripID = dbHelper.getInsertID(conn, "term_relationship", > "term_relationship_id"); > > PreparedStatement link_trip_to_term = conn.prepareStatement( > "insert into term_relationship_term " + > " (term_relationship_id, term_id) " + > "values (?, ?)" ); > link_trip_to_term.setInt(1, tripID); > link_trip_to_term.setInt(2, termID(triple)); > link_trip_to_term.executeUpdate(); > link_trip_to_term.close(); > > //System.err.println("Persisted triple: " + triple); > } > > I can't immediately see any attempt to write it twice. Are > you removing > the old triples before running the program again? > > - Mark > > > > > > "Richard HOLLAND" > Sent by: biojava-l-bounces@portal.open-bio.org > 12/02/2004 02:16 PM > > > To: > cc: (bcc: Mark Schreiber/GP/Novartis) > Subject: [Biojava-l] Ontology and BioSQL > > > Hi all, > > I am trying to use the Ontology class in Biojava 1.4rc1 to > create terms and triples, which are automatically persisted > using the BioSQL links in BioJava. Here is my code: > > BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, > dbUser, > dbPass, > biodatabase, > createIfMissing); > > Ontology o = db.createOntology("MyOntology","An > ontology"); // Use getOntology to update > Term MyGroup = o.createTerm("MyGroup","My favourite terms."); > Term Boo = o.createTerm("Boo","A fright"); > Term ISA = o.createTerm("ISA","Is a"); > Term Joke = o.createTerm("Joke","Something funny"); > o.createTriple(Boo,Joke,ISA,null,null); > > I get the following exception (NB. the ontology does not > exist yet but the database connection is just fine): > > Exception in thread "main" > org.biojava.bio.BioRuntimeException: Error removing from > BioSQL tables (rolled back successfully) at > org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > gySQL.java > :588) > at > org.biojava.bio.seq.db.biosql.OntologySQL.access$300(OntologyS > QL.java:61 > ) > at > org.biojava.bio.seq.db.biosql.OntologySQL$OntologyMonitor.post > Change(Ont > ologySQL.java:512) > at > org.biojava.utils.ChangeSupport.firePostChangeEvent(ChangeSupp > ort.java:3 > 38) > at org.biojava.ontology.Ontology$Impl.createTriple(Ontology.java:497) > at testapp.LoadOntology.main(LoadOntology.java:61) > Caused by: java.sql.SQLException: Failed to persist term: > ISA(Boo, Joke) from ontology: ontology: MyOntology with > error: 1 : 23000 at > org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology > SQL.java:5 > 62) > at > org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > gySQL.java > :595) > at > org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > gySQL.java > :576) > ... 5 more > Caused by: java.sql.SQLException: ORA-00001: unique constraint > (BIOSQL_OWNER.XAK1TERM) violated > at > oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseErr > or.java:12 > 5) > at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305) > at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272) > at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623) > at > oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedSta > tement.jav > a:181) > at > oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPr > eparedStat > ement.java:543) > at > oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Oracle > Statement. > java:1028) > at > oracle.jdbc.driver.OraclePreparedStatement.executeInternal(Ora > clePrepare > dStatement.java:2888) > at > oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(Oracl > ePreparedS > tatement.java:2960) > at > org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd > ate(Delega > tingPreparedStatement.java:101) > at > org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd > ate(Delega > tingPreparedStatement.java:101) > at > org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology > SQL.java:5 > 54) > ... 7 more > Java Result: 1 > > When I check in the database, I find that the ontology has > been created, and entries made in term for each of the terms, > and also an entry has been made in term for the triple > itself. So why the exception? Is it trying to insert the triple twice? > > cheers, > Richard > > Richard Holland > Bioinformatics Specialist > Genome Institute of Singapore > 60 Biopolis Street, #02-01 Genome, Singapore 138672 > Tel: (65) 6478 8000 DID: (65) 6478 8199 > Email: hollandr@gis.a-star.edu.sg > > --------------------------------------------- > 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. > --------------------------------------------- > > _______________________________________________ > Biojava-l mailing list - Biojava-l@biojava.org > http://biojava.org/mailman/listinfo/biojava-l > > > > From td2 at sanger.ac.uk Thu Dec 2 05:03:10 2004 From: td2 at sanger.ac.uk (Thomas Down) Date: Thu Dec 2 05:01:36 2004 Subject: [Biojava-l] Ontology and BioSQL In-Reply-To: <6D9E9B9DF347EF4385F6271C64FB8D5601267F7D@BIONIC.biopolis.one-north.com> References: <6D9E9B9DF347EF4385F6271C64FB8D5601267F7D@BIONIC.biopolis.one-north.com> Message-ID: <5F44A1E8-4449-11D9-96FF-000A95C8B056@sanger.ac.uk> Hi Richard, We've had a problem very much like this when using BioSQL with a MySQL database -- the issue occurs when you have two "ontology terms" (which are used for a number of different purposes -- feature types, annotation keys, etc) which differ only by name. For example "organism" and "ORGANISM". There's was a discussion of this issue in MySQL here: http://www.biojava.org/pipermail/biojava-dev/2004-August/001857.html From your stacktraces, it looks like you're actually using Oracle -- I don't use Oracle myself so can't confirm that this is the same problem, but it looks very similar. Is there a way to enforce uniqueness in a case-sensitive way in Oracle? Thomas. On 2 Dec 2004, at 08:52, Richard HOLLAND wrote: > Yup, this problem happened since the very first time I ran it on an > empty database. The terms get created in term, the > term representing the triple gets created in term, but it does not > create the relationship in term_relationship. > > The exception is being thrown by the persistTerm call on the very first > line of persistTriple. > > I'm thinking that this is something to do with the OntologyMonitor? > That > it is seeing the Triple get created, but > because the Triple is an instanceof Term it is firing two change events > - one for the Term representation, the > other for the Triple representation? That's the only way I can see the > Triple being created in the term table but > not in the term_relationship table, as otherwise we'd be getting > exceptions halfway through persistTriple way after that call to > persistTerm at the beginning, which we're not. > > In other words, the Triple already exists in the term table _before_ > persistTriple is getting called. Why? How? Hmm. > > cheers, > Richard > > 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. > --------------------------------------------- > > >> -----Original Message----- >> From: mark.schreiber@group.novartis.com >> [mailto:mark.schreiber@group.novartis.com] >> Sent: Thursday, December 02, 2004 4:18 PM >> To: Richard HOLLAND >> Cc: biojava-l@biojava.org; biojava-l-bounces@portal.open-bio.org >> Subject: Re: [Biojava-l] Ontology and BioSQL >> >> >> Hi - >> >> The code responsible for the insert is: >> >> private void persistTriple(Connection conn, Ontology ont, >> Triple triple) >> throws SQLException >> { >> persistTerm(conn, triple); >> >> PreparedStatement import_trip = conn.prepareStatement( >> "insert into term_relationship " + >> " (subject_term_id, predicate_term_id, >> object_term_id, >> ontology_id) " + >> "values (?, ?, ?, ?)" >> ); >> import_trip.setInt(1, termID(triple.getSubject())); >> import_trip.setInt(2, termID(triple.getPredicate())); >> import_trip.setInt(3, termID(triple.getObject())); >> import_trip.setInt(4, ontologyID(ont)); >> import_trip.executeUpdate(); >> import_trip.close(); >> int tripID = dbHelper.getInsertID(conn, "term_relationship", >> "term_relationship_id"); >> >> PreparedStatement link_trip_to_term = conn.prepareStatement( >> "insert into term_relationship_term " + >> " (term_relationship_id, term_id) " + >> "values (?, ?)" ); >> link_trip_to_term.setInt(1, tripID); >> link_trip_to_term.setInt(2, termID(triple)); >> link_trip_to_term.executeUpdate(); >> link_trip_to_term.close(); >> >> //System.err.println("Persisted triple: " + triple); >> } >> >> I can't immediately see any attempt to write it twice. Are >> you removing >> the old triples before running the program again? >> >> - Mark >> >> >> >> >> >> "Richard HOLLAND" >> Sent by: biojava-l-bounces@portal.open-bio.org >> 12/02/2004 02:16 PM >> >> >> To: >> cc: (bcc: Mark Schreiber/GP/Novartis) >> Subject: [Biojava-l] Ontology and BioSQL >> >> >> Hi all, >> >> I am trying to use the Ontology class in Biojava 1.4rc1 to >> create terms and triples, which are automatically persisted >> using the BioSQL links in BioJava. Here is my code: >> >> BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, >> dbUser, >> dbPass, >> biodatabase, >> createIfMissing); >> >> Ontology o = db.createOntology("MyOntology","An >> ontology"); // Use getOntology to update >> Term MyGroup = o.createTerm("MyGroup","My favourite terms."); >> Term Boo = o.createTerm("Boo","A fright"); >> Term ISA = o.createTerm("ISA","Is a"); >> Term Joke = o.createTerm("Joke","Something funny"); >> o.createTriple(Boo,Joke,ISA,null,null); >> >> I get the following exception (NB. the ontology does not >> exist yet but the database connection is just fine): >> >> Exception in thread "main" >> org.biojava.bio.BioRuntimeException: Error removing from >> BioSQL tables (rolled back successfully) at >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo >> gySQL.java >> :588) >> at >> org.biojava.bio.seq.db.biosql.OntologySQL.access$300(OntologyS >> QL.java:61 >> ) >> at >> org.biojava.bio.seq.db.biosql.OntologySQL$OntologyMonitor.post >> Change(Ont >> ologySQL.java:512) >> at >> org.biojava.utils.ChangeSupport.firePostChangeEvent(ChangeSupp >> ort.java:3 >> 38) >> at org.biojava.ontology.Ontology$Impl.createTriple(Ontology.java:497) >> at testapp.LoadOntology.main(LoadOntology.java:61) >> Caused by: java.sql.SQLException: Failed to persist term: >> ISA(Boo, Joke) from ontology: ontology: MyOntology with >> error: 1 : 23000 at >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology >> SQL.java:5 >> 62) >> at >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo >> gySQL.java >> :595) >> at >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo >> gySQL.java >> :576) >> ... 5 more >> Caused by: java.sql.SQLException: ORA-00001: unique constraint >> (BIOSQL_OWNER.XAK1TERM) violated >> at >> oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseErr >> or.java:12 >> 5) >> at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305) >> at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272) >> at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623) >> at >> oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedSta >> tement.jav >> a:181) >> at >> oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPr >> eparedStat >> ement.java:543) >> at >> oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Oracle >> Statement. >> java:1028) >> at >> oracle.jdbc.driver.OraclePreparedStatement.executeInternal(Ora >> clePrepare >> dStatement.java:2888) >> at >> oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(Oracl >> ePreparedS >> tatement.java:2960) >> at >> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd >> ate(Delega >> tingPreparedStatement.java:101) >> at >> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd >> ate(Delega >> tingPreparedStatement.java:101) >> at >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology >> SQL.java:5 >> 54) >> ... 7 more >> Java Result: 1 >> >> When I check in the database, I find that the ontology has >> been created, and entries made in term for each of the terms, >> and also an entry has been made in term for the triple >> itself. So why the exception? Is it trying to insert the triple twice? >> >> cheers, >> Richard >> >> Richard Holland >> Bioinformatics Specialist >> Genome Institute of Singapore >> 60 Biopolis Street, #02-01 Genome, Singapore 138672 >> Tel: (65) 6478 8000 DID: (65) 6478 8199 >> Email: hollandr@gis.a-star.edu.sg >> >> --------------------------------------------- >> 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. >> --------------------------------------------- >> >> _______________________________________________ >> Biojava-l mailing list - Biojava-l@biojava.org >> http://biojava.org/mailman/listinfo/biojava-l >> >> >> >> > > _______________________________________________ > Biojava-l mailing list - Biojava-l@biojava.org > http://biojava.org/mailman/listinfo/biojava-l > From hollandr at gis.a-star.edu.sg Thu Dec 2 05:04:00 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Thu Dec 2 05:02:30 2004 Subject: [Biojava-l] Ontology and BioSQL Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D5601267F93@BIONIC.biopolis.one-north.com> Found it, I think! In Ontology.Impl, when you create a triple and it has a listener, it does this: 1. Fires a pre-change Ontology.TRIPLE event. 2. Calls addTerm(t) where t is the triple being created. 3. Calls addTriple(t) where t is the triple being created. 4. Fires a post-change Ontology.TRIPLE event. The post-change Ontology.TRIPLE event causes the persistTriple() routine in OntologySQL to be called. The first thing this routine does is call persistTerm() on itself, but this raises an exception because the term has somehow already been created. How? Well... Step 2 of the above calls addTerm(t) in Ontology.Impl, which fires a pre-change Ontology.TERM event on the term, puts the term into its internal map, then fires a post-change Ontology.TERM event on the term. Because the term (ie. Triple) is being monitored, these events are picked up by OntologySQL and result in the term being created in the database. Hence, when persistTriple() is later called via step 4, the term is already there and that first call to persistTerm() in the persistTriple() method is redundant. SO... How to fix? My suggestion would be removing the call to persistTerm() from the start of the persistTriple() method in OntologySQL, as the action has already been done at this stage by the Ontology.TERM change event. cheers, Richard 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. --------------------------------------------- > -----Original Message----- > From: biojava-l-bounces@portal.open-bio.org > [mailto:biojava-l-bounces@portal.open-bio.org] On Behalf Of > Richard HOLLAND > Sent: Thursday, December 02, 2004 4:53 PM > To: mark.schreiber@group.novartis.com > Cc: biojava-l@biojava.org > Subject: RE: [Biojava-l] Ontology and BioSQL > > > Yup, this problem happened since the very first time I ran it > on an empty database. The terms get created in term, the term > representing the triple gets created in term, but it does not > create the relationship in term_relationship. > > The exception is being thrown by the persistTerm call on the > very first line of persistTriple. > > I'm thinking that this is something to do with the > OntologyMonitor? That it is seeing the Triple get created, > but because the Triple is an instanceof Term it is firing two > change events > - one for the Term representation, the > other for the Triple representation? That's the only way I > can see the Triple being created in the term table but not in > the term_relationship table, as otherwise we'd be getting > exceptions halfway through persistTriple way after that call > to persistTerm at the beginning, which we're not. > > In other words, the Triple already exists in the term table > _before_ persistTriple is getting called. Why? How? Hmm. > > cheers, > Richard > > 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. > --------------------------------------------- > > > > -----Original Message----- > > From: mark.schreiber@group.novartis.com > > [mailto:mark.schreiber@group.novartis.com] > > Sent: Thursday, December 02, 2004 4:18 PM > > To: Richard HOLLAND > > Cc: biojava-l@biojava.org; biojava-l-bounces@portal.open-bio.org > > Subject: Re: [Biojava-l] Ontology and BioSQL > > > > > > Hi - > > > > The code responsible for the insert is: > > > > private void persistTriple(Connection conn, Ontology ont, > > Triple triple) > > throws SQLException > > { > > persistTerm(conn, triple); > > > > PreparedStatement import_trip = conn.prepareStatement( > > "insert into term_relationship " + > > " (subject_term_id, predicate_term_id, > > object_term_id, > > ontology_id) " + > > "values (?, ?, ?, ?)" > > ); > > import_trip.setInt(1, termID(triple.getSubject())); > > import_trip.setInt(2, termID(triple.getPredicate())); > > import_trip.setInt(3, termID(triple.getObject())); > > import_trip.setInt(4, ontologyID(ont)); > > import_trip.executeUpdate(); > > import_trip.close(); > > int tripID = dbHelper.getInsertID(conn, "term_relationship", > > "term_relationship_id"); > > > > PreparedStatement link_trip_to_term = conn.prepareStatement( > > "insert into term_relationship_term " + > > " (term_relationship_id, term_id) " + > > "values (?, ?)" ); > > link_trip_to_term.setInt(1, tripID); > > link_trip_to_term.setInt(2, termID(triple)); > > link_trip_to_term.executeUpdate(); > > link_trip_to_term.close(); > > > > //System.err.println("Persisted triple: " + triple); > > } > > > > I can't immediately see any attempt to write it twice. Are > > you removing > > the old triples before running the program again? > > > > - Mark > > > > > > > > > > > > "Richard HOLLAND" > > Sent by: biojava-l-bounces@portal.open-bio.org > > 12/02/2004 02:16 PM > > > > > > To: > > cc: (bcc: Mark Schreiber/GP/Novartis) > > Subject: [Biojava-l] Ontology and BioSQL > > > > > > Hi all, > > > > I am trying to use the Ontology class in Biojava 1.4rc1 to > > create terms and triples, which are automatically persisted > > using the BioSQL links in BioJava. Here is my code: > > > > BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, > > dbUser, > > dbPass, > > biodatabase, > > createIfMissing); > > > > Ontology o = db.createOntology("MyOntology","An > > ontology"); // Use getOntology to update > > Term MyGroup = o.createTerm("MyGroup","My favourite > terms."); > > Term Boo = o.createTerm("Boo","A fright"); > > Term ISA = o.createTerm("ISA","Is a"); > > Term Joke = o.createTerm("Joke","Something funny"); > > o.createTriple(Boo,Joke,ISA,null,null); > > > > I get the following exception (NB. the ontology does not > > exist yet but the database connection is just fine): > > > > Exception in thread "main" > > org.biojava.bio.BioRuntimeException: Error removing from > > BioSQL tables (rolled back successfully) at > > org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > > gySQL.java > > :588) > > at > > org.biojava.bio.seq.db.biosql.OntologySQL.access$300(OntologyS > > QL.java:61 > > ) > > at > > org.biojava.bio.seq.db.biosql.OntologySQL$OntologyMonitor.post > > Change(Ont > > ologySQL.java:512) > > at > > org.biojava.utils.ChangeSupport.firePostChangeEvent(ChangeSupp > > ort.java:3 > > 38) > > at > org.biojava.ontology.Ontology$Impl.createTriple(Ontology.java:497) > > at testapp.LoadOntology.main(LoadOntology.java:61) > > Caused by: java.sql.SQLException: Failed to persist term: > > ISA(Boo, Joke) from ontology: ontology: MyOntology with > > error: 1 : 23000 at > > org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology > > SQL.java:5 > > 62) > > at > > org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > > gySQL.java > > :595) > > at > > org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > > gySQL.java > > :576) > > ... 5 more > > Caused by: java.sql.SQLException: ORA-00001: unique constraint > > (BIOSQL_OWNER.XAK1TERM) violated > > at > > oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseErr > > or.java:12 > > 5) > > at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305) > > at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272) > > at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623) > > at > > oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedSta > > tement.jav > > a:181) > > at > > oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPr > > eparedStat > > ement.java:543) > > at > > oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Oracle > > Statement. > > java:1028) > > at > > oracle.jdbc.driver.OraclePreparedStatement.executeInternal(Ora > > clePrepare > > dStatement.java:2888) > > at > > oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(Oracl > > ePreparedS > > tatement.java:2960) > > at > > org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd > > ate(Delega > > tingPreparedStatement.java:101) > > at > > org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd > > ate(Delega > > tingPreparedStatement.java:101) > > at > > org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology > > SQL.java:5 > > 54) > > ... 7 more > > Java Result: 1 > > > > When I check in the database, I find that the ontology has > > been created, and entries made in term for each of the terms, > > and also an entry has been made in term for the triple > > itself. So why the exception? Is it trying to insert the > triple twice? > > > > cheers, > > Richard > > > > Richard Holland > > Bioinformatics Specialist > > Genome Institute of Singapore > > 60 Biopolis Street, #02-01 Genome, Singapore 138672 > > Tel: (65) 6478 8000 DID: (65) 6478 8199 > > Email: hollandr@gis.a-star.edu.sg > > > > --------------------------------------------- > > 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. > > --------------------------------------------- > > > > _______________________________________________ > > Biojava-l mailing list - Biojava-l@biojava.org > > http://biojava.org/mailman/listinfo/biojava-l > > > > > > > > > > _______________________________________________ > Biojava-l mailing list - Biojava-l@biojava.org > http://biojava.org/mailman/listinfo/biojava-l > From hollandr at gis.a-star.edu.sg Thu Dec 2 05:05:15 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Thu Dec 2 05:03:45 2004 Subject: [Biojava-l] Ontology and BioSQL Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D5601267F94@BIONIC.biopolis.one-north.com> That'd be nice but unfortunately Oracle is case-sensitive. However I think I just got what was causing it, see my post of 5 seconds ago. I'm not sure why it hasn't broken for other people though. cheers, Richard 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. --------------------------------------------- > -----Original Message----- > From: Thomas Down [mailto:td2@sanger.ac.uk] > Sent: Thursday, December 02, 2004 6:03 PM > To: Richard HOLLAND > Cc: mark.schreiber@group.novartis.com; biojava-l@biojava.org > Subject: Re: [Biojava-l] Ontology and BioSQL > > > Hi Richard, > > We've had a problem very much like this when using BioSQL > with a MySQL > database -- the issue occurs when you have two "ontology > terms" (which > are used for a number of different purposes -- feature types, > annotation keys, etc) which differ only by name. For example > "organism" and "ORGANISM". There's was a discussion of this issue in > MySQL here: > > > http://www.biojava.org/pipermail/biojava-dev/2004-August/001857.html > > From your stacktraces, it looks like you're actually using > Oracle -- I > don't use Oracle myself so can't confirm that this is the > same problem, > but it looks very similar. > > Is there a way to enforce uniqueness in a case-sensitive way > in Oracle? > > Thomas. > > > On 2 Dec 2004, at 08:52, Richard HOLLAND wrote: > > > Yup, this problem happened since the very first time I ran it on an > > empty database. The terms get created in term, the term > representing > > the triple gets created in term, but it does not create the > > relationship in term_relationship. > > > > The exception is being thrown by the persistTerm call on the very > > first line of persistTriple. > > > > I'm thinking that this is something to do with the OntologyMonitor? > > That > > it is seeing the Triple get created, but > > because the Triple is an instanceof Term it is firing two > change events > > - one for the Term representation, the > > other for the Triple representation? That's the only way I > can see the > > Triple being created in the term table but > > not in the term_relationship table, as otherwise we'd be getting > > exceptions halfway through persistTriple way after that call to > > persistTerm at the beginning, which we're not. > > > > In other words, the Triple already exists in the term table > _before_ > > persistTriple is getting called. Why? How? Hmm. > > > > cheers, > > Richard > > > > 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. > > --------------------------------------------- > > > > > >> -----Original Message----- > >> From: mark.schreiber@group.novartis.com > >> [mailto:mark.schreiber@group.novartis.com] > >> Sent: Thursday, December 02, 2004 4:18 PM > >> To: Richard HOLLAND > >> Cc: biojava-l@biojava.org; biojava-l-bounces@portal.open-bio.org > >> Subject: Re: [Biojava-l] Ontology and BioSQL > >> > >> > >> Hi - > >> > >> The code responsible for the insert is: > >> > >> private void persistTriple(Connection conn, Ontology ont, Triple > >> triple) > >> throws SQLException > >> { > >> persistTerm(conn, triple); > >> > >> PreparedStatement import_trip = conn.prepareStatement( > >> "insert into term_relationship " + > >> " (subject_term_id, predicate_term_id, > >> object_term_id, > >> ontology_id) " + > >> "values (?, ?, ?, ?)" > >> ); > >> import_trip.setInt(1, termID(triple.getSubject())); > >> import_trip.setInt(2, termID(triple.getPredicate())); > >> import_trip.setInt(3, termID(triple.getObject())); > >> import_trip.setInt(4, ontologyID(ont)); > >> import_trip.executeUpdate(); > >> import_trip.close(); > >> int tripID = dbHelper.getInsertID(conn, "term_relationship", > >> "term_relationship_id"); > >> > >> PreparedStatement link_trip_to_term = conn.prepareStatement( > >> "insert into term_relationship_term " + > >> " (term_relationship_id, term_id) " + > >> "values (?, ?)" ); > >> link_trip_to_term.setInt(1, tripID); > >> link_trip_to_term.setInt(2, termID(triple)); > >> link_trip_to_term.executeUpdate(); > >> link_trip_to_term.close(); > >> > >> //System.err.println("Persisted triple: " + triple); > >> } > >> > >> I can't immediately see any attempt to write it twice. Are you > >> removing the old triples before running the program again? > >> > >> - Mark > >> > >> > >> > >> > >> > >> "Richard HOLLAND" > >> Sent by: biojava-l-bounces@portal.open-bio.org > >> 12/02/2004 02:16 PM > >> > >> > >> To: > >> cc: (bcc: Mark Schreiber/GP/Novartis) > >> Subject: [Biojava-l] Ontology and BioSQL > >> > >> > >> Hi all, > >> > >> I am trying to use the Ontology class in Biojava 1.4rc1 to create > >> terms and triples, which are automatically persisted using > the BioSQL > >> links in BioJava. Here is my code: > >> > >> BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, > >> dbUser, > >> dbPass, > >> biodatabase, > >> createIfMissing); > >> > >> Ontology o = db.createOntology("MyOntology","An > >> ontology"); // Use getOntology to update > >> Term MyGroup = o.createTerm("MyGroup","My > favourite terms."); > >> Term Boo = o.createTerm("Boo","A fright"); > >> Term ISA = o.createTerm("ISA","Is a"); > >> Term Joke = o.createTerm("Joke","Something funny"); > >> o.createTriple(Boo,Joke,ISA,null,null); > >> > >> I get the following exception (NB. the ontology does not exist yet > >> but the database connection is just fine): > >> > >> Exception in thread "main" > >> org.biojava.bio.BioRuntimeException: Error removing from BioSQL > >> tables (rolled back successfully) at > >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > >> gySQL.java > >> :588) > >> at org.biojava.bio.seq.db.biosql.OntologySQL.access$300(OntologyS > >> QL.java:61 > >> ) > >> at > >> org.biojava.bio.seq.db.biosql.OntologySQL$OntologyMonitor.post > >> Change(Ont > >> ologySQL.java:512) > >> at > >> org.biojava.utils.ChangeSupport.firePostChangeEvent(ChangeSupp > >> ort.java:3 > >> 38) > >> at > org.biojava.ontology.Ontology$Impl.createTriple(Ontology.java:497) > >> at testapp.LoadOntology.main(LoadOntology.java:61) > >> Caused by: java.sql.SQLException: Failed to persist term: > >> ISA(Boo, Joke) from ontology: ontology: MyOntology with > >> error: 1 : 23000 at > >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology > >> SQL.java:5 > >> 62) > >> at > >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > >> gySQL.java > >> :595) > >> at > >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(Ontolo > >> gySQL.java > >> :576) > >> ... 5 more > >> Caused by: java.sql.SQLException: ORA-00001: unique constraint > >> (BIOSQL_OWNER.XAK1TERM) violated > >> at > >> oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseErr > >> or.java:12 > >> 5) > >> at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305) > >> at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272) > >> at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623) > >> at > >> oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedSta > >> tement.jav > >> a:181) > >> at > >> oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPr > >> eparedStat > >> ement.java:543) > >> at > >> oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Oracle > >> Statement. > >> java:1028) > >> at > >> oracle.jdbc.driver.OraclePreparedStatement.executeInternal(Ora > >> clePrepare > >> dStatement.java:2888) > >> at > >> oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(Oracl > >> ePreparedS > >> tatement.java:2960) > >> at > >> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd > >> ate(Delega > >> tingPreparedStatement.java:101) > >> at > >> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpd > >> ate(Delega > >> tingPreparedStatement.java:101) > >> at > >> org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(Ontology > >> SQL.java:5 > >> 54) > >> ... 7 more > >> Java Result: 1 > >> > >> When I check in the database, I find that the ontology has been > >> created, and entries made in term for each of the terms, > and also an > >> entry has been made in term for the triple itself. So why the > >> exception? Is it trying to insert the triple twice? > >> > >> cheers, > >> Richard > >> > >> Richard Holland > >> Bioinformatics Specialist > >> Genome Institute of Singapore > >> 60 Biopolis Street, #02-01 Genome, Singapore 138672 > >> Tel: (65) 6478 8000 DID: (65) 6478 8199 > >> Email: hollandr@gis.a-star.edu.sg > >> > >> --------------------------------------------- > >> 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. > >> --------------------------------------------- > >> > >> _______________________________________________ > >> Biojava-l mailing list - Biojava-l@biojava.org > >> http://biojava.org/mailman/listinfo/biojava-l > >> > >> > >> > >> > > > > _______________________________________________ > > Biojava-l mailing list - Biojava-l@biojava.org > > http://biojava.org/mailman/listinfo/biojava-l > > > > From hollandr at gis.a-star.edu.sg Thu Dec 2 22:43:08 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Thu Dec 2 22:41:29 2004 Subject: [Biojava-l] Fix to org.biojava.bio.seq.db.biosql.OntologySQL Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D5601267FF9@BIONIC.biopolis.one-north.com> By commenting out the first call to persistTerm() from the beginning of persistTriple() in org.biojava.bio.seq.db.biosql.OntologySQL and recompiling biojava.jar, I managed to solve yesterday's problem of duplicate value errors when inserting triples by calling o.createTriple() on an ontology obtained from an BioSQLSequenceDB object. The upload example I gave now works without a hitch. Does anyone want to verify this and update CVS if it works and doesn't break anything else? cheers, Richard 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. --------------------------------------------- From hollandr at gis.a-star.edu.sg Wed Dec 1 02:58:08 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Mon Dec 6 09:20:49 2004 Subject: [Biojava-l] Ontology and BioSQL Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D5601267E92@BIONIC.biopolis.one-north.com> Hi all, I am trying to use the Ontology class in Biojava 1.4rc1 to create terms and triples, which are automatically persisted using the BioSQL links in BioJava. Here is my code: BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, dbUser, dbPass, biodatabase, createIfMissing); Ontology o = db.createOntology("MyOntology","An ontology"); // Use getOntology to update Term MyGroup = o.createTerm("MyGroup","My favourite terms."); Term Boo = o.createTerm("Boo","A fright"); Term ISA = o.createTerm("ISA","Is a"); Term Joke = o.createTerm("Joke","Something funny"); o.createTriple(Boo,Joke,ISA,null,null); I get the following exception (NB. the ontology does not exist yet but the database connection is just fine): Exception in thread "main" org.biojava.bio.BioRuntimeException: Error removing from BioSQL tables (rolled back successfully) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :588) at org.biojava.bio.seq.db.biosql.OntologySQL.access$300(OntologySQL.java:61 ) at org.biojava.bio.seq.db.biosql.OntologySQL$OntologyMonitor.postChange(Ont ologySQL.java:512) at org.biojava.utils.ChangeSupport.firePostChangeEvent(ChangeSupport.java:3 38) at org.biojava.ontology.Ontology$Impl.createTriple(Ontology.java:497) at testapp.LoadOntology.main(LoadOntology.java:61) Caused by: java.sql.SQLException: Failed to persist term: ISA(Boo, Joke) from ontology: ontology: MyOntology with error: 1 : 23000 at org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:5 62) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :595) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTriple(OntologySQL.java :576) ... 5 more Caused by: java.sql.SQLException: ORA-00001: unique constraint (BIOSQL_OWNER.XAK1TERM) violated at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:12 5) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.jav a:181) at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStat ement.java:543) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement. java:1028) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrepare dStatement.java:2888) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedS tatement.java:2960) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega tingPreparedStatement.java:101) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(Delega tingPreparedStatement.java:101) at org.biojava.bio.seq.db.biosql.OntologySQL.persistTerm(OntologySQL.java:5 54) ... 7 more Java Result: 1 When I check in the database, I find that the ontology has been created, and entries made in term for each of the terms, and also an entry has been made in term for the triple itself. So why the exception? Is it trying to insert the triple twice? cheers, Richard Richard Holland Bioinformatics Specialist Genome Institute of Singapore 60 Biopolis Street, #02-01 Genome, Singapore 138672 Tel: (65) 6478 8000 DID: (65) 6478 8199 Email: hollandr@gis.a-star.edu.sg --------------------------------------------- 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. --------------------------------------------- From cgarnier at ttz-Bremerhaven.de Mon Dec 6 10:16:58 2004 From: cgarnier at ttz-Bremerhaven.de (BIBIS, Garnier, Christophe) Date: Mon Dec 6 10:13:05 2004 Subject: AW: [Biojava-l] Parse Genbank file Message-ID: Hello, It means it did not find a class, probably the Alphabet class but i wonder why because it is an Interface part of the biojava distribution. Be sure you have the biojava jar file available in your classpath. And maybe if you want to parse a genbank file use something like that (see as well the tutorials): private static void readGenBankFile() { BufferedReader br = null; File f = new File("your_genbank_file_path"); try { br = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { ex.printStackTrace(); System.exit(-1); } SequenceIterator sequences = SeqIOTools.readGenbank(br); while (sequences.hasNext()) { try { Sequence seq = sequences.nextSequence(); System.out.println("sequence: " + seq); printSequence(seq); } catch (BioException ex) { ex.printStackTrace(); } catch (NoSuchElementException ex) { ex.printStackTrace(); } } } Regards, christophe -----Urspr¨¹ngliche Nachricht----- Von: Xingen Zhu [mailto:xingenzhu@yahoo.com.cn] Gesendet: Montag, 29. November 2004 18:46 An: biojava-l@biojava.org Betreff: [Biojava-l] Parse Genbank file Hi all, I am a new user of biojava. I use the following java program to parse a genebank file: import java.util.*; import java.io.*; import org.biojava.bio.*; import org.biojava.bio.symbol.*; import org.biojava.bio.seq.*; import org.biojava.bio.seq.io.*; public class biojava { public static void main(String[] args) { try { File genbankFile = new File("e:\\java\\gb.txt"); BufferedReader gReader = new BufferedReader(new InputStreamReader(new FileInputStream(genbankFile))); GenbankFormat gFormat = new GenbankFormat(); Alphabet alpha = DNATools.getDNA(); } catch (Throwable t) { t.printStackTrace(); System.exit(1); } } } This program can be compiled, but not run. The error message is Java.lang.NoClassDefFoundError If delete the following line Alphabet alpha = DNATools.getDNA(); It will complie and run Any idea? Thanks a lot. Michael --------------------------------- Do You Yahoo!? ÏÓÓÊÏä̫С£¿ÑÅ»¢µçÓÊ×ÔÖúÀ©ÈÝ£¡ From ady at sanger.ac.uk Mon Dec 6 10:31:09 2004 From: ady at sanger.ac.uk (Andy Yates) Date: Mon Dec 6 10:28:46 2004 Subject: AW: [Biojava-l] Parse Genbank file In-Reply-To: References: Message-ID: <41B47B3D.6030902@sanger.ac.uk> Hi, I have to agree that this sounds like a classpath issue. Usually it means that you have correctly specified Biojava in your javac compile classpath but you lack it in your java run cmd. If you're using ant to do the compile and run a good technique is to have a classpath property and use this whenever you try to compile and run. That's what we do in our department when I get my way :) Andy Yates ====== Computer Biologist. CancerIT - Cancer Genome Project, The Wellcome Trust Sanger Institute. BIBIS, Garnier, Christophe wrote: > Hello, > > It means it did not find a class, probably the Alphabet class but i wonder > why because it is an Interface part of the biojava distribution. > Be sure you have the biojava jar file available in your classpath. > > And maybe if you want to parse a genbank file use something like that (see > as well the tutorials): > > private static void readGenBankFile() > { > BufferedReader br = null; > File f = new File("your_genbank_file_path"); > > try > { > br = new BufferedReader(new FileReader(f)); > } > catch (FileNotFoundException ex) > { > ex.printStackTrace(); > System.exit(-1); > } > > SequenceIterator sequences = SeqIOTools.readGenbank(br); > while (sequences.hasNext()) > { > try > { > Sequence seq = sequences.nextSequence(); > > System.out.println("sequence: " + seq); > printSequence(seq); > > } > catch (BioException ex) > { > ex.printStackTrace(); > } > catch (NoSuchElementException ex) > { > ex.printStackTrace(); > } > } > } > > > > Regards, > christophe > > -----Urspr?ngliche Nachricht----- > Von: Xingen Zhu [mailto:xingenzhu@yahoo.com.cn] > Gesendet: Montag, 29. November 2004 18:46 > An: biojava-l@biojava.org > Betreff: [Biojava-l] Parse Genbank file > > > Hi all, > I am a new user of biojava. I use the following java program to parse a > genebank file: > import java.util.*; > import java.io.*; > > import org.biojava.bio.*; > import org.biojava.bio.symbol.*; > import org.biojava.bio.seq.*; > import org.biojava.bio.seq.io.*; > > public class biojava { > > public static void main(String[] args) { > try { > File genbankFile = new File("e:\\java\\gb.txt"); > BufferedReader gReader = new BufferedReader(new > InputStreamReader(new FileInputStream(genbankFile))); > GenbankFormat gFormat = new GenbankFormat(); > Alphabet alpha = DNATools.getDNA(); > > } catch (Throwable t) { > t.printStackTrace(); > System.exit(1); > } > > } > } > > > This program can be compiled, but not run. The error message is > Java.lang.NoClassDefFoundError > > If delete the following line > Alphabet alpha = DNATools.getDNA(); > > It will complie and run > > Any idea? > > Thanks a lot. > Michael > > > > > --------------------------------- > Do You Yahoo!? > ??????????????? > > _______________________________________________ > Biojava-l mailing list - Biojava-l@biojava.org > http://biojava.org/mailman/listinfo/biojava-l From cs at is-analyse.de Wed Dec 8 06:41:10 2004 From: cs at is-analyse.de (Christian Storm) Date: Wed Dec 8 06:36:02 2004 Subject: [Biojava-l] Genpept format - missing features Message-ID: <001f01c4dd1a$ec7ed600$6502a8c0@ARBEIT> Hi, using the following code Sequence seq = sequences.nextSequence(); SeqIOTools.writeGenpept(System.out,seq); I tried to write out a sequence in Genpept format. The sequence was previoulsy parsed in from a Genpept (NCBI protein) - format file. (http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&val=13568390) Biojava 1.4pre1 gives me some output, but is missing all features. I then tried Biojava1.3, with even worse results: Exception in thread "main" org.biojava.bio.symbol.IllegalSymbolException: Symbol ARG not found in alphabet DNA at org.biojava.bio.symbol.AbstractAlphabet.validate(AbstractAlphabet.java:278) ... I had a brief look at the biojava-sourcecode. It seems to me that Genpept format files are not really expected to stand on their own? I.e. protein - sequences are only handled correct if part of a Genbank (nucleotide) file? That would explain why I get an IllegalSymbolException - a DNA sequence is expected where in the Genpept format the AA sequence is. Strangely enough the file is parsed in correctly ... . Or is there something I am missing? Thanks in advance! Christian From mark.schreiber at group.novartis.com Mon Dec 13 04:27:48 2004 From: mark.schreiber at group.novartis.com (mark.schreiber@group.novartis.com) Date: Mon Dec 13 04:25:12 2004 Subject: [Biojava-l] Recent additions to BJIA Message-ID: Hello all - There have been some recent updates to BioJava in Anger. There is a link under 'Publications' that will search the new Google Scholar site for references to BioJava. There is a new tutorial on how to make a custom SearchContentHandler (http://www.biojava.org/docs/bj_in_anger/blastecho.htm) which shows which part of the blast parsing process are emmitted as what type of events and also gives some clues on how you would make a parser that can handle very large files or a parser that only cares about a small subset of information. Finally there is a tutorial on how to set up Biojava and BioSQL using Oracle (http://www.biojava.org/docs/bj_in_anger/bj_and_bsql_oracle_howto.htm). Credit for this page goes to Richard Holland from the Genome Institute in Singapore. There will probably be a few more additions over the next few days. Enjoy... Mark Schreiber Principal Scientist (Bioinformatics) Novartis Institute for Tropical Diseases (NITD) 10 Biopolis Road #05-01 Chromos Singapore 138670 www.nitd.novartis.com phone +65 6722 2973 fax +65 6722 2910 From cs at is-analyse.de Thu Dec 16 07:35:40 2004 From: cs at is-analyse.de (Christian Storm) Date: Thu Dec 16 07:28:57 2004 Subject: [Biojava-l] Adapting org.biojava.bio.seq classes to an interface? Message-ID: <000701c4e36b$c1639030$6502a8c0@ARBEIT> Is there a way of adapting org.biojava.bio.seq classes / interfaces to an interface? I would like to add functionality to some of the interfaces in org.biojava.bio.seq, i.e. sequence and feature, by adapting them to an existing interface. I see two possibilites - a class adapter: OwnSequence extends SimpleSequence implements NewFunctionality or an object Adapter: OwnSequence implements Sequence, NewFunctionality Unfortunately both approaches would mean massive recoding of the parsing /building process of sequence-objects, so that in essence it would be simpler for me to write my own classes to handle sequences. Anyone an idea? Cheers, Christian From cs at is-analyse.de Thu Dec 16 07:40:40 2004 From: cs at is-analyse.de (Christian Storm) Date: Thu Dec 16 07:33:23 2004 Subject: [Biojava-l] Adapting org.biojava.bio.seq classes to an interface? Message-ID: <000f01c4e36c$73e531f0$6502a8c0@ARBEIT> For clarification: The problem is that the new class OwnSequence should contain OwnFeature objects rather than Feature objects. From td2 at sanger.ac.uk Thu Dec 16 09:54:30 2004 From: td2 at sanger.ac.uk (Thomas Down) Date: Thu Dec 16 09:51:43 2004 Subject: [Biojava-l] Adapting org.biojava.bio.seq classes to an interface? In-Reply-To: <000701c4e36b$c1639030$6502a8c0@ARBEIT> References: <000701c4e36b$c1639030$6502a8c0@ARBEIT> Message-ID: <63EED7DD-4F72-11D9-B892-000A95C8B056@sanger.ac.uk> On 16 Dec 2004, at 12:35, Christian Storm wrote: > Is there a way of adapting org.biojava.bio.seq classes / interfaces to > an interface? > > I would like to add functionality to some of the interfaces in > org.biojava.bio.seq, i.e. sequence and feature, by adapting them to an > existing interface. > > I see two possibilites - a class adapter: > > OwnSequence extends SimpleSequence implements NewFunctionality > > or an object Adapter: > > OwnSequence implements Sequence, NewFunctionality > > Unfortunately both approaches would mean massive recoding of the > parsing /building process of sequence-objects, so that in essence it > would be simpler for me to write my own classes to handle sequences. Hi Christian, The BioJava sequence model was written with the possibility of dropping in new implementations in mind, and it certainly ought to be possible to do this -- whatever approach you choose to take -- without having to rewrite things like parsing code. A good place to start looking is the SequenceBuilder interface, which receives events from the parsing framework and constructs Sequence objects. By developing a new implementation of this, you'll be able to use any of the BioJava parsers. Depending on the exact details of your new Sequence implementation, you'll quite possibly be able to get away with a very small subclass of SequenceBuilderBase. Thomas. From cs at is-analyse.de Thu Dec 16 14:34:09 2004 From: cs at is-analyse.de (Christian Storm) Date: Thu Dec 16 14:26:40 2004 Subject: [Biojava-l] Adapting org.biojava.bio.seq classes to an interface? References: <000701c4e36b$c1639030$6502a8c0@ARBEIT> <63EED7DD-4F72-11D9-B892-000A95C8B056@sanger.ac.uk> Message-ID: <001001c4e3a6$371bedb0$6502a8c0@ARBEIT> Thanks! Ended up implementing SequenceBuilder from scratch rather than subclassing SequenceBuilderBase, but now it works nicely. Christian ----- Original Message ----- From: "Thomas Down" To: "Christian Storm" Cc: Sent: Thursday, December 16, 2004 3:54 PM Subject: Re: [Biojava-l] Adapting org.biojava.bio.seq classes to an interface? > > On 16 Dec 2004, at 12:35, Christian Storm wrote: > >> Is there a way of adapting org.biojava.bio.seq classes / interfaces to an >> interface? >> >> I would like to add functionality to some of the interfaces in >> org.biojava.bio.seq, i.e. sequence and feature, by adapting them to an >> existing interface. >> >> I see two possibilites - a class adapter: >> >> OwnSequence extends SimpleSequence implements NewFunctionality >> >> or an object Adapter: >> >> OwnSequence implements Sequence, NewFunctionality >> >> Unfortunately both approaches would mean massive recoding of the parsing >> /building process of sequence-objects, so that in essence it would be >> simpler for me to write my own classes to handle sequences. > > Hi Christian, > > The BioJava sequence model was written with the possibility of dropping in > new implementations in mind, and it certainly ought to be possible to do > this -- whatever approach you choose to take -- without having to rewrite > things like parsing code. A good place to start looking is the > SequenceBuilder interface, which receives events from the parsing > framework and constructs Sequence objects. By developing a new > implementation of this, you'll be able to use any of the BioJava parsers. > Depending on the exact details of your new Sequence implementation, you'll > quite possibly be able to get away with a very small subclass of > SequenceBuilderBase. > > Thomas. > From kenny at gem-hs.org Thu Dec 16 23:31:39 2004 From: kenny at gem-hs.org (Kenny Chamber) Date: Thu Dec 16 23:29:01 2004 Subject: [Biojava-l] proxy problem Message-ID: <41C2612B.4050307@gem-hs.org> I think there is a proxy problem in org.biojava.directory package. When a guy uses a computer which needs a proxy to link abroad, it will fail to use biofetch(as far as I know, this situation is often in many labs to save money).So I suggest when biojava uses a netIO,it should be able to use a proxy.Any ideas? ----------------------- Kenny Chamber http://gem-hs.org/contact.html From hollandr at gis.a-star.edu.sg Thu Dec 16 23:42:23 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Thu Dec 16 23:40:16 2004 Subject: [Biojava-l] Exception handling Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D560140E333@BIONIC.biopolis.one-north.com> Hi all, I'd like to be able to catch exceptions and handle them but it seems that many BioJava exceptions are sub-classes of the system kill everything no matter what exception, which makes them uncatchable. For instance if I try and load a junk sequence using DNATools, I get an exception quite rightly complaining about the alphabet, but even though I try-catch the code that parses this junk sequence (for Exception), the program quits completely without my exception handler or any further code being called. Is this deliberate? Surely it would be nicer to allow these exceptions to be caught? I have noticed that many routines in the BioJava source code throw BioException (or a name similar to that, can't remember...), yet do not declare it in their method signatures. This could be why. It'd be much nicer to actually declare you are going to throw an exception, what type it is likely to be, then behave nicely instead of killing the whole app. cheers, Richard 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. --------------------------------------------- From mark.schreiber at group.novartis.com Fri Dec 17 00:26:54 2004 From: mark.schreiber at group.novartis.com (mark.schreiber@group.novartis.com) Date: Fri Dec 17 00:24:30 2004 Subject: [Biojava-l] Exception handling Message-ID: Hello - Exceptions that extend RuntimeException don't have to be caught. This was a contraversial decision by the Java designers so they could make things like NullPointerException. If you think of all the times you could throw a null pointer exception you would need a hell of a lot of try catch statements (one for everytime you pass an object reference). Classes that extend RuntimeException are supposed to indicate failures due to bad programming practice. They shouldn't really occur in a well made program. You can catch them, you just have to know when they might be thrown. You should only try to catch them if you can recover sensibly though so most times you wouldn't bother unless you have a system that needs to run 24/7 without crashing. BioRuntimeException is one of these but hardly used in the API. The other type of Throwable is that doesn't need to be caught is Error (BioError is one of these, also rarely used). Errors are generally considered to be unrecoverable. You generally log them, shutdown as gracefully as possible and call tech support. BioException is much more common. This extends good old Exception and must be declared and caught. It is used all over. So I'm not sure what the problem is. If you call DNATools.createDNA and throw some rubbish at it you will probably get something like IllegalSymbolException (subclass of BioException). You can catch this. Without seeing the program or stack trace all I can think of is that some bug is causing an Error to be thrown somewhere. The only other possibility is that you have two catch statements that conflict. Eg if you catch BioException and exit before you catch IllegalSymbolException then you won't reach this. Although your compiler should complain about this so it seems unlikely. Can you send the source? or that exception stack? - Mark "Richard HOLLAND" Sent by: biojava-l-bounces@portal.open-bio.org 12/17/2004 12:42 PM To: cc: (bcc: Mark Schreiber/GP/Novartis) Subject: [Biojava-l] Exception handling Hi all, I'd like to be able to catch exceptions and handle them but it seems that many BioJava exceptions are sub-classes of the system kill everything no matter what exception, which makes them uncatchable. For instance if I try and load a junk sequence using DNATools, I get an exception quite rightly complaining about the alphabet, but even though I try-catch the code that parses this junk sequence (for Exception), the program quits completely without my exception handler or any further code being called. Is this deliberate? Surely it would be nicer to allow these exceptions to be caught? I have noticed that many routines in the BioJava source code throw BioException (or a name similar to that, can't remember...), yet do not declare it in their method signatures. This could be why. It'd be much nicer to actually declare you are going to throw an exception, what type it is likely to be, then behave nicely instead of killing the whole app. cheers, Richard 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. --------------------------------------------- _______________________________________________ Biojava-l mailing list - Biojava-l@biojava.org http://biojava.org/mailman/listinfo/biojava-l From mark.schreiber at group.novartis.com Fri Dec 17 00:38:32 2004 From: mark.schreiber at group.novartis.com (mark.schreiber@group.novartis.com) Date: Fri Dec 17 00:35:42 2004 Subject: [Biojava-l] proxy problem Message-ID: You can set proxy parameters as environment variables in the command line of java. There you can set the proxyPort etc. The syntax escapes me now (and has changed over time) java -D "proxyHost=myhost.com" myprogram (or something). A quick Google search will find it. Your other option is to set proxy variables in your program: System.setProperty("proxySet", "true"); System.setProperty("http.proxyHost", "proxy.myhost.com"); System.setProperty("http.proxyPort", "80"); If you do this before you call any network classes (such as those in biofetch) your program should navigate through your proxy. If you have an authenticating proxy (eg one that knows who you are and expects your own unique password this is more tricky but can be done). Hope this helps, Mark Kenny Chamber Sent by: biojava-l-bounces@portal.open-bio.org 12/17/2004 12:31 PM To: biojava-l@biojava.org cc: (bcc: Mark Schreiber/GP/Novartis) Subject: [Biojava-l] proxy problem I think there is a proxy problem in org.biojava.directory package. When a guy uses a computer which needs a proxy to link abroad, it will fail to use biofetch(as far as I know, this situation is often in many labs to save money).So I suggest when biojava uses a netIO,it should be able to use a proxy.Any ideas? ----------------------- Kenny Chamber http://gem-hs.org/contact.html _______________________________________________ Biojava-l mailing list - Biojava-l@biojava.org http://biojava.org/mailman/listinfo/biojava-l From hollandr at gis.a-star.edu.sg Tue Dec 28 20:56:43 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Tue Dec 28 20:54:22 2004 Subject: [Biojava-l] Exception not being caught. Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D560140E6D8@BIONIC.biopolis.one-north.com> 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.(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() Message-ID: On Wed, 29 Dec 2004, Richard HOLLAND wrote: > 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) Unfortunately BioError is not an exception, it is an Error. I believe you can catch them with try { // ... } catch (Throwable t) { // ... } but you probably shouldn't be. From the BioError javadoc: For developers: Throw this when something has gone wrong and in general people should not be handling it. > 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) This is the real problem: the parser doesn't know what to do with the character ''. I don't know exactly what that means, but does the string you pull out of the database clob look reasonable? michael > 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() > // 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. > --------------------------------------------- > > > _______________________________________________ > Biojava-l mailing list - Biojava-l@biojava.org > http://biojava.org/mailman/listinfo/biojava-l > From hollandr at gis.a-star.edu.sg Wed Dec 29 00:14:18 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Wed Dec 29 00:13:04 2004 Subject: [Biojava-l] Exception not being caught. Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D560140E707@BIONIC.biopolis.one-north.com> Hi, I resolved the exception by adding a trim() call to truncate whitespace from the ends of the sequence before passing it to DNATools. There were some weird trailing blank symbols, \0, \r, \n and the like. Fair enough that it threw a wobbly when it encountered these. However, I am sure there are situations where you would want to safely know whether a sequence contained invalid characters (eg. if accepting free-text sequence information via a web interface). In this case, you would want to catch the exception in the usual manner. Should this particular BioError not be a plain normal BioException that people could catch easily? cheers, Richard 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. --------------------------------------------- > -----Original Message----- > From: Michael Heuer [mailto:heuermh@shell3.shore.net] On > Behalf Of Michael Heuer > Sent: Wednesday, December 29, 2004 12:25 PM > To: Richard HOLLAND > Cc: biojava-l@biojava.org > Subject: Re: [Biojava-l] Exception not being caught. > > > > On Wed, 29 Dec 2004, Richard HOLLAND wrote: > > > 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) > > Unfortunately BioError is not an exception, it is an Error. > > I believe you can catch them with > > try > { > // ... > } > catch (Throwable t) > { > // ... > } > > but you probably shouldn't be. From the BioError javadoc: > > For developers: > Throw this when something has gone wrong and in general people should > not be handling it. > > > > > 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(Ch > aracterTok > > enization.java:175) > > This is the real problem: the parser doesn't know what to do with the > character ''. I don't know exactly what that means, but does > the string > you pull out of the database clob look reasonable? > > michael > > > > 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() > > > // 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. > > --------------------------------------------- > > > > > > _______________________________________________ > > Biojava-l mailing list - Biojava-l@biojava.org > > http://biojava.org/mailman/listinfo/biojava-l > > > > From felipe.albrecht at gmail.com Wed Dec 29 01:06:11 2004 From: felipe.albrecht at gmail.com (Felipe Albrecht) Date: Wed Dec 29 01:03:06 2004 Subject: [Biojava-l] CVS Message-ID: Hello, I'm a computer science student and I intent study biomolecular with bioinformatic. I have a good skills with java platform and I love to code and study biomolecular. I want work with biojava, and for while, for understand better the biojava, I thing to help biojava's upgrade, from java 1.4 to 1.5. For this, I need know what are the cvs project directory, the repository is " :pserver:cvs@cvs.open-bio.org:/home/repository/biojava" ? So, what are the project that contains the most actual (and instable) code? Thanks, Felipe Albrecht From hollandr at gis.a-star.edu.sg Wed Dec 29 22:54:28 2004 From: hollandr at gis.a-star.edu.sg (Richard HOLLAND) Date: Wed Dec 29 22:52:07 2004 Subject: [Biojava-l] Blast SAX parser output Message-ID: <6D9E9B9DF347EF4385F6271C64FB8D560140E77F@BIONIC.biopolis.one-north.com> Is there any way to stop the blast parser code from outputting progress? I get lots of the following and its clogging up my unix mailbox as the job is run through cron: obj=score 317 obj=expectValue 7e-86 obj=numberOfIdentities 158 obj=alignmentSize 160 obj=percentageIdentity 98 obj=numberOfPositives 159 obj=numberOfPositives 159 obj=queryFrame plus2 obj=querySequenceStart 29 obj=querySequenceEnd 508 obj=querySequence DKHWMPVTKLGRLVKDMKIKSLEEIYLFSLPIKESEIIDFFLGASLKD EVLKIMPVQKQTRAGQRTRFKAFVAIGDYNGHVGLGVKCSKEVATAIRGAIILAKLSIVPVRRGYWGNKIGKPHTVPCKV TGRCGSVLVRLIPAPRGTGIVSAPVPKKLLMM obj=subjectSequenceStart 31 obj=subjectSequenceEnd 190 obj=subjectSequence DKEWIPVTKLGRLVKDMKIKSLEEIYLFSLPIKESEIIDFFLGASLKD EVLKIMPVQKQTRAGQRTRFKAFVAIGDYNGHVGLGVKCSKEVATAIRGAIILAKLSIVPVRRGYWGNKIGKPHTVPCKV TGRCGSVLVRLIPAPRGTGIVSAPVPKKLLMM .... The code producing this is: File parsedBlast = safe.tempfile(); SearchContentHandler handler = new BlastHitSummaryWriter(new BufferedWriter(new FileWriter(parsedBlast))); SeqSimilarityAdapter adapter = new SeqSimilarityAdapter(); adapter.setSearchContentHandler(handler); BlastLikeSAXParser breader = new BlastLikeSAXParser(); breader.setModeLazy(); InputSource is = new InputSource(new FileReader(blast)); breader.setContentHandler(adapter); breader.parse(is); cheers, Richard 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. ---------------------------------------------