[Biojava-dev] BioSQLRichSequenceDB and BioSQLBioEntryDB
mark.schreiber at novartis.com
mark.schreiber at novartis.com
Mon Jan 23 22:17:19 EST 2006
Very cool use of reflection in there!
I don't see how commits and rollbacks are handled though??
- Mark
"Richard HOLLAND" <hollandr at gis.a-star.edu.sg>
Sent by: biojava-dev-bounces at portal.open-bio.org
01/24/2006 10:51 AM
To: <biojava-dev at biojava.org>
cc: Mark Schreiber/GP/Novartis at PH
Subject: [Biojava-dev] BioSQLRichSequenceDB and BioSQLBioEntryDB
We've added two new modules to BioJavaX that allow you to wrap a
BioSQL/Hibernate database in a SequenceDB compatible wrapper. More for
convenience sake than anything else (its not foolproof) but it might be
useful.
They are:
org.biojavax.bio.db.biosql.BioSQLBioEntryDB
org.biojavax.bio.db.biosql.BioSQLRichSequenceDB
The code depends on you having unique values in the 'name' column of the
BioEntry table in your BioSQL database. You'll get 'IllegalIDExceptions'
thrown all over the place if this does not hold true. If this is the case,
you should use Hibernate directly rather than this convenience wrapper
code.
To use it, make sure Hibernate is on your classpath. Then you can do
things like this:
Session session = ...; // get a Hibernate session from
somewhere
RichObjectFactory.connectToHibernate(session); // bind
BioJavaX to the hibernate session
RichSequenceDB db = new BioSQLRichSequenceDB(session); //
connect the hibernate session to our SequenceDB
System.out.println(db.ids()); // prints out a list of all
the values in the 'name' column of the BioEntry table in the database
for (Iterator i = db.getRichSequences("bloggs");
i.hasNext(); ) { // retrieve all sequences where the name is 'bloggs'
RichSequence seq = (RichSequence)i.next(); // get the
next one
... // do something with it here
}
To add sequences to your database:
RichSequence seq = ...; // get a RichSequence from
somewhere
db.addRichSequence(seq);
To remove them again:
db.removeRichSequence("bloggs"); // removes the sequence
with the name 'bloggs'
The BioSQLBioEntryDB works in exactly the same way but returns only
BioEntry objects - ie. sequences without the sequence data attached. This
might help with performance in some cases.
Finally, we also added a GenbankRichSequenceDB object that behaves much
like the old GenbankSequenceDB object but returns RichSequence objects
instead.
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-dev mailing list
biojava-dev at biojava.org
http://biojava.org/mailman/listinfo/biojava-dev
More information about the biojava-dev
mailing list