[Biojava-l] Ontology and BioSQL

mark.schreiber at group.novartis.com mark.schreiber at group.novartis.com
Thu Dec 2 03:18:24 EST 2004


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" <hollandr at gis.a-star.edu.sg>
Sent by: biojava-l-bounces at portal.open-bio.org
12/02/2004 02:16 PM

 
        To:     <biojava-l at biojava.org>
        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 at 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 at biojava.org
http://biojava.org/mailman/listinfo/biojava-l





More information about the Biojava-l mailing list