From darin.london at duke.edu Mon May 5 10:08:19 2008 From: darin.london at duke.edu (darin.london at duke.edu) Date: Mon, 5 May 2008 10:08:19 -0400 Subject: [BioSQL-l] BOSC 2008 Announcement and Call For Submissions Message-ID: <200805051408.m45E8JIl023449@tenero.duhs.duke.edu> BOSC 2008 Call for Abstracts Reminder The 9th annual Bioinformatics Open Source Conference (BOSC 2008) will take place in Toronto, Ontario, Canada, as one of several Special Interest Group (SIG) meetings occurring in conjunction with the 16th annual Intelligent Systems for Molecular Biology Conference (ISMB 2008). This is the final reminder to submit your proposals for talks to the BOSC submission system before May 11. Submission Process: All abstracts must be submitted through our Open Conference Systems site (http://events.open-bio.org/BOSC2008/openconf.php). The form will ask for a small Abstract Text to be pasted into it, and a full paper. The small Abstract text should be a summary, while the longer abstract (should provide more details, including the open-source license requirement details) Full-length abstracts are limited to one page with one inch (2.5 cm) margins on the top, sides, and bottom. The full-length abstract should include the title, authors, and affiliations. We prefer your abstract to be in PDF format, although plain t Important Dates: May 11: Abstract submission deadline. June 2: Notification of accepted talks. June 4: Early registration discount cut-off. July 18-19: BOSC 2008! We hope to see you at BOSC 2008! Kam Dahlquist and Darin London BOSC 2008 Co-organizers From biopython at maubp.freeserve.co.uk Wed May 7 06:04:34 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Wed, 7 May 2008 11:04:34 +0100 Subject: [BioSQL-l] MySQL schema, CREATE TABLE and TYPE verus ENGINE Message-ID: <320fb6e00805070304g21c681dbkbaf7411a5c9985c6@mail.gmail.com> Hello all, I've just been running the Biopython BioSQL unit tests on a "new" Linux machine with MySQL 5.0, $ mysql --version mysql Ver 14.12 Distrib 5.0.27, for redhat-linux-gnu (i686) using readline 5.0 Part of the unit test creats a new empty database and loads the schema file biosqldb-mysql.sql into it. This triggers a warning: Warning: 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead My guess is the commands "CREATE TABLE ... TYPE=INNODB;" be updated to "CREATE TABLE ... ENGINE=INNODB;" in biosqldb-mysql.sql to get rid of the warning. According to the following documents, MySQL 4.1 and 5.0 will accept either TYPE or ENGINE, but it looks like MySQL 6.0 insists on using ENGINE. http://dev.mysql.com/doc/refman/4.1/en/create-table.html http://dev.mysql.com/doc/refman/5.0/en/create-table.html http://dev.mysql.com/doc/refman/6.0/en/create-table.html Is this something which should be fixed in BioSQL? Thanks Peter From hlapp at gmx.net Thu May 8 00:22:03 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Wed, 7 May 2008 22:22:03 -0600 Subject: [BioSQL-l] MySQL schema, CREATE TABLE and TYPE verus ENGINE In-Reply-To: <320fb6e00805070304g21c681dbkbaf7411a5c9985c6@mail.gmail.com> References: <320fb6e00805070304g21c681dbkbaf7411a5c9985c6@mail.gmail.com> Message-ID: <3F9E5C22-1FFD-4C80-A4B5-F6CAF7DA05B5@gmx.net> On May 7, 2008, at 4:04 AM, Peter wrote: > According to the following documents, MySQL 4.1 and 5.0 will accept > either TYPE or ENGINE, but it looks like MySQL 6.0 insists on using > ENGINE. > > http://dev.mysql.com/doc/refman/4.1/en/create-table.html > http://dev.mysql.com/doc/refman/5.0/en/create-table.html > http://dev.mysql.com/doc/refman/6.0/en/create-table.html > > Is this something which should be fixed in BioSQL? Sounds like this would not break compatibility for >= 4.1, but would for at least for 3.x. (Not sure about 4.0.x here.) Is anyone still using MySQL with a version < 4.0? -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Thu May 8 00:45:38 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Wed, 7 May 2008 22:45:38 -0600 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL In-Reply-To: <4821C37D.7050105@uni-tuebingen.de> References: <4821C37D.7050105@uni-tuebingen.de> Message-ID: This is odd - it would mean that you don't have the obo.pm parser, or that it can't be loaded. Maybe there is some kind of version mix going on here? Could you check that you have the file Bio/OntologyIO/obo.pm in the directory where you've installed BioPerl? If yes, can you do $ perl -MBio::OntologyIO::obo and let me know what happens? -hilmar On May 7, 2008, at 8:58 AM, Andreas Dr?ger wrote: > Dear all, > > Unfortunately, I am still having trouble while loading the Gene > Ontology into my BioSQL database. I installed BioSQL, downloaded > the file gene_ontology_edit.obo from the Gene Ontology homepage > (http://www.geneontology.org/GO.downloads.ontology.shtml), > installed the BioPerl package bioperl-db-1.5.2_100 as described in > the INSTALL file and tried the following: > > ./scripts/biosql/load_ontology.pl \ > --host localhost --dbname biosql \ > --dbuser myUser \ > --dbpass 'myPassword' \ > --driver mysql \ > --namespace "Gene Ontology" \ > --format obo \ > gene_ontology_edit.obo > > I received the following error message: > > Bio::OntologyIO: obo cannot be found > Exception > ------------- EXCEPTION ------------- > MSG: Failed to load module Bio::OntologyIO::obo. Can't locate Bio/ > OntologyIO/obo.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/ > 5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386- > linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread- > multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/ > lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/ > perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/ > site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi / > usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/ > perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/ > vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/ > vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/ > vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/ > vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/ > perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm > line 394. > > STACK Bio::Root::Root::_load_module /usr/lib/perl5/site_perl/5.8.8/ > Bio/Root/Root.pm:396 > STACK (eval) /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:255 > STACK Bio::OntologyIO::_load_format_module /usr/lib/perl5/site_perl/ > 5.8.8/Bio/OntologyIO.pm:254 > STACK Bio::OntologyIO::new /usr/lib/perl5/site_perl/5.8.8/Bio/ > OntologyIO.pm:165 > STACK toplevel ./scripts/biosql/load_ontology.pl:525 > > -------------------------------------- > > For more information about the OntologyIO system please see the docs. > This includes ways of checking for formats at compile time, not run > time > Can't call method "term_factory" on an undefined value at ./scripts/ > biosql/load_ontology.pl line 531. > [root at u-172-c052 bioperl-db-1.5.2_100]# vim scripts/biosql/ > load_ontology.pl > > > I am grateful for any hint what I can do to solve this problem and > to store the GO in my database. > > Cheers, > Andreas -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Thu May 8 16:24:01 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Thu, 8 May 2008 14:24:01 -0600 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL In-Reply-To: <4822BF3A.2020305@uni-tuebingen.de> References: <4821C37D.7050105@uni-tuebingen.de> <4822BF3A.2020305@uni-tuebingen.de> Message-ID: <5D34FC99-AAC1-4EF5-AD79-4F152D12A391@gmx.net> Hi Andreas - it seems that the GO download you have has two terms with name 'invasive growth', which are both obsoleted, but have different GO IDs. That's a somewhat nasty situation and happens occasionally (ask the GO people if you want to know more on why exactly that's necessary). If you're loading the ontology fresh into your database you can avoid all that by simply leaving all obsolete terms outside using the -- noobsolete switch. There are other options for handling obsolete terms (see the script's POD) that should allow you to stay out of that trouble for updates too. -hilmar On May 8, 2008, at 2:52 AM, Andreas Dr?ger wrote: > Dear all, > > Thank you for your advice! Now it works, but not completely. It > seems that there is either a problem with the ontology file I > downloaded from GO (gene_ontology_edit.obo) or an error in the script: > > ./scripts/biosql/load_ontology.pl --host localhost --dbname > bioseqdb --dbuser myUser --dbpass 'myPasswd' --driver mysql -- > namespace "Gene Ontology" --format obo gene_ontology_edit.obo > > > > And it works: > > > > Loading ontology gene_ontology: > ... terms > ... relationships > Done with gene_ontology. > Loading ontology biological_process: > ... terms > > > > But then I receive the following messages: > > > > -------------------- WARNING --------------------- > MSG: insert in Bio::DB::BioSQL::TermAdaptor (driver) failed, values > were ("GO:0007125","invasive growth","OBSOLETE (was not defined > before being made obsolete).","X","") FKs (46) > Duplicate entry 'invasive growth-46-X' for key 3 > --------------------------------------------------- > Could not store term GO:0007125, name 'invasive growth': > > ------------- EXCEPTION: Bio::Root::Exception ------------- > MSG: create: object (Bio::Ontology::OBOterm) failed to insert or to > be found by unique key > STACK: Error::throw > STACK: Bio::Root::Root::throw /usr/lib/perl5/site_perl/5.8.8/Bio/ > Root/Root.pm:359 > STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::create /usr/lib/ > perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:206 > STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::store /usr/lib/ > perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:251 > STACK: Bio::DB::Persistent::PersistentObject::store /usr/lib/perl5/ > site_perl/5.8.8/Bio/DB/Persistent/PersistentObject.pm:271 > STACK: main::persist_term ./scripts/biosql/load_ontology.pl:802 > STACK: ./scripts/biosql/load_ontology.pl:607 > ----------------------------------------------------------- > > at ./scripts/biosql/load_ontology.pl line 814 > main::persist_term('-term', 'Bio::Ontology::OBOterm=HASH > (0xa1b502c)', '-db', 'Bio::DB::BioSQL::DBAdaptor=HASH(0x8ba793c)', > '-termfactory', 'undef', '-throw', 'CODE(0x87406d8)', '- > mergeobs', ...) called at ./scripts/biosql/load_ontology.pl line 607 -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From andreas.draeger at uni-tuebingen.de Wed May 7 09:29:18 2008 From: andreas.draeger at uni-tuebingen.de (=?ISO-8859-1?Q?Andreas_Dr=E4ger?=) Date: Wed, 07 May 2008 15:29:18 +0200 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL Message-ID: <4821AEAE.5010205@uni-tuebingen.de> Dear all, Unfortunately, I am still having trouble while loading the Gene Ontology into my BioSQL database. I installed BioSQL, downloaded the file gene_ontology_edit.obo from the Gene Ontology homepage (http://www.geneontology.org/GO.downloads.ontology.shtml), installed the BioPerl package bioperl-db-1.5.2_100 as described in the INSTALL file and tried the following: ./scripts/biosql/load_ontology.pl \ --host localhost --dbname biosql \ --dbuser myUser \ --dbpass 'myPassword' \ --driver mysql \ --namespace "Gene Ontology" \ --format obo \ gene_ontology_edit.obo I received the following error message: Bio::OntologyIO: obo cannot be found Exception ------------- EXCEPTION ------------- MSG: Failed to load module Bio::OntologyIO::obo. Can't locate Bio/OntologyIO/obo.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm line 394. STACK Bio::Root::Root::_load_module /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm:396 STACK (eval) /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:255 STACK Bio::OntologyIO::_load_format_module /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:254 STACK Bio::OntologyIO::new /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:165 STACK toplevel ./scripts/biosql/load_ontology.pl:525 -------------------------------------- For more information about the OntologyIO system please see the docs. This includes ways of checking for formats at compile time, not run time Can't call method "term_factory" on an undefined value at ./scripts/biosql/load_ontology.pl line 531. [root at u-172-c052 bioperl-db-1.5.2_100]# vim scripts/biosql/load_ontology.pl I am grateful for any hint what I can do to solve this problem and to store the GO in my database. Cheers, Andreas From andreas.draeger at uni-tuebingen.de Wed May 7 10:58:05 2008 From: andreas.draeger at uni-tuebingen.de (=?ISO-8859-1?Q?Andreas_Dr=E4ger?=) Date: Wed, 07 May 2008 16:58:05 +0200 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL Message-ID: <4821C37D.7050105@uni-tuebingen.de> Dear all, Unfortunately, I am still having trouble while loading the Gene Ontology into my BioSQL database. I installed BioSQL, downloaded the file gene_ontology_edit.obo from the Gene Ontology homepage (http://www.geneontology.org/GO.downloads.ontology.shtml), installed the BioPerl package bioperl-db-1.5.2_100 as described in the INSTALL file and tried the following: ./scripts/biosql/load_ontology.pl \ --host localhost --dbname biosql \ --dbuser myUser \ --dbpass 'myPassword' \ --driver mysql \ --namespace "Gene Ontology" \ --format obo \ gene_ontology_edit.obo I received the following error message: Bio::OntologyIO: obo cannot be found Exception ------------- EXCEPTION ------------- MSG: Failed to load module Bio::OntologyIO::obo. Can't locate Bio/OntologyIO/obo.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm line 394. STACK Bio::Root::Root::_load_module /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm:396 STACK (eval) /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:255 STACK Bio::OntologyIO::_load_format_module /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:254 STACK Bio::OntologyIO::new /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:165 STACK toplevel ./scripts/biosql/load_ontology.pl:525 -------------------------------------- For more information about the OntologyIO system please see the docs. This includes ways of checking for formats at compile time, not run time Can't call method "term_factory" on an undefined value at ./scripts/biosql/load_ontology.pl line 531. [root at u-172-c052 bioperl-db-1.5.2_100]# vim scripts/biosql/load_ontology.pl I am grateful for any hint what I can do to solve this problem and to store the GO in my database. Cheers, Andreas From andreas.draeger at uni-tuebingen.de Thu May 8 04:52:10 2008 From: andreas.draeger at uni-tuebingen.de (=?ISO-8859-1?Q?Andreas_Dr=E4ger?=) Date: Thu, 08 May 2008 10:52:10 +0200 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL In-Reply-To: References: <4821C37D.7050105@uni-tuebingen.de> Message-ID: <4822BF3A.2020305@uni-tuebingen.de> Dear all, Thank you for your advice! Now it works, but not completely. It seems that there is either a problem with the ontology file I downloaded from GO (gene_ontology_edit.obo) or an error in the script: ./scripts/biosql/load_ontology.pl --host localhost --dbname bioseqdb --dbuser myUser --dbpass 'myPasswd' --driver mysql --namespace "Gene Ontology" --format obo gene_ontology_edit.obo And it works: Loading ontology gene_ontology: ... terms ... relationships Done with gene_ontology. Loading ontology biological_process: ... terms But then I receive the following messages: -------------------- WARNING --------------------- MSG: insert in Bio::DB::BioSQL::TermAdaptor (driver) failed, values were ("GO:0007125","invasive growth","OBSOLETE (was not defined before being made obsolete).","X","") FKs (46) Duplicate entry 'invasive growth-46-X' for key 3 --------------------------------------------------- Could not store term GO:0007125, name 'invasive growth': ------------- EXCEPTION: Bio::Root::Exception ------------- MSG: create: object (Bio::Ontology::OBOterm) failed to insert or to be found by unique key STACK: Error::throw STACK: Bio::Root::Root::throw /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm:359 STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::create /usr/lib/perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:206 STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::store /usr/lib/perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:251 STACK: Bio::DB::Persistent::PersistentObject::store /usr/lib/perl5/site_perl/5.8.8/Bio/DB/Persistent/PersistentObject.pm:271 STACK: main::persist_term ./scripts/biosql/load_ontology.pl:802 STACK: ./scripts/biosql/load_ontology.pl:607 ----------------------------------------------------------- at ./scripts/biosql/load_ontology.pl line 814 main::persist_term('-term', 'Bio::Ontology::OBOterm=HASH(0xa1b502c)', '-db', 'Bio::DB::BioSQL::DBAdaptor=HASH(0x8ba793c)', '-termfactory', 'undef', '-throw', 'CODE(0x87406d8)', '-mergeobs', ...) called at ./scripts/biosql/load_ontology.pl line 607 From gwu at molbio.mgh.harvard.edu Tue May 20 14:03:35 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Tue, 20 May 2008 14:03:35 -0400 Subject: [BioSQL-l] Load/Update Genbank sequence issue Message-ID: <48331277.7060105@molbio.mgh.harvard.edu> Hi all, I'm trying to load Genbank sequence into BioSQL database with BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the exception when loading new sequences or reloading the same sequence. Seems the Hibernate is trying to insert "genbank" namespace again. Can anybody tell me what I did wrong? Thanks in advance. Gang ================================================================ public class SequenceLoaderNew { public void loadSeq(String fileName, String namespace) throws FileNotFoundException, BioException { System.out.println("Start loading file " + fileName + " at " + System.currentTimeMillis()); BufferedReader br = new BufferedReader(new FileReader(fileName)); Session session = new Configuration().configure().buildSessionFactory().openSession(); RichObjectFactory.connectToBioSQL(session); RichSequenceDB db = new BioSQLRichSequenceDB(session); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new SimpleNamespace(namespace)); while (rsi.hasNext()) { Transaction tx = session.beginTransaction(); RichSequence sequence = rsi.nextRichSequence(); System.out.println("Loaded sequence" + sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); try { System.out.println("Delete sequence" + sequence.getAccession() + " if exists."); db.removeSequence(sequence.getAccession()); } catch (Exception ex) { } try { System.out.println("Save sequence " + sequence.getAccession()); session.save("BioEntry", sequence); tx.commit(); session.flush(); session.clear(); } catch (HibernateException ex) { tx.rollback(); ex.printStackTrace(); } } } public static void main(String[] args) throws BioException, FileNotFoundException { SequenceLoaderNew sl = new SequenceLoaderNew(); //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); } } ================================================================ org.hibernate.exception.ConstraintViolationException: could not insert: [Namespace] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry 'genbank' for key 'name' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) ... 31 more ================================================================ From gwu at molbio.mgh.harvard.edu Tue May 20 14:37:18 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Tue, 20 May 2008 14:37:18 -0400 Subject: [BioSQL-l] Load, Update Genbank sequence issue Message-ID: <48331A5E.9020908@molbio.mgh.harvard.edu> Hi all, I'm trying to load Genbank sequence into BioSQL database with BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the exception when loading new sequences or reloading the same sequence. Seems the Hibernate is trying to insert "genbank" namespace again. Can anybody tell me what I did wrong? Thanks in advance. Gang ================================================================ public class SequenceLoaderNew { public void loadSeq(String fileName, String namespace) throws FileNotFoundException, BioException { System.out.println("Start loading file " + fileName + " at " + System.currentTimeMillis()); BufferedReader br = new BufferedReader(new FileReader(fileName)); Session session = new Configuration().configure().buildSessionFactory().openSession(); RichObjectFactory.connectToBioSQL(session); RichSequenceDB db = new BioSQLRichSequenceDB(session); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new SimpleNamespace(namespace)); while (rsi.hasNext()) { Transaction tx = session.beginTransaction(); RichSequence sequence = rsi.nextRichSequence(); System.out.println("Loaded sequence" + sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); try { System.out.println("Delete sequence" + sequence.getAccession() + " if exists."); db.removeSequence(sequence.getAccession()); } catch (Exception ex) { } try { System.out.println("Save sequence " + sequence.getAccession()); session.save("BioEntry", sequence); tx.commit(); session.flush(); session.clear(); } catch (HibernateException ex) { tx.rollback(); ex.printStackTrace(); } } } public static void main(String[] args) throws BioException, FileNotFoundException { SequenceLoaderNew sl = new SequenceLoaderNew(); //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); } } ================================================================ org.hibernate.exception.ConstraintViolationException: could not insert: [Namespace] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry 'genbank' for key 'name' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) ... 31 more ================================================================ From dicknetherlands at gmail.com Tue May 20 14:44:09 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Tue, 20 May 2008 19:44:09 +0100 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> Message-ID: Forgot to copy my reply back to the lists! ---------- Forwarded message ---------- From: Richard Holland Date: 2008/5/20 Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue To: gang wu You need to substitute this line: RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new SimpleNamespace(namespace)); with this line: Namespace ns = (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new Object[]{namespace}); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); cheers, Richard PS. You're the second person who has quoted this section of code on this list recently, and had the same problem with it. If you got it from a website somewhere, could you send me the URL so I can get in touch with the authors and get them to correct it? Thanks! 2008/5/20 gang wu : > Hi all, > > I'm trying to load Genbank sequence into BioSQL database with > BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the > exception when loading new sequences or reloading the same sequence. Seems > the Hibernate is trying to insert "genbank" namespace again. Can anybody > tell me what I did wrong? Thanks in advance. > > Gang > > ================================================================ > public class SequenceLoaderNew { > public void loadSeq(String fileName, String namespace) throws > FileNotFoundException, BioException { > System.out.println("Start loading file " + fileName + " at " + > System.currentTimeMillis()); > BufferedReader br = new BufferedReader(new FileReader(fileName)); > Session session = new > Configuration().configure().buildSessionFactory().openSession(); > RichObjectFactory.connectToBioSQL(session); > RichSequenceDB db = new BioSQLRichSequenceDB(session); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new > SimpleNamespace(namespace)); > while (rsi.hasNext()) { > Transaction tx = session.beginTransaction(); > RichSequence sequence = rsi.nextRichSequence(); > System.out.println("Loaded sequence" + sequence.getAccession() + > ", identifier: " + sequence.getIdentifier()); > try { > System.out.println("Delete sequence" + sequence.getAccession() > + " if exists."); > db.removeSequence(sequence.getAccession()); > } catch (Exception ex) { > } > try { > System.out.println("Save sequence " + > sequence.getAccession()); > session.save("BioEntry", sequence); > tx.commit(); > session.flush(); > session.clear(); > } catch (HibernateException ex) { > tx.rollback(); > ex.printStackTrace(); > } > } > } > > public static void main(String[] args) throws BioException, > FileNotFoundException { > SequenceLoaderNew sl = new SequenceLoaderNew(); > //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); > sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); > } > } > ================================================================ > org.hibernate.exception.ConstraintViolationException: could not insert: > [Namespace] > at > org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) > at > org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) > at > org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) > at > org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) > at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) > at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) > at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) > at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) > Caused by: > com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: > Duplicate entry 'genbank' for key 'name' > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) > at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) > at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) > at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) > at > com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) > at > com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) > at > com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) > at > com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) > at > org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) > at > org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) > ... 31 more > ================================================================ > > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From gwu at molbio.mgh.harvard.edu Wed May 21 02:28:16 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Wed, 21 May 2008 02:28:16 -0400 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> Message-ID: <4833C100.7040304@molbio.mgh.harvard.edu> I got another problem with almost the same code(see attached code and output). If I call the loadSeq() only once, everything works fine. The second call of the same method will fail. By the exception message, it looks like the session is not cleaned up yet though at the end of the method the session has been flush/clear/closed. Anything wrong? Or does anyone have a sequence data loader would like to share? I'm quite frustrated after keeping trying to do this seems simple thing without success. If I can make it work, I'd like to post it on the mailing list. Thanks in advance. Gang ==================================================== public class SequenceLoaderNew { public void loadSeq(String fileName, String namespace) throws FileNotFoundException, BioException, SQLException, InterruptedException { SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session = sessionFactory.openSession(); RichObjectFactory.connectToBioSQL(session); Namespace ns = (Namespace) RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); RichSequenceDB db = new BioSQLRichSequenceDB(session); System.out.println("Start loading file " + fileName + " at " + System.currentTimeMillis()); BufferedReader br = new BufferedReader(new FileReader(fileName)); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); try { while (rsi.hasNext()) { RichSequence sequence = rsi.nextRichSequence(); System.out.println("Loaded sequence" + sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); Transaction tx = session.beginTransaction(); try { System.out.println("Delete sequence" + sequence.getAccession() + " if exists."); db.removeSequence(sequence.getAccession()); tx.commit(); session.flush(); session.clear(); } catch (Exception ex) { if (tx != null) { tx.rollback(); } } try { tx = session.beginTransaction(); System.out.println("Save sequence " + sequence.getAccession()); //session.save("BioEntry", sequence); //db.addSequence(sequence); db.addRichSequence(sequence); tx.commit(); System.out.println("Finished savig sequence " + sequence.getAccession() + "\n"); } catch (HibernateException ex) { tx.rollback(); ex.printStackTrace(); } } } finally { session.flush(); session.clear(); session.close(); } } public static void main(String[] args) throws BioException, FileNotFoundException, InterruptedException, SQLException { SequenceLoaderNew sl = new SequenceLoaderNew(); sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); } } ==================================================== Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 Loaded sequenceNC_005813, identifier: 45478502 Delete sequenceNC_005813 if exists. Save sequence NC_005813 Finished savig sequence NC_005813 Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 Loaded sequenceNC_005813, identifier: 45478502 Delete sequenceNC_005813 if exists. Save sequence NC_005813 org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Term#20] at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) Exception in thread "main" org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Term#19] at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) ==================================================== Richard Holland wrote: > Forgot to copy my reply back to the lists! > > > ---------- Forwarded message ---------- > From: Richard Holland > Date: 2008/5/20 > Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue > To: gang wu > > > You need to substitute this line: > > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new > SimpleNamespace(namespace)); > > with this line: > > Namespace ns = (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new > Object[]{namespace}); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); > > cheers, > Richard > > PS. You're the second person who has quoted this section of code on > this list recently, and had the same problem with it. If you got it > from a website somewhere, could you send me the URL so I can get in > touch with the authors and get them to correct it? Thanks! > > 2008/5/20 gang wu : > >> Hi all, >> >> I'm trying to load Genbank sequence into BioSQL database with >> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >> exception when loading new sequences or reloading the same sequence. Seems >> the Hibernate is trying to insert "genbank" namespace again. Can anybody >> tell me what I did wrong? Thanks in advance. >> >> Gang >> >> ================================================================ >> public class SequenceLoaderNew { >> public void loadSeq(String fileName, String namespace) throws >> FileNotFoundException, BioException { >> System.out.println("Start loading file " + fileName + " at " + >> System.currentTimeMillis()); >> BufferedReader br = new BufferedReader(new FileReader(fileName)); >> Session session = new >> Configuration().configure().buildSessionFactory().openSession(); >> RichObjectFactory.connectToBioSQL(session); >> RichSequenceDB db = new BioSQLRichSequenceDB(session); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >> SimpleNamespace(namespace)); >> while (rsi.hasNext()) { >> Transaction tx = session.beginTransaction(); >> RichSequence sequence = rsi.nextRichSequence(); >> System.out.println("Loaded sequence" + sequence.getAccession() + >> ", identifier: " + sequence.getIdentifier()); >> try { >> System.out.println("Delete sequence" + sequence.getAccession() >> + " if exists."); >> db.removeSequence(sequence.getAccession()); >> } catch (Exception ex) { >> } >> try { >> System.out.println("Save sequence " + >> sequence.getAccession()); >> session.save("BioEntry", sequence); >> tx.commit(); >> session.flush(); >> session.clear(); >> } catch (HibernateException ex) { >> tx.rollback(); >> ex.printStackTrace(); >> } >> } >> } >> >> public static void main(String[] args) throws BioException, >> FileNotFoundException { >> SequenceLoaderNew sl = new SequenceLoaderNew(); >> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >> } >> } >> ================================================================ >> org.hibernate.exception.ConstraintViolationException: could not insert: >> [Namespace] >> at >> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >> at >> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >> at >> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >> at >> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >> at >> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >> at >> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >> Caused by: >> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >> Duplicate entry 'genbank' for key 'name' >> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >> at >> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >> at >> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >> at >> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >> at >> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >> at >> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >> at >> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >> ... 31 more >> ================================================================ >> >> _______________________________________________ >> BioSQL-l mailing list >> BioSQL-l at lists.open-bio.org >> http://lists.open-bio.org/mailman/listinfo/biosql-l >> >> From dicknetherlands at gmail.com Wed May 21 13:17:39 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Wed, 21 May 2008 18:17:39 +0100 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: <4833C100.7040304@molbio.mgh.harvard.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: I'm not sure why you'd want to do that? Either way, as far as I know, Hibernate sessions are not designed for that. If you want to delete the sequence then replace it with a completely new sequence object, you have to create a new sequence object - you can't reuse the one you just deleted. The session info is embedded into that object so even if you clear the session, the object still refers to it. If you just want to load a sequence, modify it, then save it back, you should just load it then use saveOrUpdate to save it back again with changes. If you want to replace objects in your database, don't load them, just delete them, then use save to create new objects in their place. cheers, Richard 2008/5/21 gang wu : > I got another problem with almost the same code(see attached code and > output). If I call the loadSeq() only once, everything works fine. The > second call of the same method will fail. By the exception message, it looks > like the session is not cleaned up yet though at the end of the method the > session has been flush/clear/closed. Anything wrong? > > Or does anyone have a sequence data loader would like to share? I'm quite > frustrated after keeping trying to do this seems simple thing without > success. If I can make it work, I'd like to post it on the mailing list. > Thanks in advance. > > Gang > > ==================================================== > public class SequenceLoaderNew { > public void loadSeq(String fileName, String namespace) throws > FileNotFoundException, BioException, SQLException, InterruptedException { > SessionFactory sessionFactory = new > Configuration().configure().buildSessionFactory(); > Session session = sessionFactory.openSession(); > RichObjectFactory.connectToBioSQL(session); > Namespace ns = (Namespace) > RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); > RichSequenceDB db = new BioSQLRichSequenceDB(session); > System.out.println("Start loading file " + fileName + " at " + > System.currentTimeMillis()); > BufferedReader br = new BufferedReader(new FileReader(fileName)); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, > ns); > try { > while (rsi.hasNext()) { > RichSequence sequence = rsi.nextRichSequence(); > System.out.println("Loaded sequence" + sequence.getAccession() > + ", identifier: " + sequence.getIdentifier()); > Transaction tx = session.beginTransaction(); > try { > System.out.println("Delete sequence" + > sequence.getAccession() + " if exists."); > db.removeSequence(sequence.getAccession()); > tx.commit(); > session.flush(); > session.clear(); > } catch (Exception ex) { > if (tx != null) { > tx.rollback(); > } > } > try { > tx = session.beginTransaction(); > System.out.println("Save sequence " + > sequence.getAccession()); > //session.save("BioEntry", sequence); > //db.addSequence(sequence); > db.addRichSequence(sequence); > tx.commit(); > System.out.println("Finished savig sequence " + > sequence.getAccession() + "\n"); > } catch (HibernateException ex) { > tx.rollback(); > ex.printStackTrace(); > } > } > } finally { > session.flush(); > session.clear(); > session.close(); > } > } > > public static void main(String[] args) throws BioException, > FileNotFoundException, InterruptedException, SQLException { > SequenceLoaderNew sl = new SequenceLoaderNew(); > sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); > sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); > } > } > ==================================================== > Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 > Loaded sequenceNC_005813, identifier: 45478502 > Delete sequenceNC_005813 if exists. > Save sequence NC_005813 > Finished savig sequence NC_005813 > > Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 > Loaded sequenceNC_005813, identifier: 45478502 > Delete sequenceNC_005813 if exists. > Save sequence NC_005813 > org.hibernate.NonUniqueObjectException: a different object with the same > identifier value was already associated with the session: [Term#20] > at > org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at > org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) > at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) > at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) > at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) > at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) > Exception in thread "main" org.hibernate.NonUniqueObjectException: a > different object with the same identifier value was already associated with > the session: [Term#19] > at > org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at > org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) > at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) > at > org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) > at > org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) > at > org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) > at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) > at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) > at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) > ==================================================== > > Richard Holland wrote: >> >> Forgot to copy my reply back to the lists! >> >> >> ---------- Forwarded message ---------- >> From: Richard Holland >> Date: 2008/5/20 >> Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue >> To: gang wu >> >> >> You need to substitute this line: >> >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >> SimpleNamespace(namespace)); >> >> with this line: >> >> Namespace ns = >> (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new >> Object[]{namespace}); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); >> >> cheers, >> Richard >> >> PS. You're the second person who has quoted this section of code on >> this list recently, and had the same problem with it. If you got it >> from a website somewhere, could you send me the URL so I can get in >> touch with the authors and get them to correct it? Thanks! >> >> 2008/5/20 gang wu : >> >>> >>> Hi all, >>> >>> I'm trying to load Genbank sequence into BioSQL database with >>> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >>> exception when loading new sequences or reloading the same sequence. >>> Seems >>> the Hibernate is trying to insert "genbank" namespace again. Can anybody >>> tell me what I did wrong? Thanks in advance. >>> >>> Gang >>> >>> ================================================================ >>> public class SequenceLoaderNew { >>> public void loadSeq(String fileName, String namespace) throws >>> FileNotFoundException, BioException { >>> System.out.println("Start loading file " + fileName + " at " + >>> System.currentTimeMillis()); >>> BufferedReader br = new BufferedReader(new FileReader(fileName)); >>> Session session = new >>> Configuration().configure().buildSessionFactory().openSession(); >>> RichObjectFactory.connectToBioSQL(session); >>> RichSequenceDB db = new BioSQLRichSequenceDB(session); >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >>> new >>> SimpleNamespace(namespace)); >>> while (rsi.hasNext()) { >>> Transaction tx = session.beginTransaction(); >>> RichSequence sequence = rsi.nextRichSequence(); >>> System.out.println("Loaded sequence" + sequence.getAccession() + >>> ", identifier: " + sequence.getIdentifier()); >>> try { >>> System.out.println("Delete sequence" + >>> sequence.getAccession() >>> + " if exists."); >>> db.removeSequence(sequence.getAccession()); >>> } catch (Exception ex) { >>> } >>> try { >>> System.out.println("Save sequence " + >>> sequence.getAccession()); >>> session.save("BioEntry", sequence); >>> tx.commit(); >>> session.flush(); >>> session.clear(); >>> } catch (HibernateException ex) { >>> tx.rollback(); >>> ex.printStackTrace(); >>> } >>> } >>> } >>> >>> public static void main(String[] args) throws BioException, >>> FileNotFoundException { >>> SequenceLoaderNew sl = new SequenceLoaderNew(); >>> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >>> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >>> } >>> } >>> ================================================================ >>> org.hibernate.exception.ConstraintViolationException: could not insert: >>> [Namespace] >>> at >>> >>> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >>> at >>> >>> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >>> at >>> >>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >>> at >>> >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >>> at >>> >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >>> at >>> >>> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>> at >>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >>> at >>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>> at >>> >>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>> at >>> >>> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >>> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >>> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >>> Caused by: >>> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >>> Duplicate entry 'genbank' for key 'name' >>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >>> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >>> at >>> >>> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >>> at >>> >>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >>> ... 31 more >>> ================================================================ >>> >>> _______________________________________________ >>> BioSQL-l mailing list >>> BioSQL-l at lists.open-bio.org >>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>> >>> > > From gwu at molbio.mgh.harvard.edu Wed May 21 14:12:36 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Wed, 21 May 2008 14:12:36 -0400 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: <48346614.6060102@molbio.mgh.harvard.edu> The scenario is quite simple: I'm using the database to store Genbank genome sequences. Later I've to update the sequences when Genbank has newer releases. The following two lines are loading the same sequence twice. The first time will insert a new BioEntry record. the second time will delete the existing record and insert a new record again. sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); Following code is used to load multiple genome sequences by calling the loadSeq() method multiple times. All failed except the first time. sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_006723.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_008945.gbk", "genbank"); The exception message has the details. Since all variables used in loadSeq() are local, and I did the session flush/clear/close, then it should be ok to call the method again. Thank you very much for your help. Gang Richard Holland wrote: > I'm not sure why you'd want to do that? Either way, as far as I know, > Hibernate sessions are not designed for that. If you want to delete > the sequence then replace it with a completely new sequence object, > you have to create a new sequence object - you can't reuse the one you > just deleted. The session info is embedded into that object so even if > you clear the session, the object still refers to it. > > If you just want to load a sequence, modify it, then save it back, you > should just load it then use saveOrUpdate to save it back again with > changes. If you want to replace objects in your database, don't load > them, just delete them, then use save to create new objects in their > place. > > cheers, > Richard > > 2008/5/21 gang wu : > >> I got another problem with almost the same code(see attached code and >> output). If I call the loadSeq() only once, everything works fine. The >> second call of the same method will fail. By the exception message, it looks >> like the session is not cleaned up yet though at the end of the method the >> session has been flush/clear/closed. Anything wrong? >> >> Or does anyone have a sequence data loader would like to share? I'm quite >> frustrated after keeping trying to do this seems simple thing without >> success. If I can make it work, I'd like to post it on the mailing list. >> Thanks in advance. >> >> Gang >> >> ==================================================== >> public class SequenceLoaderNew { >> public void loadSeq(String fileName, String namespace) throws >> FileNotFoundException, BioException, SQLException, InterruptedException { >> SessionFactory sessionFactory = new >> Configuration().configure().buildSessionFactory(); >> Session session = sessionFactory.openSession(); >> RichObjectFactory.connectToBioSQL(session); >> Namespace ns = (Namespace) >> RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); >> RichSequenceDB db = new BioSQLRichSequenceDB(session); >> System.out.println("Start loading file " + fileName + " at " + >> System.currentTimeMillis()); >> BufferedReader br = new BufferedReader(new FileReader(fileName)); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >> ns); >> try { >> while (rsi.hasNext()) { >> RichSequence sequence = rsi.nextRichSequence(); >> System.out.println("Loaded sequence" + sequence.getAccession() >> + ", identifier: " + sequence.getIdentifier()); >> Transaction tx = session.beginTransaction(); >> try { >> System.out.println("Delete sequence" + >> sequence.getAccession() + " if exists."); >> db.removeSequence(sequence.getAccession()); >> tx.commit(); >> session.flush(); >> session.clear(); >> } catch (Exception ex) { >> if (tx != null) { >> tx.rollback(); >> } >> } >> try { >> tx = session.beginTransaction(); >> System.out.println("Save sequence " + >> sequence.getAccession()); >> //session.save("BioEntry", sequence); >> //db.addSequence(sequence); >> db.addRichSequence(sequence); >> tx.commit(); >> System.out.println("Finished savig sequence " + >> sequence.getAccession() + "\n"); >> } catch (HibernateException ex) { >> tx.rollback(); >> ex.printStackTrace(); >> } >> } >> } finally { >> session.flush(); >> session.clear(); >> session.close(); >> } >> } >> >> public static void main(String[] args) throws BioException, >> FileNotFoundException, InterruptedException, SQLException { >> SequenceLoaderNew sl = new SequenceLoaderNew(); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> } >> } >> ==================================================== >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> Finished savig sequence NC_005813 >> >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> org.hibernate.NonUniqueObjectException: a different object with the same >> identifier value was already associated with the session: [Term#20] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> Exception in thread "main" org.hibernate.NonUniqueObjectException: a >> different object with the same identifier value was already associated with >> the session: [Term#19] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) >> at >> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) >> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> ==================================================== >> >> Richard Holland wrote: >> >>> Forgot to copy my reply back to the lists! >>> >>> >>> ---------- Forwarded message ---------- >>> From: Richard Holland >>> Date: 2008/5/20 >>> Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue >>> To: gang wu >>> >>> >>> You need to substitute this line: >>> >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >>> SimpleNamespace(namespace)); >>> >>> with this line: >>> >>> Namespace ns = >>> (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new >>> Object[]{namespace}); >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); >>> >>> cheers, >>> Richard >>> >>> PS. You're the second person who has quoted this section of code on >>> this list recently, and had the same problem with it. If you got it >>> from a website somewhere, could you send me the URL so I can get in >>> touch with the authors and get them to correct it? Thanks! >>> >>> 2008/5/20 gang wu : >>> >>> >>>> Hi all, >>>> >>>> I'm trying to load Genbank sequence into BioSQL database with >>>> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >>>> exception when loading new sequences or reloading the same sequence. >>>> Seems >>>> the Hibernate is trying to insert "genbank" namespace again. Can anybody >>>> tell me what I did wrong? Thanks in advance. >>>> >>>> Gang >>>> >>>> ================================================================ >>>> public class SequenceLoaderNew { >>>> public void loadSeq(String fileName, String namespace) throws >>>> FileNotFoundException, BioException { >>>> System.out.println("Start loading file " + fileName + " at " + >>>> System.currentTimeMillis()); >>>> BufferedReader br = new BufferedReader(new FileReader(fileName)); >>>> Session session = new >>>> Configuration().configure().buildSessionFactory().openSession(); >>>> RichObjectFactory.connectToBioSQL(session); >>>> RichSequenceDB db = new BioSQLRichSequenceDB(session); >>>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >>>> new >>>> SimpleNamespace(namespace)); >>>> while (rsi.hasNext()) { >>>> Transaction tx = session.beginTransaction(); >>>> RichSequence sequence = rsi.nextRichSequence(); >>>> System.out.println("Loaded sequence" + sequence.getAccession() + >>>> ", identifier: " + sequence.getIdentifier()); >>>> try { >>>> System.out.println("Delete sequence" + >>>> sequence.getAccession() >>>> + " if exists."); >>>> db.removeSequence(sequence.getAccession()); >>>> } catch (Exception ex) { >>>> } >>>> try { >>>> System.out.println("Save sequence " + >>>> sequence.getAccession()); >>>> session.save("BioEntry", sequence); >>>> tx.commit(); >>>> session.flush(); >>>> session.clear(); >>>> } catch (HibernateException ex) { >>>> tx.rollback(); >>>> ex.printStackTrace(); >>>> } >>>> } >>>> } >>>> >>>> public static void main(String[] args) throws BioException, >>>> FileNotFoundException { >>>> SequenceLoaderNew sl = new SequenceLoaderNew(); >>>> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >>>> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >>>> } >>>> } >>>> ================================================================ >>>> org.hibernate.exception.ConstraintViolationException: could not insert: >>>> [Namespace] >>>> at >>>> >>>> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >>>> at >>>> >>>> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >>>> at >>>> >>>> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at >>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >>>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >>>> at >>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >>>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >>>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >>>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >>>> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >>>> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >>>> Caused by: >>>> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >>>> Duplicate entry 'genbank' for key 'name' >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >>>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >>>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >>>> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >>>> at >>>> >>>> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >>>> ... 31 more >>>> ================================================================ >>>> >>>> _______________________________________________ >>>> BioSQL-l mailing list >>>> BioSQL-l at lists.open-bio.org >>>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>>> >>>> >>>> >> From dicknetherlands at gmail.com Wed May 21 14:40:41 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Wed, 21 May 2008 19:40:41 +0100 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: Sorry, I misread the original question. My bad. What it actually seems that you're doing is simply iterating through a genbank file, deleting from the db that already exist, then replacing them with members from the file. Looking more closely it seems that it is complaining about duplicated Term objects, probably because the cache is getting confused with all this flushing and clearing. Have you tried running this code without flushing and clearing the session? If not, try also inserting If that didn't work, then after each call to flush(), insert a RichObjectFactory.clearLRUCache() call. That really will completely clear memory of all objects from the database. cheers, Richard 2008/5/21 Richard Holland : > I'm not sure why you'd want to do that? Either way, as far as I know, > Hibernate sessions are not designed for that. If you want to delete > the sequence then replace it with a completely new sequence object, > you have to create a new sequence object - you can't reuse the one you > just deleted. The session info is embedded into that object so even if > you clear the session, the object still refers to it. > > If you just want to load a sequence, modify it, then save it back, you > should just load it then use saveOrUpdate to save it back again with > changes. If you want to replace objects in your database, don't load > them, just delete them, then use save to create new objects in their > place. > > cheers, > Richard > > 2008/5/21 gang wu : >> I got another problem with almost the same code(see attached code and >> output). If I call the loadSeq() only once, everything works fine. The >> second call of the same method will fail. By the exception message, it looks >> like the session is not cleaned up yet though at the end of the method the >> session has been flush/clear/closed. Anything wrong? >> >> Or does anyone have a sequence data loader would like to share? I'm quite >> frustrated after keeping trying to do this seems simple thing without >> success. If I can make it work, I'd like to post it on the mailing list. >> Thanks in advance. >> >> Gang >> >> ==================================================== >> public class SequenceLoaderNew { >> public void loadSeq(String fileName, String namespace) throws >> FileNotFoundException, BioException, SQLException, InterruptedException { >> SessionFactory sessionFactory = new >> Configuration().configure().buildSessionFactory(); >> Session session = sessionFactory.openSession(); >> RichObjectFactory.connectToBioSQL(session); >> Namespace ns = (Namespace) >> RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); >> RichSequenceDB db = new BioSQLRichSequenceDB(session); >> System.out.println("Start loading file " + fileName + " at " + >> System.currentTimeMillis()); >> BufferedReader br = new BufferedReader(new FileReader(fileName)); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >> ns); >> try { >> while (rsi.hasNext()) { >> RichSequence sequence = rsi.nextRichSequence(); >> System.out.println("Loaded sequence" + sequence.getAccession() >> + ", identifier: " + sequence.getIdentifier()); >> Transaction tx = session.beginTransaction(); >> try { >> System.out.println("Delete sequence" + >> sequence.getAccession() + " if exists."); >> db.removeSequence(sequence.getAccession()); >> tx.commit(); >> session.flush(); >> session.clear(); >> } catch (Exception ex) { >> if (tx != null) { >> tx.rollback(); >> } >> } >> try { >> tx = session.beginTransaction(); >> System.out.println("Save sequence " + >> sequence.getAccession()); >> //session.save("BioEntry", sequence); >> //db.addSequence(sequence); >> db.addRichSequence(sequence); >> tx.commit(); >> System.out.println("Finished savig sequence " + >> sequence.getAccession() + "\n"); >> } catch (HibernateException ex) { >> tx.rollback(); >> ex.printStackTrace(); >> } >> } >> } finally { >> session.flush(); >> session.clear(); >> session.close(); >> } >> } >> >> public static void main(String[] args) throws BioException, >> FileNotFoundException, InterruptedException, SQLException { >> SequenceLoaderNew sl = new SequenceLoaderNew(); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> } >> } >> ==================================================== >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> Finished savig sequence NC_005813 >> >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> org.hibernate.NonUniqueObjectException: a different object with the same >> identifier value was already associated with the session: [Term#20] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> Exception in thread "main" org.hibernate.NonUniqueObjectException: a >> different object with the same identifier value was already associated with >> the session: [Term#19] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) >> at >> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) >> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> ==================================================== >> >> Richard Holland wrote: >>> >>> Forgot to copy my reply back to the lists! >>> >>> >>> ---------- Forwarded message ---------- >>> From: Richard Holland >>> Date: 2008/5/20 >>> Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue >>> To: gang wu >>> >>> >>> You need to substitute this line: >>> >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >>> SimpleNamespace(namespace)); >>> >>> with this line: >>> >>> Namespace ns = >>> (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new >>> Object[]{namespace}); >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); >>> >>> cheers, >>> Richard >>> >>> PS. You're the second person who has quoted this section of code on >>> this list recently, and had the same problem with it. If you got it >>> from a website somewhere, could you send me the URL so I can get in >>> touch with the authors and get them to correct it? Thanks! >>> >>> 2008/5/20 gang wu : >>> >>>> >>>> Hi all, >>>> >>>> I'm trying to load Genbank sequence into BioSQL database with >>>> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >>>> exception when loading new sequences or reloading the same sequence. >>>> Seems >>>> the Hibernate is trying to insert "genbank" namespace again. Can anybody >>>> tell me what I did wrong? Thanks in advance. >>>> >>>> Gang >>>> >>>> ================================================================ >>>> public class SequenceLoaderNew { >>>> public void loadSeq(String fileName, String namespace) throws >>>> FileNotFoundException, BioException { >>>> System.out.println("Start loading file " + fileName + " at " + >>>> System.currentTimeMillis()); >>>> BufferedReader br = new BufferedReader(new FileReader(fileName)); >>>> Session session = new >>>> Configuration().configure().buildSessionFactory().openSession(); >>>> RichObjectFactory.connectToBioSQL(session); >>>> RichSequenceDB db = new BioSQLRichSequenceDB(session); >>>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >>>> new >>>> SimpleNamespace(namespace)); >>>> while (rsi.hasNext()) { >>>> Transaction tx = session.beginTransaction(); >>>> RichSequence sequence = rsi.nextRichSequence(); >>>> System.out.println("Loaded sequence" + sequence.getAccession() + >>>> ", identifier: " + sequence.getIdentifier()); >>>> try { >>>> System.out.println("Delete sequence" + >>>> sequence.getAccession() >>>> + " if exists."); >>>> db.removeSequence(sequence.getAccession()); >>>> } catch (Exception ex) { >>>> } >>>> try { >>>> System.out.println("Save sequence " + >>>> sequence.getAccession()); >>>> session.save("BioEntry", sequence); >>>> tx.commit(); >>>> session.flush(); >>>> session.clear(); >>>> } catch (HibernateException ex) { >>>> tx.rollback(); >>>> ex.printStackTrace(); >>>> } >>>> } >>>> } >>>> >>>> public static void main(String[] args) throws BioException, >>>> FileNotFoundException { >>>> SequenceLoaderNew sl = new SequenceLoaderNew(); >>>> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >>>> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >>>> } >>>> } >>>> ================================================================ >>>> org.hibernate.exception.ConstraintViolationException: could not insert: >>>> [Namespace] >>>> at >>>> >>>> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >>>> at >>>> >>>> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >>>> at >>>> >>>> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at >>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >>>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >>>> at >>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >>>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >>>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >>>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >>>> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >>>> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >>>> Caused by: >>>> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >>>> Duplicate entry 'genbank' for key 'name' >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >>>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >>>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >>>> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >>>> at >>>> >>>> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >>>> ... 31 more >>>> ================================================================ >>>> >>>> _______________________________________________ >>>> BioSQL-l mailing list >>>> BioSQL-l at lists.open-bio.org >>>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>>> >>>> >> >> > From dicknetherlands at gmail.com Thu May 22 17:07:23 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Thu, 22 May 2008 22:07:23 +0100 Subject: [BioSQL-l] [Biojava-l] Load/Update Genbank sequence issue In-Reply-To: <4835DAAE.6080609@molbio.mgh.harvard.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> <48346EE1.70004@unity.ncsu.edu> <4835DAAE.6080609@molbio.mgh.harvard.edu> Message-ID: Interesting stuff. Have you tried parsing those Arabidopsis files without persisting them? i.e. just running them through the parser without attaching anything to Hibernate. I'm wondering how much of the slowness is Hibernate, and how much is BioJava's own object model. cheers, Richard 2008/5/22 gang wu : > Hi Doug and Richard, > > Thanks for your reply. I've been following your suggestions and finding a > way that works for me. Basically, if there is anything in the code that > flush/clear the session, it's going to be a problem for the following calls > to the same method. I'm not sure if it's Hibernate bug or is like Richard > suggested that it is a feature. Attached is the code I am using to > load/update Genbank sequences. It could be easily generalized to load other > sequences(if the process works). > > Seems it works for me now(still running test on bigger sequences). It's > pretty fast to load those small bacteria sequences, usually 10-60 seconds. > But it seems it's getting choked with the bigger sequences. I started it > last night at about 11pm to load the 5 Arabidopsis thaliana genome > sequences(about 280MB total). The first one finished in about 1.5 hours and > it's stilling hanging there now on the second sequence. I saw a 100% CPU > usage and 2.6GB memory assigned for the program. The MySQL server is running > on the same server. The machine has 8GB RAM and 2 dual core exon CPUS > running at 3.73GHZ. > > Doug, I tested your code and seems the output is not always consistent: I > tried to load two sequences. Sometimes succeeded and sometimes failed. I > wonder it's still the session issue. I did not try with removing those > flush/clear code. > > Thanks again for your response. It really helps me out. I'll post my code > here if I work out a better solution. > > Gang > > Doug Brown wrote: > > Hi Gang wu, > > I recognize your problem. I to had to build a loader for genbank flat > files. When attempting to 'replace' a record stored in the database, one > needs to explicitly delete it before doing the save. I found that the > hibernate code does not seem to understand that an in-memory deletion should > be realized in the data base prior to the new insertion. My solution, see > attached code, was to commit the transaction for the deletion and then open > a new transaction for the insertion. > > Try inserting the following after "System.out.println("Loaded sequence"": > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name = > :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > // Interestingly, hibernate does not seem to do transactions in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > > Regards, > Doug > > gang wu wrote: > > I got another problem with almost the same code(see attached code and > output). If I call the loadSeq() only once, everything works fine. The > second call of the same method will fail. By the exception message, it looks > like the session is not cleaned up yet though at the end of the method the > session has been flush/clear/closed. Anything wrong? > > ________________________________ > // Copyright 2008, by North Carolina State University. All rights reserved. > > /** > * > * javac -cp > "C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" > bioinformatics\biojava\BriefLoader.java > * > * java -Xmx100m -cp > "c:\jars\asm.jar;c:\jars\asm-attrs.jar;c:\jars\cglib-2.1.3.jar;c:\jars\jta.jar;c:\jars\antlr-2.7.6.jar;c:\jars\commons-collections-2.1.1.jar;c:\jars\commons-logging-1.0.4.jar;c:\jars\dom4j-1.6.1.jar;C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" > -Djdbc.drivers=com.mysql.jdbc.Driver bioinformatics.biojava.BriefLoader > C:\WorkData\genomes\M_grisea_genbank_v5\CH476760.gb > */ > package bioinformatics.biojavaTools; > > import java.io.BufferedReader; > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileReader; > import java.io.IOException; > > import org.biojava.bio.BioException; > import org.biojavax.*; > import org.biojavax.RichObjectFactory; > import org.biojavax.bio.db.biosql.BioSQLRichSequenceDB; > import org.biojavax.bio.seq.*; > import org.biojavax.bio.seq.RichSequence.*; > import org.biojavax.bio.seq.RichSequence.IOTools; > import org.biojavax.bio.seq.io.*; > import org.biojavax.bio.BioEntry; > > import org.hibernate.*; > import org.hibernate.cfg.*; > > //import java.util.logging.*; > //import org.apache.commons.logging.*; > > > > > public class BriefLoader > { > static SessionFactory sessionFactory; > static boolean verbose = false; > public static void main(String[] args) > { > int argPos = 0; > if ( args.length > 0 && args[argPos].equals( "-v")) > { > verbose = true; > argPos++; > } > if ( argPos == args.length) > { > System.out.println( "Usage: BriefLoader [-v] file1.bg [file2.gb > ...]"); > return; > } > > BriefLoader bf = new BriefLoader(); > > // logging: > // I want to suppress the verbose info messages. > // After some investigation, it seems that commons > // logging uses a default of Jdk14Logger (the standard java logger). > // Thus, I can control the commons logger via the java.util.logging API. > // API > java.util.logging.Logger jdklogger = > java.util.logging.Logger.getLogger("org.hibernate"); > jdklogger.setLevel(java.util.logging.Level.WARNING); > > sessionFactory = new > // Configuration is very expensive and can only be done once. > // > // properties can be specified via the file hibernate.properties located > // on the classpath, > // on the command line via -D, > // via the defaut "hibernate.cfg.xml" file in the current working > directory, > // via an explicitly identified file, e.g. "specific_file.cfg.xml", > // via explicit calls to setProperty. The same goes for resources. > // Later definitions override earlier ones. > Configuration() > // Note: > // specifying the resource location of the configuration file > // works ONLY if I also modify the > // hibernate.cfg.xml file to add the class' package as a prefix > // for every resource. Hibernate does not understand the > // concept of relative locations based on the location of the > // configuratin file. Nonetheless, this allows me to organize the > // mapping files based on java packages. > .configure( bf.getClass().getResource( "hibernate.cfg.xml")) > // the following should allows use of a generic configuration file > // by overriding the items that need to be customized. > //.setProperty( "connection.url", > "jdbc:mysql://someMachine.ncsu.edu:3306/M_grisea_genbank_biosql") > //.setProperty( "connection.username", "aUser") > //.setProperty( "connection.password", "aPassword") > // > // The following can be used to adjust memory consumption. > //.setProperty( "hibernate.jdbc.batch_size", "20") > //.setProperty( "hibernate.cache.use_second_level_cache", "false") > // > // examining the generated SQL can be informative... > //.setProperty( "hibernate.show_sql", "true") > > // Go and make the support interfaces... > .buildSessionFactory(); > > Session session = null; > try > { > session = bf.doSessionFactoryBindings( sessionFactory); > > while ( argPos < args.length) > { > File f = new File( args[argPos++]); > > // handle one level of directories > if ( f.isDirectory()) > { > File contents[] = f.listFiles(); > for ( int j=contents.length-1;j>=0;j--) > bf.loadNSave( session, contents[j]); > } > > bf.loadNSave( session, f); > } > } > finally > { > if ( session != null) > { > session.flush(); // force in-memory to disk. > session.close(); // only for local sessions > } > } > } > > /** > * The session is the primary interaction layer between Hibernate and > * the underlying database. Closely allied with that is a suite of > * Biojavax classes handling the load and save operations. These classes > * are coordinated throught the RichObjectFactory. Thus, correctly > * setting up and using the factory for all object operations is > * critical! > */ > Session doSessionFactoryBindings( SessionFactory sessionFactory) > { > if ( verbose) System.out.println( "doing bindings."); > // open a session before processing the files. This allows the > // session to survive across the multiple transactions. And, hopefully, > // to provide level-2 caching services for the objects.... > // Contrast with getCurrentSession wich only survives for the current > // transaction. > Session session = sessionFactory.openSession(); > > // Change DefaultNamespaceName binding from "biojavax" > RichObjectFactory.setDefaultNamespaceName( "genbankBiosqlRich"); > > // Change DefaultOntologyName binding from "lcl". Hopefully, this will > // map the genbank annotation information into the SO term space. This > // works for some, but not all features. Those which donto map are > // flagged as "auto-generated by biojavax". > // nota bene: may be dangerous if semantics are not exactly the same! > // examination of the SO mapping indicated that were the terms align, > the > // semantics also align. > // Benefit is that semantic queries can be performed on the loaded info. > RichObjectFactory.setDefaultOntologyName( "sequence"); //"SO" ); > > > // Hook to BiojavaX and BioSQL. This sets up the proper conditions for > // transparently hooking to the database and supplying objects from > // that db if they exist within it. This is accomplished via hooking the > // Builder, Resolver, and Handler to BioSQL implementations. > // Establishes standard bindings for: > // RichObjectBuilder, > // DefaultCrossReferenceResolver, > // DefaultRichSequenceHandler. > // nb: PositionResolver is left as new AverageResolver(); > RichObjectFactory.connectToBioSQL(session); > > // also grab a reference to the underlying database (so that I can use > // the convenience wrapper methods for delting entries). > //db = new BioSQLRichSequenceDB( session); // create the > RichSequenceDB wrapper around the Hibernate session > > return session; > } > > /** > * This works for genbank files containing multiple sequences. > * Originaly concept from: > http://portal.open-bio.org/pipermail/biojava-l/2007-April/005824.html > * It fails on inserting existant record(s) - does not replace... > * This causes grief when loading multiple files... > */ > public void loadNSave( Session session, File fileName) > { > boolean localSession = (session == null); > Transaction tx = null; > // ensure that an acceptable session configuration exists. > if ( session == null) throw new Error( "session object not > established"); > > // Note the retrieval of namespace VIA the factory. The interface > // documentation did not make clear the requirement to use the > // established 'singleton' object (via getDefaultNamespace or > equivalent). > // The underlying hibernate code does not attempt to automatically > ensure > // the uniqueness (singleton) by attempting a load of any instances. > // Failure to use the factory will result in attempts to create a > // duplicate namespace in the database. > org.biojavax.Namespace ns = RichObjectFactory.getDefaultNamespace(); > > try > { > if ( verbose) System.out.println( "*********** Loading > "+fileName+"..."); > BufferedReader br = new BufferedReader( new FileReader( fileName) ); > > // readGenbankDNA loads the objects from the stream and uses the > // established factory(ies) and defaults for object creation. > if ( verbose) System.out.println( "*********** readGenbankDNA..."); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA( br, > ns); > > while ( rsi.hasNext() ) // for each sequence in the file... > { > if ( verbose) System.out.println( "*********** start transaction."); > // Hibernate seems to REQUIRE transactions when objects are > modified. > tx = session.beginTransaction(); > > if ( verbose) System.out.println( "*********** Loading next > sequence..."); > RichSequence sequence = rsi.nextRichSequence(); > System.out.println( "loaded sequence "+sequence.getAccession()+ > ", identifier: "+ sequence.getIdentifier()); > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name = > :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > if ( verbose) System.out.println( "*********** DELETING extant > sequence..."); > // Interesintly, hibernate does not seem to do transactions in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > try > { > // Loading entire genomes from genbank consumes large amounts > // of memory. Thus, each sequence and its associated > // annotations are wrapped in a transaction, the transaction > saved, > // and the in-memory cache is cleared. While being somewhat > // inefficient, this approach does limit memory consumption. > if ( verbose) System.out.println( "*********** saving..."); > > // synchronize in-memory representation w/ the database > session.saveOrUpdate( "Sequence", sequence ); > if ( verbose) System.out.println( "*********** comitting..."); > tx.commit(); // save to database - does an automatic flush > // batch operations overwhelm the hibernate cache - clear it out! > if ( verbose) System.out.println( "*********** flushing..."); > session.flush(); // force in-memory to disk. > if ( verbose) System.out.println( "*********** clearing..."); > session.clear(); // clean out cache. > } > catch (HibernateException ex) > { > tx.rollback(); // discard the sequence and all its annotations > ex.printStackTrace(); > } > } > } > catch (FileNotFoundException ex) > { > ex.printStackTrace(); > } > catch ( BioException bex) > { > bex.printStackTrace(); > } > } > > } > > > > package primerdb; > > import java.io.BufferedReader; > import java.io.File; > import java.io.FileFilter; > import java.io.FileNotFoundException; > import java.io.FileReader; > import java.io.IOException; > import java.sql.SQLException; > import java.util.ArrayList; > import org.biojava.bio.BioException; > import org.biojavax.Namespace; > import org.biojavax.RichObjectFactory; > import org.biojavax.SimpleNamespace; > import org.biojavax.bio.BioEntry; > import org.biojavax.bio.db.RichSequenceDB; > import org.biojavax.bio.db.biosql.BioSQLRichSequenceDB; > import org.biojavax.bio.seq.RichSequence; > import org.biojavax.bio.seq.RichSequenceIterator; > import org.hibernate.HibernateException; > import org.hibernate.Query; > import org.hibernate.Session; > import org.hibernate.SessionFactory; > import org.hibernate.Transaction; > import org.hibernate.cfg.Configuration; > > public class SequenceLoaderNew { > > private SessionFactory sessionFactory; > private Session session = null; > > private void initSession() { > sessionFactory = new > Configuration().configure().buildSessionFactory(); > session = sessionFactory.openSession(); > RichObjectFactory.connectToBioSQL(session); > } > > public static ArrayList getFiles(File filePath) { > FileFilter fileFilter = new FileFilter() { > > public boolean accept(File pathname) { > return pathname.isFile(); > } > }; > return getFiles(filePath, fileFilter); > } > > public static ArrayList getFiles(File filePath, FileFilter fileFilter) { > ArrayList rtn = new ArrayList(); > if (filePath.isFile()) { > if (fileFilter.accept(filePath)) { > rtn.add(filePath); > } > } else if (filePath.isDirectory()) { > File[] flist = filePath.listFiles(); > for (int i = 0; i < flist.length; i++) { > ArrayList subRtn = getFiles(flist[i], fileFilter); > for (int k = 0; k < subRtn.size(); k++) { > rtn.add(subRtn.get(k)); > } > } > } > return rtn; > } > > public void loadGenbankSeq(String[] filePaths, String namespace) throws > FileNotFoundException, BioException, SQLException, InterruptedException, > IOException { > File[] files = new File[filePaths.length]; > for (int i = 0; i < filePaths.length; i++) { > files[i] = new File(filePaths[i]); > } > loadGenbankSeq(files, namespace); > } > > public void loadGenbankSeq(File[] files, String namespace) throws > FileNotFoundException, BioException, SQLException, InterruptedException, > IOException { > if (session == null) { > initSession(); > } > Namespace ns = (Namespace) > RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); > RichSequenceDB db = new BioSQLRichSequenceDB(session); > for (int i = 0; i < files.length; i++) { > File file = files[i]; > System.out.println("Start loading file " + file.getAbsolutePath() > + " at " + System.currentTimeMillis()); > BufferedReader br = new BufferedReader(new FileReader(file)); > RichSequenceIterator rsi = > RichSequence.IOTools.readGenbankDNA(br, ns); > try { > while (rsi.hasNext()) { > Transaction tx = session.beginTransaction(); > try { > RichSequence sequence = rsi.nextRichSequence(); > System.out.println("Loaded sequence" + > sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); > Query q = session.createQuery("from BioEntry as s > where s.name = :acc"); > q.setString("acc", sequence.getAccession()); > BioEntry be = (BioEntry) q.uniqueResult(); > if (be != null) { > session.delete(be); > tx.commit(); > tx = session.beginTransaction(); > } > System.out.println("Save sequence " + > sequence.getAccession()); > session.saveOrUpdate("Sequence", sequence); > tx.commit(); > System.out.println("Finished savig sequence " + > sequence.getAccession() + "\n"); > } catch (HibernateException ex) { > tx.rollback(); > ex.printStackTrace(); > } > } > } finally { > //session.flush(); > //RichObjectFactory.clearLRUCache(); > //session.clear(); > } > br.close(); > } > } > > public static void main(String[] args) throws BioException, > FileNotFoundException, InterruptedException, SQLException, IOException { > SequenceLoaderNew sl = new SequenceLoaderNew(); > FileFilter ff = new FileFilter() { > public boolean accept(File pathname) { > return pathname.isFile() && > (pathname.getName().toLowerCase().endsWith("gbk") || > pathname.getName().toLowerCase().endsWith("gb")); > } > }; > ArrayList flist = SequenceLoaderNew.getFiles(new > File("/genomeseq/bacteria"), ff); > File[] files = new File[flist.size()]; > for (int i = 0; i < flist.size(); i++) { > files[i] = (File) flist.get(i); > } > for (int i = 0; i < files.length; i++) { > System.out.println(files[i].getAbsolutePath() + ", size: " + > files[i].length()); > } > sl.loadGenbankSeq(files, "genbank"); > } > } > > From biopython at maubp.freeserve.co.uk Sat May 24 08:21:12 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Sat, 24 May 2008 13:21:12 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? Message-ID: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> This is a BioSQL related query - but first a little background: One topic that has recently come up on the Biopython developers mailing list is extending our sequence classes to deal with "per letter" annotation. This annotation should then survive splicing the sequence into sub-strings for example. For example, with nucleotide sequences, each base-pair may have an associated quality score (one float per bp). Or perhaps you might have a contig region where for each bp you want to record the number of fragments it is supported by (one integer per bp). Similarly, for proteins, you might know the secondary structure (for example held as a character per amino acid, a = alpha helix etc). For a PDB file, you might want to have an object for each residue holding an associated set of atomic coordinates, or may just the C-alpha back bone coordinates (three floats per residue). One final motivating example, you might want to hold the solvent accessibility of each residue (one float per residue). First of all, have any of the other Bio* project implemented anything like this? If so, I'd like to have a look at the relevant documentation (and depending on the language, even the implementation). And secondly, how would you go about storing it in BioSQL? As far as I can see, there isn't anything in BioSQL at the moment suitable (other than abusing the sequence features). I will be away most of next week, so I apologise in advance for an delayed responses. Peter (Biopython) From hlapp at gmx.net Sat May 24 20:16:31 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sat, 24 May 2008 20:16:31 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> Message-ID: <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> Comments below. On May 24, 2008, at 8:21 AM, Peter wrote: > This is a BioSQL related query - but first a little background: > > One topic that has recently come up on the Biopython developers > mailing list is extending our sequence classes to deal with "per > letter" annotation. This annotation should then survive splicing the > sequence into sub-strings for example. > > For example, with nucleotide sequences, each base-pair may have an > associated quality score (one float per bp). Or perhaps you might > have a contig region where for each bp you want to record the number > of fragments it is supported by (one integer per bp). > > Similarly, for proteins, you might know the secondary structure (for > example held as a character per amino acid, a = alpha helix etc). For > a PDB file, you might want to have an object for each residue holding > an associated set of atomic coordinates, or may just the C-alpha back > bone coordinates (three floats per residue). One final motivating > example, you might want to hold the solvent accessibility of each > residue (one float per residue). > > First of all, have any of the other Bio* project implemented anything > like this? If so, I'd like to have a look at the relevant > documentation (and depending on the language, even the > implementation). And secondly, how would you go about storing it in > BioSQL? As far as I can see, there isn't anything in BioSQL at the > moment suitable (other than abusing the sequence features). It sounds like in essence you want to store alternative sequences in other alphabets for a sequence? In BioPerl we have Bio::Seq::SeqWithQuality and the more generic Bio::Seq::MetaI. However, BioSQL in v1.0 really only supports a 1-1 relationship between Bioentry and Biosequence, i.e., a bioentry can only have a single sequence, and hence additional sequences (quality values, secondary structure, etc) would need to be stored as a flat annotation value, or through a the biosequence of a second bioentry that is linked to the first through a bioentry_relationship. (Biosequence in principle allows any alphabet.) Neither of those kludges (in fact, quite bad hacks) seem particularly attractive, so this would actually be another use case in favor of relaxing the 1-1 cardinality constraint to one that's 1-n. (Feel free to add this to the roadmap on the wiki.) As you say, you could indeed do this using seqfeatures too, but that'd be an abuse. -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From debrown at unity.ncsu.edu Wed May 21 14:50:09 2008 From: debrown at unity.ncsu.edu (Doug Brown) Date: Wed, 21 May 2008 14:50:09 -0400 Subject: [BioSQL-l] [Biojava-l] Load/Update Genbank sequence issue In-Reply-To: <4833C100.7040304@molbio.mgh.harvard.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: <48346EE1.70004@unity.ncsu.edu> Hi Gang wu, I recognize your problem. I to had to build a loader for genbank flat files. When attempting to 'replace' a record stored in the database, one needs to explicitly delete it before doing the save. I found that the hibernate code does not seem to understand that an in-memory deletion should be realized in the data base prior to the new insertion. My solution, see attached code, was to commit the transaction for the deletion and then open a new transaction for the insertion. Try inserting the following after "System.out.println("Loaded sequence"": // delete any extant sequence from the database. The cascaded // constraints will result in removal of all associated features // and what-not. Query q = session.createQuery( "from BioEntry as s where s.name = :acc"); q.setString( "acc", sequence.getAccession()); BioEntry be = (BioEntry)q.uniqueResult(); if ( be != null) { // Interestingly, hibernate does not seem to do transactions in the // same sense that a database would. Thus, I need to commit the // delete operation before I attempt to insert the replacement // information. session.delete( be); tx.commit(); tx = session.beginTransaction(); } Regards, Doug gang wu wrote: > I got another problem with almost the same code(see attached code and > output). If I call the loadSeq() only once, everything works fine. The > second call of the same method will fail. By the exception message, it > looks like the session is not cleaned up yet though at the end of the > method the session has been flush/clear/closed. Anything wrong? -- Doug Brown - Bioinformatics Fungal Genomics Laboratory Center for Integrated Fungal Research North Carolina State University Campus Box 7251, Raleigh, NC 27695-7251 https://www.fungalgenomics.ncsu.edu/~debrown/ Tel: (919) 513-0394, Fax (919) 513-0024 e-mail: doug_brown AtSign ncsu.edu -------------- next part -------------- A non-text attachment was scrubbed... Name: BriefLoader.java Type: text/x-java Size: 11672 bytes Desc: not available URL: From gwu at molbio.mgh.harvard.edu Thu May 22 16:42:22 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Thu, 22 May 2008 16:42:22 -0400 Subject: [BioSQL-l] [Biojava-l] Load/Update Genbank sequence issue In-Reply-To: <48346EE1.70004@unity.ncsu.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> <48346EE1.70004@unity.ncsu.edu> Message-ID: <4835DAAE.6080609@molbio.mgh.harvard.edu> Hi Doug and Richard, Thanks for your reply. I've been following your suggestions and finding a way that works for me. Basically, if there is anything in the code that flush/clear the session, it's going to be a problem for the following calls to the same method. I'm not sure if it's Hibernate bug or is like Richard suggested that it is a feature. Attached is the code I am using to load/update Genbank sequences. It could be easily generalized to load other sequences(if the process works). Seems it works for me now(still running test on bigger sequences). It's pretty fast to load those small bacteria sequences, usually 10-60 seconds. But it seems it's getting choked with the bigger sequences. I started it last night at about 11pm to load the 5 Arabidopsis thaliana genome sequences(about 280MB total). The first one finished in about 1.5 hours and it's stilling hanging there now on the second sequence. I saw a 100% CPU usage and 2.6GB memory assigned for the program. The MySQL server is running on the same server. The machine has 8GB RAM and 2 dual core exon CPUS running at 3.73GHZ. Doug, I tested your code and seems the output is not always consistent: I tried to load two sequences. Sometimes succeeded and sometimes failed. I wonder it's still the session issue. I did not try with removing those flush/clear code. Thanks again for your response. It really helps me out. I'll post my code here if I work out a better solution. Gang Doug Brown wrote: > Hi Gang wu, > > I recognize your problem. I to had to build a loader for genbank flat > files. When attempting to 'replace' a record stored in the database, > one needs to explicitly delete it before doing the save. I found that > the hibernate code does not seem to understand that an in-memory > deletion should be realized in the data base prior to the new > insertion. My solution, see attached code, was to commit the > transaction for the deletion and then open a new transaction for the > insertion. > > Try inserting the following after "System.out.println("Loaded sequence"": > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name > = :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > // Interestingly, hibernate does not seem to do transactions > in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > > Regards, > Doug > > gang wu wrote: >> I got another problem with almost the same code(see attached code and >> output). If I call the loadSeq() only once, everything works fine. >> The second call of the same method will fail. By the exception >> message, it looks like the session is not cleaned up yet though at >> the end of the method the session has been flush/clear/closed. >> Anything wrong? > > ------------------------------------------------------------------------ > > // Copyright 2008, by North Carolina State University. All rights reserved. > > /** > * > * javac -cp "C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" bioinformatics\biojava\BriefLoader.java > * > * java -Xmx100m -cp "c:\jars\asm.jar;c:\jars\asm-attrs.jar;c:\jars\cglib-2.1.3.jar;c:\jars\jta.jar;c:\jars\antlr-2.7.6.jar;c:\jars\commons-collections-2.1.1.jar;c:\jars\commons-logging-1.0.4.jar;c:\jars\dom4j-1.6.1.jar;C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" -Djdbc.drivers=com.mysql.jdbc.Driver bioinformatics.biojava.BriefLoader C:\WorkData\genomes\M_grisea_genbank_v5\CH476760.gb > */ > package bioinformatics.biojavaTools; > > import java.io.BufferedReader; > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileReader; > import java.io.IOException; > > import org.biojava.bio.BioException; > import org.biojavax.*; > import org.biojavax.RichObjectFactory; > import org.biojavax.bio.db.biosql.BioSQLRichSequenceDB; > import org.biojavax.bio.seq.*; > import org.biojavax.bio.seq.RichSequence.*; > import org.biojavax.bio.seq.RichSequence.IOTools; > import org.biojavax.bio.seq.io.*; > import org.biojavax.bio.BioEntry; > > import org.hibernate.*; > import org.hibernate.cfg.*; > > //import java.util.logging.*; > //import org.apache.commons.logging.*; > > > > > public class BriefLoader > { > static SessionFactory sessionFactory; > static boolean verbose = false; > public static void main(String[] args) > { > int argPos = 0; > if ( args.length > 0 && args[argPos].equals( "-v")) > { > verbose = true; > argPos++; > } > if ( argPos == args.length) > { > System.out.println( "Usage: BriefLoader [-v] file1.bg [file2.gb ...]"); > return; > } > > BriefLoader bf = new BriefLoader(); > > // logging: > // I want to suppress the verbose info messages. > // After some investigation, it seems that commons > // logging uses a default of Jdk14Logger (the standard java logger). > // Thus, I can control the commons logger via the java.util.logging API. > // API > java.util.logging.Logger jdklogger = java.util.logging.Logger.getLogger("org.hibernate"); > jdklogger.setLevel(java.util.logging.Level.WARNING); > > sessionFactory = new > // Configuration is very expensive and can only be done once. > // > // properties can be specified via the file hibernate.properties located > // on the classpath, > // on the command line via -D, > // via the defaut "hibernate.cfg.xml" file in the current working directory, > // via an explicitly identified file, e.g. "specific_file.cfg.xml", > // via explicit calls to setProperty. The same goes for resources. > // Later definitions override earlier ones. > Configuration() > // Note: > // specifying the resource location of the configuration file > // works ONLY if I also modify the > // hibernate.cfg.xml file to add the class' package as a prefix > // for every resource. Hibernate does not understand the > // concept of relative locations based on the location of the > // configuratin file. Nonetheless, this allows me to organize the > // mapping files based on java packages. > .configure( bf.getClass().getResource( "hibernate.cfg.xml")) > // the following should allows use of a generic configuration file > // by overriding the items that need to be customized. > //.setProperty( "connection.url", "jdbc:mysql://someMachine.ncsu.edu:3306/M_grisea_genbank_biosql") > //.setProperty( "connection.username", "aUser") > //.setProperty( "connection.password", "aPassword") > // > // The following can be used to adjust memory consumption. > //.setProperty( "hibernate.jdbc.batch_size", "20") > //.setProperty( "hibernate.cache.use_second_level_cache", "false") > // > // examining the generated SQL can be informative... > //.setProperty( "hibernate.show_sql", "true") > > // Go and make the support interfaces... > .buildSessionFactory(); > > Session session = null; > try > { > session = bf.doSessionFactoryBindings( sessionFactory); > > while ( argPos < args.length) > { > File f = new File( args[argPos++]); > > // handle one level of directories > if ( f.isDirectory()) > { > File contents[] = f.listFiles(); > for ( int j=contents.length-1;j>=0;j--) > bf.loadNSave( session, contents[j]); > } > > bf.loadNSave( session, f); > } > } > finally > { > if ( session != null) > { > session.flush(); // force in-memory to disk. > session.close(); // only for local sessions > } > } > } > > /** > * The session is the primary interaction layer between Hibernate and > * the underlying database. Closely allied with that is a suite of > * Biojavax classes handling the load and save operations. These classes > * are coordinated throught the RichObjectFactory. Thus, correctly > * setting up and using the factory for all object operations is > * critical! > */ > Session doSessionFactoryBindings( SessionFactory sessionFactory) > { > if ( verbose) System.out.println( "doing bindings."); > // open a session before processing the files. This allows the > // session to survive across the multiple transactions. And, hopefully, > // to provide level-2 caching services for the objects.... > // Contrast with getCurrentSession wich only survives for the current > // transaction. > Session session = sessionFactory.openSession(); > > // Change DefaultNamespaceName binding from "biojavax" > RichObjectFactory.setDefaultNamespaceName( "genbankBiosqlRich"); > > // Change DefaultOntologyName binding from "lcl". Hopefully, this will > // map the genbank annotation information into the SO term space. This > // works for some, but not all features. Those which donto map are > // flagged as "auto-generated by biojavax". > // nota bene: may be dangerous if semantics are not exactly the same! > // examination of the SO mapping indicated that were the terms align, the > // semantics also align. > // Benefit is that semantic queries can be performed on the loaded info. > RichObjectFactory.setDefaultOntologyName( "sequence"); //"SO" ); > > > // Hook to BiojavaX and BioSQL. This sets up the proper conditions for > // transparently hooking to the database and supplying objects from > // that db if they exist within it. This is accomplished via hooking the > // Builder, Resolver, and Handler to BioSQL implementations. > // Establishes standard bindings for: > // RichObjectBuilder, > // DefaultCrossReferenceResolver, > // DefaultRichSequenceHandler. > // nb: PositionResolver is left as new AverageResolver(); > RichObjectFactory.connectToBioSQL(session); > > // also grab a reference to the underlying database (so that I can use > // the convenience wrapper methods for delting entries). > //db = new BioSQLRichSequenceDB( session); // create the RichSequenceDB wrapper around the Hibernate session > > return session; > } > > /** > * This works for genbank files containing multiple sequences. > * Originaly concept from: http://portal.open-bio.org/pipermail/biojava-l/2007-April/005824.html > * It fails on inserting existant record(s) - does not replace... > * This causes grief when loading multiple files... > */ > public void loadNSave( Session session, File fileName) > { > boolean localSession = (session == null); > Transaction tx = null; > // ensure that an acceptable session configuration exists. > if ( session == null) throw new Error( "session object not established"); > > // Note the retrieval of namespace VIA the factory. The interface > // documentation did not make clear the requirement to use the > // established 'singleton' object (via getDefaultNamespace or equivalent). > // The underlying hibernate code does not attempt to automatically ensure > // the uniqueness (singleton) by attempting a load of any instances. > // Failure to use the factory will result in attempts to create a > // duplicate namespace in the database. > org.biojavax.Namespace ns = RichObjectFactory.getDefaultNamespace(); > > try > { > if ( verbose) System.out.println( "*********** Loading "+fileName+"..."); > BufferedReader br = new BufferedReader( new FileReader( fileName) ); > > // readGenbankDNA loads the objects from the stream and uses the > // established factory(ies) and defaults for object creation. > if ( verbose) System.out.println( "*********** readGenbankDNA..."); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA( br, ns); > > while ( rsi.hasNext() ) // for each sequence in the file... > { > if ( verbose) System.out.println( "*********** start transaction."); > // Hibernate seems to REQUIRE transactions when objects are modified. > tx = session.beginTransaction(); > > if ( verbose) System.out.println( "*********** Loading next sequence..."); > RichSequence sequence = rsi.nextRichSequence(); > System.out.println( "loaded sequence "+sequence.getAccession()+ > ", identifier: "+ sequence.getIdentifier()); > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name = :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > if ( verbose) System.out.println( "*********** DELETING extant sequence..."); > // Interesintly, hibernate does not seem to do transactions in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > try > { > // Loading entire genomes from genbank consumes large amounts > // of memory. Thus, each sequence and its associated > // annotations are wrapped in a transaction, the transaction saved, > // and the in-memory cache is cleared. While being somewhat > // inefficient, this approach does limit memory consumption. > if ( verbose) System.out.println( "*********** saving..."); > > // synchronize in-memory representation w/ the database > session.saveOrUpdate( "Sequence", sequence ); > if ( verbose) System.out.println( "*********** comitting..."); > tx.commit(); // save to database - does an automatic flush > // batch operations overwhelm the hibernate cache - clear it out! > if ( verbose) System.out.println( "*********** flushing..."); > session.flush(); // force in-memory to disk. > if ( verbose) System.out.println( "*********** clearing..."); > session.clear(); // clean out cache. > } > catch (HibernateException ex) > { > tx.rollback(); // discard the sequence and all its annotations > ex.printStackTrace(); > } > } > } > catch (FileNotFoundException ex) > { > ex.printStackTrace(); > } > catch ( BioException bex) > { > bex.printStackTrace(); > } > } > > } > > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: SequenceLoaderNew.java URL: From biopython at maubp.freeserve.co.uk Sun May 25 05:49:36 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Sun, 25 May 2008 10:49:36 +0100 Subject: [BioSQL-l] *** SPAM *** Re: Storing "per letter" annotation? In-Reply-To: <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> Message-ID: <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> > It sounds like in essence you want to store alternative sequences in other > alphabets for a sequence? I hadn't thought of it like that, but for many of the examples it would just be one character per letter of sequence, so could be held as an alternative sequence. This doesn't really extend to cover things like a list of integers or a list of floats, but would certainly cover a number of use-cases. > In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > Bio::Seq::MetaI. I'll have to look at those. Thanks for you comments Hilmar - I'm not yet sure what would be the best way forward for extending BioSQL for this sort of thing. I guess some real world examples of where it would be useful would be a helpful guide. Peter From biopython at maubp.freeserve.co.uk Sun May 25 06:00:36 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Sun, 25 May 2008 11:00:36 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? Message-ID: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Hilmar Wrote: >> It sounds like in essence you want to store alternative sequences in other >> alphabets for a sequence? Peter wrote: > I hadn't thought of it like that, but for many of the examples it > would just be one character per letter of sequence, so could be held > as an alternative sequence. This doesn't really extend to cover > things like a list of integers or a list of floats, but would > certainly cover a number of use-cases. Now that I know which bits of BioPerl to search for, I see there has been some similar BioSQL discussion in the past, e.g. http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html Hilmar Wrote: >> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >> Bio::Seq::MetaI. I had wondered what metals had to do with sequences, in a different font MetaI is of course short for MetaInformation! Peter P.S. I'll be away next week, so I probably won't follow up on this topic immediately, From dicknetherlands at gmail.com Sun May 25 07:55:32 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Sun, 25 May 2008 12:55:32 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: For what it's worth, BioJava allows you to define sequences as lists of symbols, and each symbol can contain as much info as you want. e.g. if you consider DNA to be an alphabet of ATCG etc., and you consider quality scores as an alphabet consisting of the integer numbers, then to construct a quality-scored sequence you use BioJava to make a cross-product alphabet of the two, where each symbol in the sequence actually consists of a pair of symbols, one from each alphabet. This means you can combine any number of alphabets to define complex and informative objects to represent each symbol in your sequence. cheers, Richard. 2008/5/25 Peter : > Hilmar Wrote: >>> It sounds like in essence you want to store alternative sequences in other >>> alphabets for a sequence? > > Peter wrote: >> I hadn't thought of it like that, but for many of the examples it >> would just be one character per letter of sequence, so could be held >> as an alternative sequence. This doesn't really extend to cover >> things like a list of integers or a list of floats, but would >> certainly cover a number of use-cases. > > Now that I know which bits of BioPerl to search for, I see there has > been some similar BioSQL discussion in the past, e.g. > http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html > > Hilmar Wrote: >>> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >>> Bio::Seq::MetaI. > > I had wondered what metals had to do with sequences, in a different > font MetaI is of course short for MetaInformation! > > Peter > > P.S. I'll be away next week, so I probably won't follow up on this > topic immediately, > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From hlapp at gmx.net Sun May 25 11:43:26 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sun, 25 May 2008 11:43:26 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: <341678E5-69E1-4486-A176-893762849D68@gmx.net> Indeed, when building a cross-product you can mix alphabets too of course (as compared to codons, which is DNA x DNA x DNA). That's a nice concept - so given proper de/serialization from/into one flat string the present BioSQL model could hold the cross-product sequence already. Do you guys have a standard notation for the alphabet in this case? More concretely, if you store a cross-product sequence in BioSQL, what do you put into the biosequence.alphabet column? Peter - I had included integer or floating point sequences in my response; there is no restriction that individual symbols need to be representable by at most 7 or 8 bits. -hilmar On May 25, 2008, at 7:55 AM, Richard Holland wrote: > For what it's worth, BioJava allows you to define sequences as lists > of symbols, and each symbol can contain as much info as you want. e.g. > if you consider DNA to be an alphabet of ATCG etc., and you consider > quality scores as an alphabet consisting of the integer numbers, then > to construct a quality-scored sequence you use BioJava to make a > cross-product alphabet of the two, where each symbol in the sequence > actually consists of a pair of symbols, one from each alphabet. This > means you can combine any number of alphabets to define complex and > informative objects to represent each symbol in your sequence. > > cheers, > Richard. > > 2008/5/25 Peter : >> Hilmar Wrote: >>>> It sounds like in essence you want to store alternative >>>> sequences in other >>>> alphabets for a sequence? >> >> Peter wrote: >>> I hadn't thought of it like that, but for many of the examples it >>> would just be one character per letter of sequence, so could be held >>> as an alternative sequence. This doesn't really extend to cover >>> things like a list of integers or a list of floats, but would >>> certainly cover a number of use-cases. >> >> Now that I know which bits of BioPerl to search for, I see there has >> been some similar BioSQL discussion in the past, e.g. >> http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html >> >> Hilmar Wrote: >>>> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >>>> Bio::Seq::MetaI. >> >> I had wondered what metals had to do with sequences, in a different >> font MetaI is of course short for MetaInformation! >> >> Peter >> >> P.S. I'll be away next week, so I probably won't follow up on this >> topic immediately, >> _______________________________________________ >> BioSQL-l mailing list >> BioSQL-l at lists.open-bio.org >> http://lists.open-bio.org/mailman/listinfo/biosql-l >> -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Sun May 25 11:44:05 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sun, 25 May 2008 11:44:05 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: <5BA0181B-C815-4B46-904D-05BA2504FFF3@gmx.net> On May 25, 2008, at 6:12 AM, Robson Francisco de Souza wrote: > Anyone might correct me if I'm wrong but I believe MetaI it is > short for "Meta Interface", which means this package defines the > methods any Bio::Seq::MetaI-complaint object should implement. That is correct. Bio::Seq::MetaI is the interface, and Bio::Seq::Meta is an implementation. -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Sun May 25 12:44:36 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sun, 25 May 2008 12:44:36 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: <595C5BBE-A07A-4ECA-A054-35CD9462AE3F@gmx.net> On May 25, 2008, at 6:00 AM, Peter wrote: > Now that I know which bits of BioPerl to search for, I see there has > been some similar BioSQL discussion in the past, e.g. > http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html Oops - indeed - I'm glad we arrive at the same conclusion 3 years later :-)) -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From dicknetherlands at gmail.com Sun May 25 15:21:36 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Sun, 25 May 2008 20:21:36 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <341678E5-69E1-4486-A176-893762849D68@gmx.net> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> <341678E5-69E1-4486-A176-893762849D68@gmx.net> Message-ID: The notation is to enclose each symbol in square brackets, with comma separate sub-symbols, each of which can be square bracketed itself if it consists of further sub-divisions. The alphabet name is then just the name of the alphabet object in BioJava - you'd have to decode this externally to the db, unless you introduce some kind of fixed format description for the alphabet to store in the name field. We've never tried storing this kind of sequence to my knowledge. Something to try in future! Richard. 2008/5/25 Hilmar Lapp : > Indeed, when building a cross-product you can mix alphabets too of course > (as compared to codons, which is DNA x DNA x DNA). > > That's a nice concept - so given proper de/serialization from/into one flat > string the present BioSQL model could hold the cross-product sequence > already. > > Do you guys have a standard notation for the alphabet in this case? More > concretely, if you store a cross-product sequence in BioSQL, what do you put > into the biosequence.alphabet column? > > Peter - I had included integer or floating point sequences in my response; > there is no restriction that individual symbols need to be representable by > at most 7 or 8 bits. > > -hilmar > > On May 25, 2008, at 7:55 AM, Richard Holland wrote: >> >> For what it's worth, BioJava allows you to define sequences as lists >> of symbols, and each symbol can contain as much info as you want. e.g. >> if you consider DNA to be an alphabet of ATCG etc., and you consider >> quality scores as an alphabet consisting of the integer numbers, then >> to construct a quality-scored sequence you use BioJava to make a >> cross-product alphabet of the two, where each symbol in the sequence >> actually consists of a pair of symbols, one from each alphabet. This >> means you can combine any number of alphabets to define complex and >> informative objects to represent each symbol in your sequence. >> >> cheers, >> Richard. >> >> 2008/5/25 Peter : >>> >>> Hilmar Wrote: >>>>> >>>>> It sounds like in essence you want to store alternative sequences in >>>>> other >>>>> alphabets for a sequence? >>> >>> Peter wrote: >>>> >>>> I hadn't thought of it like that, but for many of the examples it >>>> would just be one character per letter of sequence, so could be held >>>> as an alternative sequence. This doesn't really extend to cover >>>> things like a list of integers or a list of floats, but would >>>> certainly cover a number of use-cases. >>> >>> Now that I know which bits of BioPerl to search for, I see there has >>> been some similar BioSQL discussion in the past, e.g. >>> http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html >>> >>> Hilmar Wrote: >>>>> >>>>> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >>>>> Bio::Seq::MetaI. >>> >>> I had wondered what metals had to do with sequences, in a different >>> font MetaI is of course short for MetaInformation! >>> >>> Peter >>> >>> P.S. I'll be away next week, so I probably won't follow up on this >>> topic immediately, >>> _______________________________________________ >>> BioSQL-l mailing list >>> BioSQL-l at lists.open-bio.org >>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>> > > -- > =========================================================== > : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : > =========================================================== > > > > From markjschreiber at gmail.com Sun May 25 22:23:01 2008 From: markjschreiber at gmail.com (Mark Schreiber) Date: Mon, 26 May 2008 10:23:01 +0800 Subject: [BioSQL-l] *** SPAM *** Re: Storing "per letter" annotation? In-Reply-To: <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> Message-ID: <93b45ca50805251923q6f443078l415d59317eba0b04@mail.gmail.com> Hi - Genbank/EMBL format has options for partial locations that have ends less than the start or greater than the end of a sequence. This would let you retain feature information after obtaining a subsequence. I think these locations can be stored in BioSQL?? - Mark On 5/25/08, Peter wrote: > > It sounds like in essence you want to store alternative sequences in other > > alphabets for a sequence? > > I hadn't thought of it like that, but for many of the examples it > would just be one character per letter of sequence, so could be held > as an alternative sequence. This doesn't really extend to cover > things like a list of integers or a list of floats, but would > certainly cover a number of use-cases. > > > In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > > Bio::Seq::MetaI. > > I'll have to look at those. > > Thanks for you comments Hilmar - I'm not yet sure what would be the > best way forward for extending BioSQL for this sort of thing. I guess > some real world examples of where it would be useful would be a > helpful guide. > > Peter > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From markjschreiber at gmail.com Sun May 25 22:30:31 2008 From: markjschreiber at gmail.com (Mark Schreiber) Date: Mon, 26 May 2008 10:30:31 +0800 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <341678E5-69E1-4486-A176-893762849D68@gmx.net> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> <341678E5-69E1-4486-A176-893762849D68@gmx.net> Message-ID: <93b45ca50805251930o790f54f1v3337aca6f9fd17bb@mail.gmail.com> Hi - BioJava has Interfaces for tokenizers which can be String or character. Most cross product alphabets don't have official character tokenizers however there is no reason why they can't. I think the only reason why they don't as yet is that there is no official IUB type nomenclature, however he who codes it wins! Because this is an issue that mostly affects BioSQL serialization it would be nice if when people develop these they could become official BioSQL standards so that Bio* et al all speak the same language. - Mark On 5/25/08, Hilmar Lapp wrote: > Indeed, when building a cross-product you can mix alphabets too of course > (as compared to codons, which is DNA x DNA x DNA). > > That's a nice concept - so given proper de/serialization from/into one flat > string the present BioSQL model could hold the cross-product sequence > already. > > Do you guys have a standard notation for the alphabet in this case? More > concretely, if you store a cross-product sequence in BioSQL, what do you put > into the biosequence.alphabet column? > > Peter - I had included integer or floating point sequences in my response; > there is no restriction that individual symbols need to be representable by > at most 7 or 8 bits. > > -hilmar > > > On May 25, 2008, at 7:55 AM, Richard Holland wrote: > > For what it's worth, BioJava allows you to define sequences as lists > > of symbols, and each symbol can contain as much info as you want. e.g. > > if you consider DNA to be an alphabet of ATCG etc., and you consider > > quality scores as an alphabet consisting of the integer numbers, then > > to construct a quality-scored sequence you use BioJava to make a > > cross-product alphabet of the two, where each symbol in the sequence > > actually consists of a pair of symbols, one from each alphabet. This > > means you can combine any number of alphabets to define complex and > > informative objects to represent each symbol in your sequence. > > > > cheers, > > Richard. > > > > 2008/5/25 Peter : > > > > > Hilmar Wrote: > > > > > > > > > > > > It sounds like in essence you want to store alternative sequences in > other > > > > > alphabets for a sequence? > > > > > > > > > > > > > > > Peter wrote: > > > > > > > I hadn't thought of it like that, but for many of the examples it > > > > would just be one character per letter of sequence, so could be held > > > > as an alternative sequence. This doesn't really extend to cover > > > > things like a list of integers or a list of floats, but would > > > > certainly cover a number of use-cases. > > > > > > > > > > Now that I know which bits of BioPerl to search for, I see there has > > > been some similar BioSQL discussion in the past, e.g. > > > > http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html > > > > > > Hilmar Wrote: > > > > > > > > > > > > In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > > > > > Bio::Seq::MetaI. > > > > > > > > > > > > > > > I had wondered what metals had to do with sequences, in a different > > > font MetaI is of course short for MetaInformation! > > > > > > Peter > > > > > > P.S. I'll be away next week, so I probably won't follow up on this > > > topic immediately, > > > _______________________________________________ > > > BioSQL-l mailing list > > > BioSQL-l at lists.open-bio.org > > > http://lists.open-bio.org/mailman/listinfo/biosql-l > > > > > > > > > > -- > =========================================================== > : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : > =========================================================== > > > > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From hlapp at gmx.net Mon May 26 13:52:32 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Mon, 26 May 2008 13:52:32 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <93b45ca50805251923q6f443078l415d59317eba0b04@mail.gmail.com> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> <93b45ca50805251923q6f443078l415d59317eba0b04@mail.gmail.com> Message-ID: On May 25, 2008, at 10:23 PM, Mark Schreiber wrote: > Genbank/EMBL format has options for partial locations that have ends > less than the start or greater than the end of a sequence. This would > let you retain feature information after obtaining a subsequence. > > I think these locations can be stored in BioSQL?? Yes they can. However, I don't think Biojava can handle fuzzy locations, or can it? -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From robfsouza at gmail.com Sun May 25 06:12:47 2008 From: robfsouza at gmail.com (Robson Francisco de Souza) Date: Sun, 25 May 2008 07:12:47 -0300 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: 2008/5/25 Peter : > Hilmar Wrote: > >> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > >> Bio::Seq::MetaI. > > I had wondered what metals had to do with sequences, in a different > font MetaI is of course short for MetaInformation! > Anyone might correct me if I'm wrong but I believe MetaI it is short for "Meta Interface", which means this package defines the methods any Bio::Seq::MetaI-complaint object should implement. Cheers, Robson > Peter > > > P.S. I'll be away next week, so I probably won't follow up on this > topic immediately, > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > > From darin.london at duke.edu Mon May 5 14:08:19 2008 From: darin.london at duke.edu (darin.london at duke.edu) Date: Mon, 5 May 2008 10:08:19 -0400 Subject: [BioSQL-l] BOSC 2008 Announcement and Call For Submissions Message-ID: <200805051408.m45E8JIl023449@tenero.duhs.duke.edu> BOSC 2008 Call for Abstracts Reminder The 9th annual Bioinformatics Open Source Conference (BOSC 2008) will take place in Toronto, Ontario, Canada, as one of several Special Interest Group (SIG) meetings occurring in conjunction with the 16th annual Intelligent Systems for Molecular Biology Conference (ISMB 2008). This is the final reminder to submit your proposals for talks to the BOSC submission system before May 11. Submission Process: All abstracts must be submitted through our Open Conference Systems site (http://events.open-bio.org/BOSC2008/openconf.php). The form will ask for a small Abstract Text to be pasted into it, and a full paper. The small Abstract text should be a summary, while the longer abstract (should provide more details, including the open-source license requirement details) Full-length abstracts are limited to one page with one inch (2.5 cm) margins on the top, sides, and bottom. The full-length abstract should include the title, authors, and affiliations. We prefer your abstract to be in PDF format, although plain t Important Dates: May 11: Abstract submission deadline. June 2: Notification of accepted talks. June 4: Early registration discount cut-off. July 18-19: BOSC 2008! We hope to see you at BOSC 2008! Kam Dahlquist and Darin London BOSC 2008 Co-organizers From biopython at maubp.freeserve.co.uk Wed May 7 10:04:34 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Wed, 7 May 2008 11:04:34 +0100 Subject: [BioSQL-l] MySQL schema, CREATE TABLE and TYPE verus ENGINE Message-ID: <320fb6e00805070304g21c681dbkbaf7411a5c9985c6@mail.gmail.com> Hello all, I've just been running the Biopython BioSQL unit tests on a "new" Linux machine with MySQL 5.0, $ mysql --version mysql Ver 14.12 Distrib 5.0.27, for redhat-linux-gnu (i686) using readline 5.0 Part of the unit test creats a new empty database and loads the schema file biosqldb-mysql.sql into it. This triggers a warning: Warning: 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead My guess is the commands "CREATE TABLE ... TYPE=INNODB;" be updated to "CREATE TABLE ... ENGINE=INNODB;" in biosqldb-mysql.sql to get rid of the warning. According to the following documents, MySQL 4.1 and 5.0 will accept either TYPE or ENGINE, but it looks like MySQL 6.0 insists on using ENGINE. http://dev.mysql.com/doc/refman/4.1/en/create-table.html http://dev.mysql.com/doc/refman/5.0/en/create-table.html http://dev.mysql.com/doc/refman/6.0/en/create-table.html Is this something which should be fixed in BioSQL? Thanks Peter From hlapp at gmx.net Thu May 8 04:22:03 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Wed, 7 May 2008 22:22:03 -0600 Subject: [BioSQL-l] MySQL schema, CREATE TABLE and TYPE verus ENGINE In-Reply-To: <320fb6e00805070304g21c681dbkbaf7411a5c9985c6@mail.gmail.com> References: <320fb6e00805070304g21c681dbkbaf7411a5c9985c6@mail.gmail.com> Message-ID: <3F9E5C22-1FFD-4C80-A4B5-F6CAF7DA05B5@gmx.net> On May 7, 2008, at 4:04 AM, Peter wrote: > According to the following documents, MySQL 4.1 and 5.0 will accept > either TYPE or ENGINE, but it looks like MySQL 6.0 insists on using > ENGINE. > > http://dev.mysql.com/doc/refman/4.1/en/create-table.html > http://dev.mysql.com/doc/refman/5.0/en/create-table.html > http://dev.mysql.com/doc/refman/6.0/en/create-table.html > > Is this something which should be fixed in BioSQL? Sounds like this would not break compatibility for >= 4.1, but would for at least for 3.x. (Not sure about 4.0.x here.) Is anyone still using MySQL with a version < 4.0? -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Thu May 8 04:45:38 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Wed, 7 May 2008 22:45:38 -0600 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL In-Reply-To: <4821C37D.7050105@uni-tuebingen.de> References: <4821C37D.7050105@uni-tuebingen.de> Message-ID: This is odd - it would mean that you don't have the obo.pm parser, or that it can't be loaded. Maybe there is some kind of version mix going on here? Could you check that you have the file Bio/OntologyIO/obo.pm in the directory where you've installed BioPerl? If yes, can you do $ perl -MBio::OntologyIO::obo and let me know what happens? -hilmar On May 7, 2008, at 8:58 AM, Andreas Dr?ger wrote: > Dear all, > > Unfortunately, I am still having trouble while loading the Gene > Ontology into my BioSQL database. I installed BioSQL, downloaded > the file gene_ontology_edit.obo from the Gene Ontology homepage > (http://www.geneontology.org/GO.downloads.ontology.shtml), > installed the BioPerl package bioperl-db-1.5.2_100 as described in > the INSTALL file and tried the following: > > ./scripts/biosql/load_ontology.pl \ > --host localhost --dbname biosql \ > --dbuser myUser \ > --dbpass 'myPassword' \ > --driver mysql \ > --namespace "Gene Ontology" \ > --format obo \ > gene_ontology_edit.obo > > I received the following error message: > > Bio::OntologyIO: obo cannot be found > Exception > ------------- EXCEPTION ------------- > MSG: Failed to load module Bio::OntologyIO::obo. Can't locate Bio/ > OntologyIO/obo.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/ > 5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386- > linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread- > multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/ > lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/ > perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/ > site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi / > usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/ > perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/ > vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/ > vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/ > vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/ > vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/ > perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm > line 394. > > STACK Bio::Root::Root::_load_module /usr/lib/perl5/site_perl/5.8.8/ > Bio/Root/Root.pm:396 > STACK (eval) /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:255 > STACK Bio::OntologyIO::_load_format_module /usr/lib/perl5/site_perl/ > 5.8.8/Bio/OntologyIO.pm:254 > STACK Bio::OntologyIO::new /usr/lib/perl5/site_perl/5.8.8/Bio/ > OntologyIO.pm:165 > STACK toplevel ./scripts/biosql/load_ontology.pl:525 > > -------------------------------------- > > For more information about the OntologyIO system please see the docs. > This includes ways of checking for formats at compile time, not run > time > Can't call method "term_factory" on an undefined value at ./scripts/ > biosql/load_ontology.pl line 531. > [root at u-172-c052 bioperl-db-1.5.2_100]# vim scripts/biosql/ > load_ontology.pl > > > I am grateful for any hint what I can do to solve this problem and > to store the GO in my database. > > Cheers, > Andreas -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Thu May 8 20:24:01 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Thu, 8 May 2008 14:24:01 -0600 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL In-Reply-To: <4822BF3A.2020305@uni-tuebingen.de> References: <4821C37D.7050105@uni-tuebingen.de> <4822BF3A.2020305@uni-tuebingen.de> Message-ID: <5D34FC99-AAC1-4EF5-AD79-4F152D12A391@gmx.net> Hi Andreas - it seems that the GO download you have has two terms with name 'invasive growth', which are both obsoleted, but have different GO IDs. That's a somewhat nasty situation and happens occasionally (ask the GO people if you want to know more on why exactly that's necessary). If you're loading the ontology fresh into your database you can avoid all that by simply leaving all obsolete terms outside using the -- noobsolete switch. There are other options for handling obsolete terms (see the script's POD) that should allow you to stay out of that trouble for updates too. -hilmar On May 8, 2008, at 2:52 AM, Andreas Dr?ger wrote: > Dear all, > > Thank you for your advice! Now it works, but not completely. It > seems that there is either a problem with the ontology file I > downloaded from GO (gene_ontology_edit.obo) or an error in the script: > > ./scripts/biosql/load_ontology.pl --host localhost --dbname > bioseqdb --dbuser myUser --dbpass 'myPasswd' --driver mysql -- > namespace "Gene Ontology" --format obo gene_ontology_edit.obo > > > > And it works: > > > > Loading ontology gene_ontology: > ... terms > ... relationships > Done with gene_ontology. > Loading ontology biological_process: > ... terms > > > > But then I receive the following messages: > > > > -------------------- WARNING --------------------- > MSG: insert in Bio::DB::BioSQL::TermAdaptor (driver) failed, values > were ("GO:0007125","invasive growth","OBSOLETE (was not defined > before being made obsolete).","X","") FKs (46) > Duplicate entry 'invasive growth-46-X' for key 3 > --------------------------------------------------- > Could not store term GO:0007125, name 'invasive growth': > > ------------- EXCEPTION: Bio::Root::Exception ------------- > MSG: create: object (Bio::Ontology::OBOterm) failed to insert or to > be found by unique key > STACK: Error::throw > STACK: Bio::Root::Root::throw /usr/lib/perl5/site_perl/5.8.8/Bio/ > Root/Root.pm:359 > STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::create /usr/lib/ > perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:206 > STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::store /usr/lib/ > perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:251 > STACK: Bio::DB::Persistent::PersistentObject::store /usr/lib/perl5/ > site_perl/5.8.8/Bio/DB/Persistent/PersistentObject.pm:271 > STACK: main::persist_term ./scripts/biosql/load_ontology.pl:802 > STACK: ./scripts/biosql/load_ontology.pl:607 > ----------------------------------------------------------- > > at ./scripts/biosql/load_ontology.pl line 814 > main::persist_term('-term', 'Bio::Ontology::OBOterm=HASH > (0xa1b502c)', '-db', 'Bio::DB::BioSQL::DBAdaptor=HASH(0x8ba793c)', > '-termfactory', 'undef', '-throw', 'CODE(0x87406d8)', '- > mergeobs', ...) called at ./scripts/biosql/load_ontology.pl line 607 -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From andreas.draeger at uni-tuebingen.de Wed May 7 13:29:18 2008 From: andreas.draeger at uni-tuebingen.de (=?ISO-8859-1?Q?Andreas_Dr=E4ger?=) Date: Wed, 07 May 2008 15:29:18 +0200 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL Message-ID: <4821AEAE.5010205@uni-tuebingen.de> Dear all, Unfortunately, I am still having trouble while loading the Gene Ontology into my BioSQL database. I installed BioSQL, downloaded the file gene_ontology_edit.obo from the Gene Ontology homepage (http://www.geneontology.org/GO.downloads.ontology.shtml), installed the BioPerl package bioperl-db-1.5.2_100 as described in the INSTALL file and tried the following: ./scripts/biosql/load_ontology.pl \ --host localhost --dbname biosql \ --dbuser myUser \ --dbpass 'myPassword' \ --driver mysql \ --namespace "Gene Ontology" \ --format obo \ gene_ontology_edit.obo I received the following error message: Bio::OntologyIO: obo cannot be found Exception ------------- EXCEPTION ------------- MSG: Failed to load module Bio::OntologyIO::obo. Can't locate Bio/OntologyIO/obo.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm line 394. STACK Bio::Root::Root::_load_module /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm:396 STACK (eval) /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:255 STACK Bio::OntologyIO::_load_format_module /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:254 STACK Bio::OntologyIO::new /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:165 STACK toplevel ./scripts/biosql/load_ontology.pl:525 -------------------------------------- For more information about the OntologyIO system please see the docs. This includes ways of checking for formats at compile time, not run time Can't call method "term_factory" on an undefined value at ./scripts/biosql/load_ontology.pl line 531. [root at u-172-c052 bioperl-db-1.5.2_100]# vim scripts/biosql/load_ontology.pl I am grateful for any hint what I can do to solve this problem and to store the GO in my database. Cheers, Andreas From andreas.draeger at uni-tuebingen.de Wed May 7 14:58:05 2008 From: andreas.draeger at uni-tuebingen.de (=?ISO-8859-1?Q?Andreas_Dr=E4ger?=) Date: Wed, 07 May 2008 16:58:05 +0200 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL Message-ID: <4821C37D.7050105@uni-tuebingen.de> Dear all, Unfortunately, I am still having trouble while loading the Gene Ontology into my BioSQL database. I installed BioSQL, downloaded the file gene_ontology_edit.obo from the Gene Ontology homepage (http://www.geneontology.org/GO.downloads.ontology.shtml), installed the BioPerl package bioperl-db-1.5.2_100 as described in the INSTALL file and tried the following: ./scripts/biosql/load_ontology.pl \ --host localhost --dbname biosql \ --dbuser myUser \ --dbpass 'myPassword' \ --driver mysql \ --namespace "Gene Ontology" \ --format obo \ gene_ontology_edit.obo I received the following error message: Bio::OntologyIO: obo cannot be found Exception ------------- EXCEPTION ------------- MSG: Failed to load module Bio::OntologyIO::obo. Can't locate Bio/OntologyIO/obo.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm line 394. STACK Bio::Root::Root::_load_module /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm:396 STACK (eval) /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:255 STACK Bio::OntologyIO::_load_format_module /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:254 STACK Bio::OntologyIO::new /usr/lib/perl5/site_perl/5.8.8/Bio/OntologyIO.pm:165 STACK toplevel ./scripts/biosql/load_ontology.pl:525 -------------------------------------- For more information about the OntologyIO system please see the docs. This includes ways of checking for formats at compile time, not run time Can't call method "term_factory" on an undefined value at ./scripts/biosql/load_ontology.pl line 531. [root at u-172-c052 bioperl-db-1.5.2_100]# vim scripts/biosql/load_ontology.pl I am grateful for any hint what I can do to solve this problem and to store the GO in my database. Cheers, Andreas From andreas.draeger at uni-tuebingen.de Thu May 8 08:52:10 2008 From: andreas.draeger at uni-tuebingen.de (=?ISO-8859-1?Q?Andreas_Dr=E4ger?=) Date: Thu, 08 May 2008 10:52:10 +0200 Subject: [BioSQL-l] Problem when trying to persist GO in BioSQL In-Reply-To: References: <4821C37D.7050105@uni-tuebingen.de> Message-ID: <4822BF3A.2020305@uni-tuebingen.de> Dear all, Thank you for your advice! Now it works, but not completely. It seems that there is either a problem with the ontology file I downloaded from GO (gene_ontology_edit.obo) or an error in the script: ./scripts/biosql/load_ontology.pl --host localhost --dbname bioseqdb --dbuser myUser --dbpass 'myPasswd' --driver mysql --namespace "Gene Ontology" --format obo gene_ontology_edit.obo And it works: Loading ontology gene_ontology: ... terms ... relationships Done with gene_ontology. Loading ontology biological_process: ... terms But then I receive the following messages: -------------------- WARNING --------------------- MSG: insert in Bio::DB::BioSQL::TermAdaptor (driver) failed, values were ("GO:0007125","invasive growth","OBSOLETE (was not defined before being made obsolete).","X","") FKs (46) Duplicate entry 'invasive growth-46-X' for key 3 --------------------------------------------------- Could not store term GO:0007125, name 'invasive growth': ------------- EXCEPTION: Bio::Root::Exception ------------- MSG: create: object (Bio::Ontology::OBOterm) failed to insert or to be found by unique key STACK: Error::throw STACK: Bio::Root::Root::throw /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm:359 STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::create /usr/lib/perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:206 STACK: Bio::DB::BioSQL::BasePersistenceAdaptor::store /usr/lib/perl5/site_perl/5.8.8/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:251 STACK: Bio::DB::Persistent::PersistentObject::store /usr/lib/perl5/site_perl/5.8.8/Bio/DB/Persistent/PersistentObject.pm:271 STACK: main::persist_term ./scripts/biosql/load_ontology.pl:802 STACK: ./scripts/biosql/load_ontology.pl:607 ----------------------------------------------------------- at ./scripts/biosql/load_ontology.pl line 814 main::persist_term('-term', 'Bio::Ontology::OBOterm=HASH(0xa1b502c)', '-db', 'Bio::DB::BioSQL::DBAdaptor=HASH(0x8ba793c)', '-termfactory', 'undef', '-throw', 'CODE(0x87406d8)', '-mergeobs', ...) called at ./scripts/biosql/load_ontology.pl line 607 From gwu at molbio.mgh.harvard.edu Tue May 20 18:03:35 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Tue, 20 May 2008 14:03:35 -0400 Subject: [BioSQL-l] Load/Update Genbank sequence issue Message-ID: <48331277.7060105@molbio.mgh.harvard.edu> Hi all, I'm trying to load Genbank sequence into BioSQL database with BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the exception when loading new sequences or reloading the same sequence. Seems the Hibernate is trying to insert "genbank" namespace again. Can anybody tell me what I did wrong? Thanks in advance. Gang ================================================================ public class SequenceLoaderNew { public void loadSeq(String fileName, String namespace) throws FileNotFoundException, BioException { System.out.println("Start loading file " + fileName + " at " + System.currentTimeMillis()); BufferedReader br = new BufferedReader(new FileReader(fileName)); Session session = new Configuration().configure().buildSessionFactory().openSession(); RichObjectFactory.connectToBioSQL(session); RichSequenceDB db = new BioSQLRichSequenceDB(session); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new SimpleNamespace(namespace)); while (rsi.hasNext()) { Transaction tx = session.beginTransaction(); RichSequence sequence = rsi.nextRichSequence(); System.out.println("Loaded sequence" + sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); try { System.out.println("Delete sequence" + sequence.getAccession() + " if exists."); db.removeSequence(sequence.getAccession()); } catch (Exception ex) { } try { System.out.println("Save sequence " + sequence.getAccession()); session.save("BioEntry", sequence); tx.commit(); session.flush(); session.clear(); } catch (HibernateException ex) { tx.rollback(); ex.printStackTrace(); } } } public static void main(String[] args) throws BioException, FileNotFoundException { SequenceLoaderNew sl = new SequenceLoaderNew(); //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); } } ================================================================ org.hibernate.exception.ConstraintViolationException: could not insert: [Namespace] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry 'genbank' for key 'name' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) ... 31 more ================================================================ From gwu at molbio.mgh.harvard.edu Tue May 20 18:37:18 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Tue, 20 May 2008 14:37:18 -0400 Subject: [BioSQL-l] Load, Update Genbank sequence issue Message-ID: <48331A5E.9020908@molbio.mgh.harvard.edu> Hi all, I'm trying to load Genbank sequence into BioSQL database with BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the exception when loading new sequences or reloading the same sequence. Seems the Hibernate is trying to insert "genbank" namespace again. Can anybody tell me what I did wrong? Thanks in advance. Gang ================================================================ public class SequenceLoaderNew { public void loadSeq(String fileName, String namespace) throws FileNotFoundException, BioException { System.out.println("Start loading file " + fileName + " at " + System.currentTimeMillis()); BufferedReader br = new BufferedReader(new FileReader(fileName)); Session session = new Configuration().configure().buildSessionFactory().openSession(); RichObjectFactory.connectToBioSQL(session); RichSequenceDB db = new BioSQLRichSequenceDB(session); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new SimpleNamespace(namespace)); while (rsi.hasNext()) { Transaction tx = session.beginTransaction(); RichSequence sequence = rsi.nextRichSequence(); System.out.println("Loaded sequence" + sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); try { System.out.println("Delete sequence" + sequence.getAccession() + " if exists."); db.removeSequence(sequence.getAccession()); } catch (Exception ex) { } try { System.out.println("Save sequence " + sequence.getAccession()); session.save("BioEntry", sequence); tx.commit(); session.flush(); session.clear(); } catch (HibernateException ex) { tx.rollback(); ex.printStackTrace(); } } } public static void main(String[] args) throws BioException, FileNotFoundException { SequenceLoaderNew sl = new SequenceLoaderNew(); //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); } } ================================================================ org.hibernate.exception.ConstraintViolationException: could not insert: [Namespace] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry 'genbank' for key 'name' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) ... 31 more ================================================================ From dicknetherlands at gmail.com Tue May 20 18:44:09 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Tue, 20 May 2008 19:44:09 +0100 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> Message-ID: Forgot to copy my reply back to the lists! ---------- Forwarded message ---------- From: Richard Holland Date: 2008/5/20 Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue To: gang wu You need to substitute this line: RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new SimpleNamespace(namespace)); with this line: Namespace ns = (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new Object[]{namespace}); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); cheers, Richard PS. You're the second person who has quoted this section of code on this list recently, and had the same problem with it. If you got it from a website somewhere, could you send me the URL so I can get in touch with the authors and get them to correct it? Thanks! 2008/5/20 gang wu : > Hi all, > > I'm trying to load Genbank sequence into BioSQL database with > BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the > exception when loading new sequences or reloading the same sequence. Seems > the Hibernate is trying to insert "genbank" namespace again. Can anybody > tell me what I did wrong? Thanks in advance. > > Gang > > ================================================================ > public class SequenceLoaderNew { > public void loadSeq(String fileName, String namespace) throws > FileNotFoundException, BioException { > System.out.println("Start loading file " + fileName + " at " + > System.currentTimeMillis()); > BufferedReader br = new BufferedReader(new FileReader(fileName)); > Session session = new > Configuration().configure().buildSessionFactory().openSession(); > RichObjectFactory.connectToBioSQL(session); > RichSequenceDB db = new BioSQLRichSequenceDB(session); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new > SimpleNamespace(namespace)); > while (rsi.hasNext()) { > Transaction tx = session.beginTransaction(); > RichSequence sequence = rsi.nextRichSequence(); > System.out.println("Loaded sequence" + sequence.getAccession() + > ", identifier: " + sequence.getIdentifier()); > try { > System.out.println("Delete sequence" + sequence.getAccession() > + " if exists."); > db.removeSequence(sequence.getAccession()); > } catch (Exception ex) { > } > try { > System.out.println("Save sequence " + > sequence.getAccession()); > session.save("BioEntry", sequence); > tx.commit(); > session.flush(); > session.clear(); > } catch (HibernateException ex) { > tx.rollback(); > ex.printStackTrace(); > } > } > } > > public static void main(String[] args) throws BioException, > FileNotFoundException { > SequenceLoaderNew sl = new SequenceLoaderNew(); > //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); > sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); > } > } > ================================================================ > org.hibernate.exception.ConstraintViolationException: could not insert: > [Namespace] > at > org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) > at > org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) > at > org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) > at > org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) > at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) > at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) > at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) > at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) > Caused by: > com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: > Duplicate entry 'genbank' for key 'name' > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) > at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) > at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) > at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) > at > com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) > at > com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) > at > com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) > at > com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) > at > org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) > at > org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) > ... 31 more > ================================================================ > > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From gwu at molbio.mgh.harvard.edu Wed May 21 06:28:16 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Wed, 21 May 2008 02:28:16 -0400 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> Message-ID: <4833C100.7040304@molbio.mgh.harvard.edu> I got another problem with almost the same code(see attached code and output). If I call the loadSeq() only once, everything works fine. The second call of the same method will fail. By the exception message, it looks like the session is not cleaned up yet though at the end of the method the session has been flush/clear/closed. Anything wrong? Or does anyone have a sequence data loader would like to share? I'm quite frustrated after keeping trying to do this seems simple thing without success. If I can make it work, I'd like to post it on the mailing list. Thanks in advance. Gang ==================================================== public class SequenceLoaderNew { public void loadSeq(String fileName, String namespace) throws FileNotFoundException, BioException, SQLException, InterruptedException { SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session = sessionFactory.openSession(); RichObjectFactory.connectToBioSQL(session); Namespace ns = (Namespace) RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); RichSequenceDB db = new BioSQLRichSequenceDB(session); System.out.println("Start loading file " + fileName + " at " + System.currentTimeMillis()); BufferedReader br = new BufferedReader(new FileReader(fileName)); RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); try { while (rsi.hasNext()) { RichSequence sequence = rsi.nextRichSequence(); System.out.println("Loaded sequence" + sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); Transaction tx = session.beginTransaction(); try { System.out.println("Delete sequence" + sequence.getAccession() + " if exists."); db.removeSequence(sequence.getAccession()); tx.commit(); session.flush(); session.clear(); } catch (Exception ex) { if (tx != null) { tx.rollback(); } } try { tx = session.beginTransaction(); System.out.println("Save sequence " + sequence.getAccession()); //session.save("BioEntry", sequence); //db.addSequence(sequence); db.addRichSequence(sequence); tx.commit(); System.out.println("Finished savig sequence " + sequence.getAccession() + "\n"); } catch (HibernateException ex) { tx.rollback(); ex.printStackTrace(); } } } finally { session.flush(); session.clear(); session.close(); } } public static void main(String[] args) throws BioException, FileNotFoundException, InterruptedException, SQLException { SequenceLoaderNew sl = new SequenceLoaderNew(); sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); } } ==================================================== Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 Loaded sequenceNC_005813, identifier: 45478502 Delete sequenceNC_005813 if exists. Save sequence NC_005813 Finished savig sequence NC_005813 Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 Loaded sequenceNC_005813, identifier: 45478502 Delete sequenceNC_005813 if exists. Save sequence NC_005813 org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Term#20] at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) Exception in thread "main" org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Term#19] at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) at org.hibernate.engine.Cascade.cascade(Cascade.java:130) at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) ==================================================== Richard Holland wrote: > Forgot to copy my reply back to the lists! > > > ---------- Forwarded message ---------- > From: Richard Holland > Date: 2008/5/20 > Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue > To: gang wu > > > You need to substitute this line: > > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new > SimpleNamespace(namespace)); > > with this line: > > Namespace ns = (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new > Object[]{namespace}); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); > > cheers, > Richard > > PS. You're the second person who has quoted this section of code on > this list recently, and had the same problem with it. If you got it > from a website somewhere, could you send me the URL so I can get in > touch with the authors and get them to correct it? Thanks! > > 2008/5/20 gang wu : > >> Hi all, >> >> I'm trying to load Genbank sequence into BioSQL database with >> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >> exception when loading new sequences or reloading the same sequence. Seems >> the Hibernate is trying to insert "genbank" namespace again. Can anybody >> tell me what I did wrong? Thanks in advance. >> >> Gang >> >> ================================================================ >> public class SequenceLoaderNew { >> public void loadSeq(String fileName, String namespace) throws >> FileNotFoundException, BioException { >> System.out.println("Start loading file " + fileName + " at " + >> System.currentTimeMillis()); >> BufferedReader br = new BufferedReader(new FileReader(fileName)); >> Session session = new >> Configuration().configure().buildSessionFactory().openSession(); >> RichObjectFactory.connectToBioSQL(session); >> RichSequenceDB db = new BioSQLRichSequenceDB(session); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >> SimpleNamespace(namespace)); >> while (rsi.hasNext()) { >> Transaction tx = session.beginTransaction(); >> RichSequence sequence = rsi.nextRichSequence(); >> System.out.println("Loaded sequence" + sequence.getAccession() + >> ", identifier: " + sequence.getIdentifier()); >> try { >> System.out.println("Delete sequence" + sequence.getAccession() >> + " if exists."); >> db.removeSequence(sequence.getAccession()); >> } catch (Exception ex) { >> } >> try { >> System.out.println("Save sequence " + >> sequence.getAccession()); >> session.save("BioEntry", sequence); >> tx.commit(); >> session.flush(); >> session.clear(); >> } catch (HibernateException ex) { >> tx.rollback(); >> ex.printStackTrace(); >> } >> } >> } >> >> public static void main(String[] args) throws BioException, >> FileNotFoundException { >> SequenceLoaderNew sl = new SequenceLoaderNew(); >> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >> } >> } >> ================================================================ >> org.hibernate.exception.ConstraintViolationException: could not insert: >> [Namespace] >> at >> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >> at >> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >> at >> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >> at >> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >> at >> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >> at >> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >> Caused by: >> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >> Duplicate entry 'genbank' for key 'name' >> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >> at >> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >> at >> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >> at >> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >> at >> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >> at >> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >> at >> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >> ... 31 more >> ================================================================ >> >> _______________________________________________ >> BioSQL-l mailing list >> BioSQL-l at lists.open-bio.org >> http://lists.open-bio.org/mailman/listinfo/biosql-l >> >> From dicknetherlands at gmail.com Wed May 21 17:17:39 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Wed, 21 May 2008 18:17:39 +0100 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: <4833C100.7040304@molbio.mgh.harvard.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: I'm not sure why you'd want to do that? Either way, as far as I know, Hibernate sessions are not designed for that. If you want to delete the sequence then replace it with a completely new sequence object, you have to create a new sequence object - you can't reuse the one you just deleted. The session info is embedded into that object so even if you clear the session, the object still refers to it. If you just want to load a sequence, modify it, then save it back, you should just load it then use saveOrUpdate to save it back again with changes. If you want to replace objects in your database, don't load them, just delete them, then use save to create new objects in their place. cheers, Richard 2008/5/21 gang wu : > I got another problem with almost the same code(see attached code and > output). If I call the loadSeq() only once, everything works fine. The > second call of the same method will fail. By the exception message, it looks > like the session is not cleaned up yet though at the end of the method the > session has been flush/clear/closed. Anything wrong? > > Or does anyone have a sequence data loader would like to share? I'm quite > frustrated after keeping trying to do this seems simple thing without > success. If I can make it work, I'd like to post it on the mailing list. > Thanks in advance. > > Gang > > ==================================================== > public class SequenceLoaderNew { > public void loadSeq(String fileName, String namespace) throws > FileNotFoundException, BioException, SQLException, InterruptedException { > SessionFactory sessionFactory = new > Configuration().configure().buildSessionFactory(); > Session session = sessionFactory.openSession(); > RichObjectFactory.connectToBioSQL(session); > Namespace ns = (Namespace) > RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); > RichSequenceDB db = new BioSQLRichSequenceDB(session); > System.out.println("Start loading file " + fileName + " at " + > System.currentTimeMillis()); > BufferedReader br = new BufferedReader(new FileReader(fileName)); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, > ns); > try { > while (rsi.hasNext()) { > RichSequence sequence = rsi.nextRichSequence(); > System.out.println("Loaded sequence" + sequence.getAccession() > + ", identifier: " + sequence.getIdentifier()); > Transaction tx = session.beginTransaction(); > try { > System.out.println("Delete sequence" + > sequence.getAccession() + " if exists."); > db.removeSequence(sequence.getAccession()); > tx.commit(); > session.flush(); > session.clear(); > } catch (Exception ex) { > if (tx != null) { > tx.rollback(); > } > } > try { > tx = session.beginTransaction(); > System.out.println("Save sequence " + > sequence.getAccession()); > //session.save("BioEntry", sequence); > //db.addSequence(sequence); > db.addRichSequence(sequence); > tx.commit(); > System.out.println("Finished savig sequence " + > sequence.getAccession() + "\n"); > } catch (HibernateException ex) { > tx.rollback(); > ex.printStackTrace(); > } > } > } finally { > session.flush(); > session.clear(); > session.close(); > } > } > > public static void main(String[] args) throws BioException, > FileNotFoundException, InterruptedException, SQLException { > SequenceLoaderNew sl = new SequenceLoaderNew(); > sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); > sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); > } > } > ==================================================== > Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 > Loaded sequenceNC_005813, identifier: 45478502 > Delete sequenceNC_005813 if exists. > Save sequence NC_005813 > Finished savig sequence NC_005813 > > Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 > Loaded sequenceNC_005813, identifier: 45478502 > Delete sequenceNC_005813 if exists. > Save sequence NC_005813 > org.hibernate.NonUniqueObjectException: a different object with the same > identifier value was already associated with the session: [Term#20] > at > org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at > org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) > at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) > at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) > at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) > at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) > Exception in thread "main" org.hibernate.NonUniqueObjectException: a > different object with the same identifier value was already associated with > the session: [Term#19] > at > org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) > at > org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) > at > org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) > at > org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) > at > org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at > org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at > org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) > at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at > org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) > at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) > at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) > at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) > at org.hibernate.engine.Cascade.cascade(Cascade.java:130) > at > org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) > at > org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) > at > org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) > at > org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) > at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) > at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) > at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) > ==================================================== > > Richard Holland wrote: >> >> Forgot to copy my reply back to the lists! >> >> >> ---------- Forwarded message ---------- >> From: Richard Holland >> Date: 2008/5/20 >> Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue >> To: gang wu >> >> >> You need to substitute this line: >> >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >> SimpleNamespace(namespace)); >> >> with this line: >> >> Namespace ns = >> (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new >> Object[]{namespace}); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); >> >> cheers, >> Richard >> >> PS. You're the second person who has quoted this section of code on >> this list recently, and had the same problem with it. If you got it >> from a website somewhere, could you send me the URL so I can get in >> touch with the authors and get them to correct it? Thanks! >> >> 2008/5/20 gang wu : >> >>> >>> Hi all, >>> >>> I'm trying to load Genbank sequence into BioSQL database with >>> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >>> exception when loading new sequences or reloading the same sequence. >>> Seems >>> the Hibernate is trying to insert "genbank" namespace again. Can anybody >>> tell me what I did wrong? Thanks in advance. >>> >>> Gang >>> >>> ================================================================ >>> public class SequenceLoaderNew { >>> public void loadSeq(String fileName, String namespace) throws >>> FileNotFoundException, BioException { >>> System.out.println("Start loading file " + fileName + " at " + >>> System.currentTimeMillis()); >>> BufferedReader br = new BufferedReader(new FileReader(fileName)); >>> Session session = new >>> Configuration().configure().buildSessionFactory().openSession(); >>> RichObjectFactory.connectToBioSQL(session); >>> RichSequenceDB db = new BioSQLRichSequenceDB(session); >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >>> new >>> SimpleNamespace(namespace)); >>> while (rsi.hasNext()) { >>> Transaction tx = session.beginTransaction(); >>> RichSequence sequence = rsi.nextRichSequence(); >>> System.out.println("Loaded sequence" + sequence.getAccession() + >>> ", identifier: " + sequence.getIdentifier()); >>> try { >>> System.out.println("Delete sequence" + >>> sequence.getAccession() >>> + " if exists."); >>> db.removeSequence(sequence.getAccession()); >>> } catch (Exception ex) { >>> } >>> try { >>> System.out.println("Save sequence " + >>> sequence.getAccession()); >>> session.save("BioEntry", sequence); >>> tx.commit(); >>> session.flush(); >>> session.clear(); >>> } catch (HibernateException ex) { >>> tx.rollback(); >>> ex.printStackTrace(); >>> } >>> } >>> } >>> >>> public static void main(String[] args) throws BioException, >>> FileNotFoundException { >>> SequenceLoaderNew sl = new SequenceLoaderNew(); >>> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >>> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >>> } >>> } >>> ================================================================ >>> org.hibernate.exception.ConstraintViolationException: could not insert: >>> [Namespace] >>> at >>> >>> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >>> at >>> >>> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >>> at >>> >>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >>> at >>> >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >>> at >>> >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >>> at >>> >>> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>> at >>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >>> at >>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>> at >>> >>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>> at >>> >>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>> at >>> >>> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >>> at >>> >>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >>> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >>> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >>> Caused by: >>> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >>> Duplicate entry 'genbank' for key 'name' >>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >>> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >>> at >>> >>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >>> at >>> >>> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >>> at >>> >>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >>> ... 31 more >>> ================================================================ >>> >>> _______________________________________________ >>> BioSQL-l mailing list >>> BioSQL-l at lists.open-bio.org >>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>> >>> > > From gwu at molbio.mgh.harvard.edu Wed May 21 18:12:36 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Wed, 21 May 2008 14:12:36 -0400 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: <48346614.6060102@molbio.mgh.harvard.edu> The scenario is quite simple: I'm using the database to store Genbank genome sequences. Later I've to update the sequences when Genbank has newer releases. The following two lines are loading the same sequence twice. The first time will insert a new BioEntry record. the second time will delete the existing record and insert a new record again. sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); Following code is used to load multiple genome sequences by calling the loadSeq() method multiple times. All failed except the first time. sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_006723.gbk", "genbank"); sl.loadSeq("/genomeseq/bacteria/NC_008945.gbk", "genbank"); The exception message has the details. Since all variables used in loadSeq() are local, and I did the session flush/clear/close, then it should be ok to call the method again. Thank you very much for your help. Gang Richard Holland wrote: > I'm not sure why you'd want to do that? Either way, as far as I know, > Hibernate sessions are not designed for that. If you want to delete > the sequence then replace it with a completely new sequence object, > you have to create a new sequence object - you can't reuse the one you > just deleted. The session info is embedded into that object so even if > you clear the session, the object still refers to it. > > If you just want to load a sequence, modify it, then save it back, you > should just load it then use saveOrUpdate to save it back again with > changes. If you want to replace objects in your database, don't load > them, just delete them, then use save to create new objects in their > place. > > cheers, > Richard > > 2008/5/21 gang wu : > >> I got another problem with almost the same code(see attached code and >> output). If I call the loadSeq() only once, everything works fine. The >> second call of the same method will fail. By the exception message, it looks >> like the session is not cleaned up yet though at the end of the method the >> session has been flush/clear/closed. Anything wrong? >> >> Or does anyone have a sequence data loader would like to share? I'm quite >> frustrated after keeping trying to do this seems simple thing without >> success. If I can make it work, I'd like to post it on the mailing list. >> Thanks in advance. >> >> Gang >> >> ==================================================== >> public class SequenceLoaderNew { >> public void loadSeq(String fileName, String namespace) throws >> FileNotFoundException, BioException, SQLException, InterruptedException { >> SessionFactory sessionFactory = new >> Configuration().configure().buildSessionFactory(); >> Session session = sessionFactory.openSession(); >> RichObjectFactory.connectToBioSQL(session); >> Namespace ns = (Namespace) >> RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); >> RichSequenceDB db = new BioSQLRichSequenceDB(session); >> System.out.println("Start loading file " + fileName + " at " + >> System.currentTimeMillis()); >> BufferedReader br = new BufferedReader(new FileReader(fileName)); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >> ns); >> try { >> while (rsi.hasNext()) { >> RichSequence sequence = rsi.nextRichSequence(); >> System.out.println("Loaded sequence" + sequence.getAccession() >> + ", identifier: " + sequence.getIdentifier()); >> Transaction tx = session.beginTransaction(); >> try { >> System.out.println("Delete sequence" + >> sequence.getAccession() + " if exists."); >> db.removeSequence(sequence.getAccession()); >> tx.commit(); >> session.flush(); >> session.clear(); >> } catch (Exception ex) { >> if (tx != null) { >> tx.rollback(); >> } >> } >> try { >> tx = session.beginTransaction(); >> System.out.println("Save sequence " + >> sequence.getAccession()); >> //session.save("BioEntry", sequence); >> //db.addSequence(sequence); >> db.addRichSequence(sequence); >> tx.commit(); >> System.out.println("Finished savig sequence " + >> sequence.getAccession() + "\n"); >> } catch (HibernateException ex) { >> tx.rollback(); >> ex.printStackTrace(); >> } >> } >> } finally { >> session.flush(); >> session.clear(); >> session.close(); >> } >> } >> >> public static void main(String[] args) throws BioException, >> FileNotFoundException, InterruptedException, SQLException { >> SequenceLoaderNew sl = new SequenceLoaderNew(); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> } >> } >> ==================================================== >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> Finished savig sequence NC_005813 >> >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> org.hibernate.NonUniqueObjectException: a different object with the same >> identifier value was already associated with the session: [Term#20] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> Exception in thread "main" org.hibernate.NonUniqueObjectException: a >> different object with the same identifier value was already associated with >> the session: [Term#19] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) >> at >> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) >> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> ==================================================== >> >> Richard Holland wrote: >> >>> Forgot to copy my reply back to the lists! >>> >>> >>> ---------- Forwarded message ---------- >>> From: Richard Holland >>> Date: 2008/5/20 >>> Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue >>> To: gang wu >>> >>> >>> You need to substitute this line: >>> >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >>> SimpleNamespace(namespace)); >>> >>> with this line: >>> >>> Namespace ns = >>> (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new >>> Object[]{namespace}); >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); >>> >>> cheers, >>> Richard >>> >>> PS. You're the second person who has quoted this section of code on >>> this list recently, and had the same problem with it. If you got it >>> from a website somewhere, could you send me the URL so I can get in >>> touch with the authors and get them to correct it? Thanks! >>> >>> 2008/5/20 gang wu : >>> >>> >>>> Hi all, >>>> >>>> I'm trying to load Genbank sequence into BioSQL database with >>>> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >>>> exception when loading new sequences or reloading the same sequence. >>>> Seems >>>> the Hibernate is trying to insert "genbank" namespace again. Can anybody >>>> tell me what I did wrong? Thanks in advance. >>>> >>>> Gang >>>> >>>> ================================================================ >>>> public class SequenceLoaderNew { >>>> public void loadSeq(String fileName, String namespace) throws >>>> FileNotFoundException, BioException { >>>> System.out.println("Start loading file " + fileName + " at " + >>>> System.currentTimeMillis()); >>>> BufferedReader br = new BufferedReader(new FileReader(fileName)); >>>> Session session = new >>>> Configuration().configure().buildSessionFactory().openSession(); >>>> RichObjectFactory.connectToBioSQL(session); >>>> RichSequenceDB db = new BioSQLRichSequenceDB(session); >>>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >>>> new >>>> SimpleNamespace(namespace)); >>>> while (rsi.hasNext()) { >>>> Transaction tx = session.beginTransaction(); >>>> RichSequence sequence = rsi.nextRichSequence(); >>>> System.out.println("Loaded sequence" + sequence.getAccession() + >>>> ", identifier: " + sequence.getIdentifier()); >>>> try { >>>> System.out.println("Delete sequence" + >>>> sequence.getAccession() >>>> + " if exists."); >>>> db.removeSequence(sequence.getAccession()); >>>> } catch (Exception ex) { >>>> } >>>> try { >>>> System.out.println("Save sequence " + >>>> sequence.getAccession()); >>>> session.save("BioEntry", sequence); >>>> tx.commit(); >>>> session.flush(); >>>> session.clear(); >>>> } catch (HibernateException ex) { >>>> tx.rollback(); >>>> ex.printStackTrace(); >>>> } >>>> } >>>> } >>>> >>>> public static void main(String[] args) throws BioException, >>>> FileNotFoundException { >>>> SequenceLoaderNew sl = new SequenceLoaderNew(); >>>> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >>>> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >>>> } >>>> } >>>> ================================================================ >>>> org.hibernate.exception.ConstraintViolationException: could not insert: >>>> [Namespace] >>>> at >>>> >>>> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >>>> at >>>> >>>> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >>>> at >>>> >>>> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at >>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >>>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >>>> at >>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >>>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >>>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >>>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >>>> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >>>> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >>>> Caused by: >>>> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >>>> Duplicate entry 'genbank' for key 'name' >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >>>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >>>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >>>> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >>>> at >>>> >>>> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >>>> ... 31 more >>>> ================================================================ >>>> >>>> _______________________________________________ >>>> BioSQL-l mailing list >>>> BioSQL-l at lists.open-bio.org >>>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>>> >>>> >>>> >> From dicknetherlands at gmail.com Wed May 21 18:40:41 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Wed, 21 May 2008 19:40:41 +0100 Subject: [BioSQL-l] Load/Update Genbank sequence issue In-Reply-To: References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: Sorry, I misread the original question. My bad. What it actually seems that you're doing is simply iterating through a genbank file, deleting from the db that already exist, then replacing them with members from the file. Looking more closely it seems that it is complaining about duplicated Term objects, probably because the cache is getting confused with all this flushing and clearing. Have you tried running this code without flushing and clearing the session? If not, try also inserting If that didn't work, then after each call to flush(), insert a RichObjectFactory.clearLRUCache() call. That really will completely clear memory of all objects from the database. cheers, Richard 2008/5/21 Richard Holland : > I'm not sure why you'd want to do that? Either way, as far as I know, > Hibernate sessions are not designed for that. If you want to delete > the sequence then replace it with a completely new sequence object, > you have to create a new sequence object - you can't reuse the one you > just deleted. The session info is embedded into that object so even if > you clear the session, the object still refers to it. > > If you just want to load a sequence, modify it, then save it back, you > should just load it then use saveOrUpdate to save it back again with > changes. If you want to replace objects in your database, don't load > them, just delete them, then use save to create new objects in their > place. > > cheers, > Richard > > 2008/5/21 gang wu : >> I got another problem with almost the same code(see attached code and >> output). If I call the loadSeq() only once, everything works fine. The >> second call of the same method will fail. By the exception message, it looks >> like the session is not cleaned up yet though at the end of the method the >> session has been flush/clear/closed. Anything wrong? >> >> Or does anyone have a sequence data loader would like to share? I'm quite >> frustrated after keeping trying to do this seems simple thing without >> success. If I can make it work, I'd like to post it on the mailing list. >> Thanks in advance. >> >> Gang >> >> ==================================================== >> public class SequenceLoaderNew { >> public void loadSeq(String fileName, String namespace) throws >> FileNotFoundException, BioException, SQLException, InterruptedException { >> SessionFactory sessionFactory = new >> Configuration().configure().buildSessionFactory(); >> Session session = sessionFactory.openSession(); >> RichObjectFactory.connectToBioSQL(session); >> Namespace ns = (Namespace) >> RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); >> RichSequenceDB db = new BioSQLRichSequenceDB(session); >> System.out.println("Start loading file " + fileName + " at " + >> System.currentTimeMillis()); >> BufferedReader br = new BufferedReader(new FileReader(fileName)); >> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >> ns); >> try { >> while (rsi.hasNext()) { >> RichSequence sequence = rsi.nextRichSequence(); >> System.out.println("Loaded sequence" + sequence.getAccession() >> + ", identifier: " + sequence.getIdentifier()); >> Transaction tx = session.beginTransaction(); >> try { >> System.out.println("Delete sequence" + >> sequence.getAccession() + " if exists."); >> db.removeSequence(sequence.getAccession()); >> tx.commit(); >> session.flush(); >> session.clear(); >> } catch (Exception ex) { >> if (tx != null) { >> tx.rollback(); >> } >> } >> try { >> tx = session.beginTransaction(); >> System.out.println("Save sequence " + >> sequence.getAccession()); >> //session.save("BioEntry", sequence); >> //db.addSequence(sequence); >> db.addRichSequence(sequence); >> tx.commit(); >> System.out.println("Finished savig sequence " + >> sequence.getAccession() + "\n"); >> } catch (HibernateException ex) { >> tx.rollback(); >> ex.printStackTrace(); >> } >> } >> } finally { >> session.flush(); >> session.clear(); >> session.close(); >> } >> } >> >> public static void main(String[] args) throws BioException, >> FileNotFoundException, InterruptedException, SQLException { >> SequenceLoaderNew sl = new SequenceLoaderNew(); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >> } >> } >> ==================================================== >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349859602 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> Finished savig sequence NC_005813 >> >> Start loading file /genomeseq/bacteria/NC_005813.gbk at 1211349863761 >> Loaded sequenceNC_005813, identifier: 45478502 >> Delete sequenceNC_005813 if exists. >> Save sequence NC_005813 >> org.hibernate.NonUniqueObjectException: a different object with the same >> identifier value was already associated with the session: [Term#20] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:51) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> Exception in thread "main" org.hibernate.NonUniqueObjectException: a >> different object with the same identifier value was already associated with >> the session: [Term#19] >> at >> org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:284) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >> at >> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >> at >> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >> at >> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >> at >> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >> at >> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at >> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296) >> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242) >> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219) >> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122) >> at >> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) >> at >> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) >> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) >> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:60) >> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:69) >> ==================================================== >> >> Richard Holland wrote: >>> >>> Forgot to copy my reply back to the lists! >>> >>> >>> ---------- Forwarded message ---------- >>> From: Richard Holland >>> Date: 2008/5/20 >>> Subject: Re: [BioSQL-l] Load/Update Genbank sequence issue >>> To: gang wu >>> >>> >>> You need to substitute this line: >>> >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, new >>> SimpleNamespace(namespace)); >>> >>> with this line: >>> >>> Namespace ns = >>> (Namespace)RichObjectFactory.getObject(SimpleNamespace.class,new >>> Object[]{namespace}); >>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, ns); >>> >>> cheers, >>> Richard >>> >>> PS. You're the second person who has quoted this section of code on >>> this list recently, and had the same problem with it. If you got it >>> from a website somewhere, could you send me the URL so I can get in >>> touch with the authors and get them to correct it? Thanks! >>> >>> 2008/5/20 gang wu : >>> >>>> >>>> Hi all, >>>> >>>> I'm trying to load Genbank sequence into BioSQL database with >>>> BioJavax/Hibernate. It's Ok to load the first sequence. Then I got the >>>> exception when loading new sequences or reloading the same sequence. >>>> Seems >>>> the Hibernate is trying to insert "genbank" namespace again. Can anybody >>>> tell me what I did wrong? Thanks in advance. >>>> >>>> Gang >>>> >>>> ================================================================ >>>> public class SequenceLoaderNew { >>>> public void loadSeq(String fileName, String namespace) throws >>>> FileNotFoundException, BioException { >>>> System.out.println("Start loading file " + fileName + " at " + >>>> System.currentTimeMillis()); >>>> BufferedReader br = new BufferedReader(new FileReader(fileName)); >>>> Session session = new >>>> Configuration().configure().buildSessionFactory().openSession(); >>>> RichObjectFactory.connectToBioSQL(session); >>>> RichSequenceDB db = new BioSQLRichSequenceDB(session); >>>> RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA(br, >>>> new >>>> SimpleNamespace(namespace)); >>>> while (rsi.hasNext()) { >>>> Transaction tx = session.beginTransaction(); >>>> RichSequence sequence = rsi.nextRichSequence(); >>>> System.out.println("Loaded sequence" + sequence.getAccession() + >>>> ", identifier: " + sequence.getIdentifier()); >>>> try { >>>> System.out.println("Delete sequence" + >>>> sequence.getAccession() >>>> + " if exists."); >>>> db.removeSequence(sequence.getAccession()); >>>> } catch (Exception ex) { >>>> } >>>> try { >>>> System.out.println("Save sequence " + >>>> sequence.getAccession()); >>>> session.save("BioEntry", sequence); >>>> tx.commit(); >>>> session.flush(); >>>> session.clear(); >>>> } catch (HibernateException ex) { >>>> tx.rollback(); >>>> ex.printStackTrace(); >>>> } >>>> } >>>> } >>>> >>>> public static void main(String[] args) throws BioException, >>>> FileNotFoundException { >>>> SequenceLoaderNew sl = new SequenceLoaderNew(); >>>> //sl.loadSeq("/genomeseq/bacteria/NC_005813.gbk", "genbank"); >>>> sl.loadSeq("/genomeseq/bacteria/NC_004349.gbk", "genbank"); >>>> } >>>> } >>>> ================================================================ >>>> org.hibernate.exception.ConstraintViolationException: could not insert: >>>> [Namespace] >>>> at >>>> >>>> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) >>>> at >>>> >>>> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163) >>>> at >>>> >>>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643) >>>> at >>>> >>>> org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:51) >>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at >>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) >>>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) >>>> at >>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218) >>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268) >>>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216) >>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169) >>>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) >>>> at >>>> >>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) >>>> at >>>> >>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) >>>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) >>>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) >>>> at primerdb.SequenceLoaderNew.loadSeq(SequenceLoaderNew.java:38) >>>> at primerdb.SequenceLoaderNew.main(SequenceLoaderNew.java:52) >>>> Caused by: >>>> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: >>>> Duplicate entry 'genbank' for key 'name' >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011) >>>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) >>>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) >>>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) >>>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) >>>> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) >>>> at >>>> >>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) >>>> at >>>> >>>> org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) >>>> at >>>> >>>> org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) >>>> ... 31 more >>>> ================================================================ >>>> >>>> _______________________________________________ >>>> BioSQL-l mailing list >>>> BioSQL-l at lists.open-bio.org >>>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>>> >>>> >> >> > From dicknetherlands at gmail.com Thu May 22 21:07:23 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Thu, 22 May 2008 22:07:23 +0100 Subject: [BioSQL-l] [Biojava-l] Load/Update Genbank sequence issue In-Reply-To: <4835DAAE.6080609@molbio.mgh.harvard.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> <48346EE1.70004@unity.ncsu.edu> <4835DAAE.6080609@molbio.mgh.harvard.edu> Message-ID: Interesting stuff. Have you tried parsing those Arabidopsis files without persisting them? i.e. just running them through the parser without attaching anything to Hibernate. I'm wondering how much of the slowness is Hibernate, and how much is BioJava's own object model. cheers, Richard 2008/5/22 gang wu : > Hi Doug and Richard, > > Thanks for your reply. I've been following your suggestions and finding a > way that works for me. Basically, if there is anything in the code that > flush/clear the session, it's going to be a problem for the following calls > to the same method. I'm not sure if it's Hibernate bug or is like Richard > suggested that it is a feature. Attached is the code I am using to > load/update Genbank sequences. It could be easily generalized to load other > sequences(if the process works). > > Seems it works for me now(still running test on bigger sequences). It's > pretty fast to load those small bacteria sequences, usually 10-60 seconds. > But it seems it's getting choked with the bigger sequences. I started it > last night at about 11pm to load the 5 Arabidopsis thaliana genome > sequences(about 280MB total). The first one finished in about 1.5 hours and > it's stilling hanging there now on the second sequence. I saw a 100% CPU > usage and 2.6GB memory assigned for the program. The MySQL server is running > on the same server. The machine has 8GB RAM and 2 dual core exon CPUS > running at 3.73GHZ. > > Doug, I tested your code and seems the output is not always consistent: I > tried to load two sequences. Sometimes succeeded and sometimes failed. I > wonder it's still the session issue. I did not try with removing those > flush/clear code. > > Thanks again for your response. It really helps me out. I'll post my code > here if I work out a better solution. > > Gang > > Doug Brown wrote: > > Hi Gang wu, > > I recognize your problem. I to had to build a loader for genbank flat > files. When attempting to 'replace' a record stored in the database, one > needs to explicitly delete it before doing the save. I found that the > hibernate code does not seem to understand that an in-memory deletion should > be realized in the data base prior to the new insertion. My solution, see > attached code, was to commit the transaction for the deletion and then open > a new transaction for the insertion. > > Try inserting the following after "System.out.println("Loaded sequence"": > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name = > :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > // Interestingly, hibernate does not seem to do transactions in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > > Regards, > Doug > > gang wu wrote: > > I got another problem with almost the same code(see attached code and > output). If I call the loadSeq() only once, everything works fine. The > second call of the same method will fail. By the exception message, it looks > like the session is not cleaned up yet though at the end of the method the > session has been flush/clear/closed. Anything wrong? > > ________________________________ > // Copyright 2008, by North Carolina State University. All rights reserved. > > /** > * > * javac -cp > "C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" > bioinformatics\biojava\BriefLoader.java > * > * java -Xmx100m -cp > "c:\jars\asm.jar;c:\jars\asm-attrs.jar;c:\jars\cglib-2.1.3.jar;c:\jars\jta.jar;c:\jars\antlr-2.7.6.jar;c:\jars\commons-collections-2.1.1.jar;c:\jars\commons-logging-1.0.4.jar;c:\jars\dom4j-1.6.1.jar;C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" > -Djdbc.drivers=com.mysql.jdbc.Driver bioinformatics.biojava.BriefLoader > C:\WorkData\genomes\M_grisea_genbank_v5\CH476760.gb > */ > package bioinformatics.biojavaTools; > > import java.io.BufferedReader; > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileReader; > import java.io.IOException; > > import org.biojava.bio.BioException; > import org.biojavax.*; > import org.biojavax.RichObjectFactory; > import org.biojavax.bio.db.biosql.BioSQLRichSequenceDB; > import org.biojavax.bio.seq.*; > import org.biojavax.bio.seq.RichSequence.*; > import org.biojavax.bio.seq.RichSequence.IOTools; > import org.biojavax.bio.seq.io.*; > import org.biojavax.bio.BioEntry; > > import org.hibernate.*; > import org.hibernate.cfg.*; > > //import java.util.logging.*; > //import org.apache.commons.logging.*; > > > > > public class BriefLoader > { > static SessionFactory sessionFactory; > static boolean verbose = false; > public static void main(String[] args) > { > int argPos = 0; > if ( args.length > 0 && args[argPos].equals( "-v")) > { > verbose = true; > argPos++; > } > if ( argPos == args.length) > { > System.out.println( "Usage: BriefLoader [-v] file1.bg [file2.gb > ...]"); > return; > } > > BriefLoader bf = new BriefLoader(); > > // logging: > // I want to suppress the verbose info messages. > // After some investigation, it seems that commons > // logging uses a default of Jdk14Logger (the standard java logger). > // Thus, I can control the commons logger via the java.util.logging API. > // API > java.util.logging.Logger jdklogger = > java.util.logging.Logger.getLogger("org.hibernate"); > jdklogger.setLevel(java.util.logging.Level.WARNING); > > sessionFactory = new > // Configuration is very expensive and can only be done once. > // > // properties can be specified via the file hibernate.properties located > // on the classpath, > // on the command line via -D, > // via the defaut "hibernate.cfg.xml" file in the current working > directory, > // via an explicitly identified file, e.g. "specific_file.cfg.xml", > // via explicit calls to setProperty. The same goes for resources. > // Later definitions override earlier ones. > Configuration() > // Note: > // specifying the resource location of the configuration file > // works ONLY if I also modify the > // hibernate.cfg.xml file to add the class' package as a prefix > // for every resource. Hibernate does not understand the > // concept of relative locations based on the location of the > // configuratin file. Nonetheless, this allows me to organize the > // mapping files based on java packages. > .configure( bf.getClass().getResource( "hibernate.cfg.xml")) > // the following should allows use of a generic configuration file > // by overriding the items that need to be customized. > //.setProperty( "connection.url", > "jdbc:mysql://someMachine.ncsu.edu:3306/M_grisea_genbank_biosql") > //.setProperty( "connection.username", "aUser") > //.setProperty( "connection.password", "aPassword") > // > // The following can be used to adjust memory consumption. > //.setProperty( "hibernate.jdbc.batch_size", "20") > //.setProperty( "hibernate.cache.use_second_level_cache", "false") > // > // examining the generated SQL can be informative... > //.setProperty( "hibernate.show_sql", "true") > > // Go and make the support interfaces... > .buildSessionFactory(); > > Session session = null; > try > { > session = bf.doSessionFactoryBindings( sessionFactory); > > while ( argPos < args.length) > { > File f = new File( args[argPos++]); > > // handle one level of directories > if ( f.isDirectory()) > { > File contents[] = f.listFiles(); > for ( int j=contents.length-1;j>=0;j--) > bf.loadNSave( session, contents[j]); > } > > bf.loadNSave( session, f); > } > } > finally > { > if ( session != null) > { > session.flush(); // force in-memory to disk. > session.close(); // only for local sessions > } > } > } > > /** > * The session is the primary interaction layer between Hibernate and > * the underlying database. Closely allied with that is a suite of > * Biojavax classes handling the load and save operations. These classes > * are coordinated throught the RichObjectFactory. Thus, correctly > * setting up and using the factory for all object operations is > * critical! > */ > Session doSessionFactoryBindings( SessionFactory sessionFactory) > { > if ( verbose) System.out.println( "doing bindings."); > // open a session before processing the files. This allows the > // session to survive across the multiple transactions. And, hopefully, > // to provide level-2 caching services for the objects.... > // Contrast with getCurrentSession wich only survives for the current > // transaction. > Session session = sessionFactory.openSession(); > > // Change DefaultNamespaceName binding from "biojavax" > RichObjectFactory.setDefaultNamespaceName( "genbankBiosqlRich"); > > // Change DefaultOntologyName binding from "lcl". Hopefully, this will > // map the genbank annotation information into the SO term space. This > // works for some, but not all features. Those which donto map are > // flagged as "auto-generated by biojavax". > // nota bene: may be dangerous if semantics are not exactly the same! > // examination of the SO mapping indicated that were the terms align, > the > // semantics also align. > // Benefit is that semantic queries can be performed on the loaded info. > RichObjectFactory.setDefaultOntologyName( "sequence"); //"SO" ); > > > // Hook to BiojavaX and BioSQL. This sets up the proper conditions for > // transparently hooking to the database and supplying objects from > // that db if they exist within it. This is accomplished via hooking the > // Builder, Resolver, and Handler to BioSQL implementations. > // Establishes standard bindings for: > // RichObjectBuilder, > // DefaultCrossReferenceResolver, > // DefaultRichSequenceHandler. > // nb: PositionResolver is left as new AverageResolver(); > RichObjectFactory.connectToBioSQL(session); > > // also grab a reference to the underlying database (so that I can use > // the convenience wrapper methods for delting entries). > //db = new BioSQLRichSequenceDB( session); // create the > RichSequenceDB wrapper around the Hibernate session > > return session; > } > > /** > * This works for genbank files containing multiple sequences. > * Originaly concept from: > http://portal.open-bio.org/pipermail/biojava-l/2007-April/005824.html > * It fails on inserting existant record(s) - does not replace... > * This causes grief when loading multiple files... > */ > public void loadNSave( Session session, File fileName) > { > boolean localSession = (session == null); > Transaction tx = null; > // ensure that an acceptable session configuration exists. > if ( session == null) throw new Error( "session object not > established"); > > // Note the retrieval of namespace VIA the factory. The interface > // documentation did not make clear the requirement to use the > // established 'singleton' object (via getDefaultNamespace or > equivalent). > // The underlying hibernate code does not attempt to automatically > ensure > // the uniqueness (singleton) by attempting a load of any instances. > // Failure to use the factory will result in attempts to create a > // duplicate namespace in the database. > org.biojavax.Namespace ns = RichObjectFactory.getDefaultNamespace(); > > try > { > if ( verbose) System.out.println( "*********** Loading > "+fileName+"..."); > BufferedReader br = new BufferedReader( new FileReader( fileName) ); > > // readGenbankDNA loads the objects from the stream and uses the > // established factory(ies) and defaults for object creation. > if ( verbose) System.out.println( "*********** readGenbankDNA..."); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA( br, > ns); > > while ( rsi.hasNext() ) // for each sequence in the file... > { > if ( verbose) System.out.println( "*********** start transaction."); > // Hibernate seems to REQUIRE transactions when objects are > modified. > tx = session.beginTransaction(); > > if ( verbose) System.out.println( "*********** Loading next > sequence..."); > RichSequence sequence = rsi.nextRichSequence(); > System.out.println( "loaded sequence "+sequence.getAccession()+ > ", identifier: "+ sequence.getIdentifier()); > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name = > :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > if ( verbose) System.out.println( "*********** DELETING extant > sequence..."); > // Interesintly, hibernate does not seem to do transactions in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > try > { > // Loading entire genomes from genbank consumes large amounts > // of memory. Thus, each sequence and its associated > // annotations are wrapped in a transaction, the transaction > saved, > // and the in-memory cache is cleared. While being somewhat > // inefficient, this approach does limit memory consumption. > if ( verbose) System.out.println( "*********** saving..."); > > // synchronize in-memory representation w/ the database > session.saveOrUpdate( "Sequence", sequence ); > if ( verbose) System.out.println( "*********** comitting..."); > tx.commit(); // save to database - does an automatic flush > // batch operations overwhelm the hibernate cache - clear it out! > if ( verbose) System.out.println( "*********** flushing..."); > session.flush(); // force in-memory to disk. > if ( verbose) System.out.println( "*********** clearing..."); > session.clear(); // clean out cache. > } > catch (HibernateException ex) > { > tx.rollback(); // discard the sequence and all its annotations > ex.printStackTrace(); > } > } > } > catch (FileNotFoundException ex) > { > ex.printStackTrace(); > } > catch ( BioException bex) > { > bex.printStackTrace(); > } > } > > } > > > > package primerdb; > > import java.io.BufferedReader; > import java.io.File; > import java.io.FileFilter; > import java.io.FileNotFoundException; > import java.io.FileReader; > import java.io.IOException; > import java.sql.SQLException; > import java.util.ArrayList; > import org.biojava.bio.BioException; > import org.biojavax.Namespace; > import org.biojavax.RichObjectFactory; > import org.biojavax.SimpleNamespace; > import org.biojavax.bio.BioEntry; > import org.biojavax.bio.db.RichSequenceDB; > import org.biojavax.bio.db.biosql.BioSQLRichSequenceDB; > import org.biojavax.bio.seq.RichSequence; > import org.biojavax.bio.seq.RichSequenceIterator; > import org.hibernate.HibernateException; > import org.hibernate.Query; > import org.hibernate.Session; > import org.hibernate.SessionFactory; > import org.hibernate.Transaction; > import org.hibernate.cfg.Configuration; > > public class SequenceLoaderNew { > > private SessionFactory sessionFactory; > private Session session = null; > > private void initSession() { > sessionFactory = new > Configuration().configure().buildSessionFactory(); > session = sessionFactory.openSession(); > RichObjectFactory.connectToBioSQL(session); > } > > public static ArrayList getFiles(File filePath) { > FileFilter fileFilter = new FileFilter() { > > public boolean accept(File pathname) { > return pathname.isFile(); > } > }; > return getFiles(filePath, fileFilter); > } > > public static ArrayList getFiles(File filePath, FileFilter fileFilter) { > ArrayList rtn = new ArrayList(); > if (filePath.isFile()) { > if (fileFilter.accept(filePath)) { > rtn.add(filePath); > } > } else if (filePath.isDirectory()) { > File[] flist = filePath.listFiles(); > for (int i = 0; i < flist.length; i++) { > ArrayList subRtn = getFiles(flist[i], fileFilter); > for (int k = 0; k < subRtn.size(); k++) { > rtn.add(subRtn.get(k)); > } > } > } > return rtn; > } > > public void loadGenbankSeq(String[] filePaths, String namespace) throws > FileNotFoundException, BioException, SQLException, InterruptedException, > IOException { > File[] files = new File[filePaths.length]; > for (int i = 0; i < filePaths.length; i++) { > files[i] = new File(filePaths[i]); > } > loadGenbankSeq(files, namespace); > } > > public void loadGenbankSeq(File[] files, String namespace) throws > FileNotFoundException, BioException, SQLException, InterruptedException, > IOException { > if (session == null) { > initSession(); > } > Namespace ns = (Namespace) > RichObjectFactory.getObject(SimpleNamespace.class, new Object[]{namespace}); > RichSequenceDB db = new BioSQLRichSequenceDB(session); > for (int i = 0; i < files.length; i++) { > File file = files[i]; > System.out.println("Start loading file " + file.getAbsolutePath() > + " at " + System.currentTimeMillis()); > BufferedReader br = new BufferedReader(new FileReader(file)); > RichSequenceIterator rsi = > RichSequence.IOTools.readGenbankDNA(br, ns); > try { > while (rsi.hasNext()) { > Transaction tx = session.beginTransaction(); > try { > RichSequence sequence = rsi.nextRichSequence(); > System.out.println("Loaded sequence" + > sequence.getAccession() + ", identifier: " + sequence.getIdentifier()); > Query q = session.createQuery("from BioEntry as s > where s.name = :acc"); > q.setString("acc", sequence.getAccession()); > BioEntry be = (BioEntry) q.uniqueResult(); > if (be != null) { > session.delete(be); > tx.commit(); > tx = session.beginTransaction(); > } > System.out.println("Save sequence " + > sequence.getAccession()); > session.saveOrUpdate("Sequence", sequence); > tx.commit(); > System.out.println("Finished savig sequence " + > sequence.getAccession() + "\n"); > } catch (HibernateException ex) { > tx.rollback(); > ex.printStackTrace(); > } > } > } finally { > //session.flush(); > //RichObjectFactory.clearLRUCache(); > //session.clear(); > } > br.close(); > } > } > > public static void main(String[] args) throws BioException, > FileNotFoundException, InterruptedException, SQLException, IOException { > SequenceLoaderNew sl = new SequenceLoaderNew(); > FileFilter ff = new FileFilter() { > public boolean accept(File pathname) { > return pathname.isFile() && > (pathname.getName().toLowerCase().endsWith("gbk") || > pathname.getName().toLowerCase().endsWith("gb")); > } > }; > ArrayList flist = SequenceLoaderNew.getFiles(new > File("/genomeseq/bacteria"), ff); > File[] files = new File[flist.size()]; > for (int i = 0; i < flist.size(); i++) { > files[i] = (File) flist.get(i); > } > for (int i = 0; i < files.length; i++) { > System.out.println(files[i].getAbsolutePath() + ", size: " + > files[i].length()); > } > sl.loadGenbankSeq(files, "genbank"); > } > } > > From biopython at maubp.freeserve.co.uk Sat May 24 12:21:12 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Sat, 24 May 2008 13:21:12 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? Message-ID: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> This is a BioSQL related query - but first a little background: One topic that has recently come up on the Biopython developers mailing list is extending our sequence classes to deal with "per letter" annotation. This annotation should then survive splicing the sequence into sub-strings for example. For example, with nucleotide sequences, each base-pair may have an associated quality score (one float per bp). Or perhaps you might have a contig region where for each bp you want to record the number of fragments it is supported by (one integer per bp). Similarly, for proteins, you might know the secondary structure (for example held as a character per amino acid, a = alpha helix etc). For a PDB file, you might want to have an object for each residue holding an associated set of atomic coordinates, or may just the C-alpha back bone coordinates (three floats per residue). One final motivating example, you might want to hold the solvent accessibility of each residue (one float per residue). First of all, have any of the other Bio* project implemented anything like this? If so, I'd like to have a look at the relevant documentation (and depending on the language, even the implementation). And secondly, how would you go about storing it in BioSQL? As far as I can see, there isn't anything in BioSQL at the moment suitable (other than abusing the sequence features). I will be away most of next week, so I apologise in advance for an delayed responses. Peter (Biopython) From hlapp at gmx.net Sun May 25 00:16:31 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sat, 24 May 2008 20:16:31 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> Message-ID: <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> Comments below. On May 24, 2008, at 8:21 AM, Peter wrote: > This is a BioSQL related query - but first a little background: > > One topic that has recently come up on the Biopython developers > mailing list is extending our sequence classes to deal with "per > letter" annotation. This annotation should then survive splicing the > sequence into sub-strings for example. > > For example, with nucleotide sequences, each base-pair may have an > associated quality score (one float per bp). Or perhaps you might > have a contig region where for each bp you want to record the number > of fragments it is supported by (one integer per bp). > > Similarly, for proteins, you might know the secondary structure (for > example held as a character per amino acid, a = alpha helix etc). For > a PDB file, you might want to have an object for each residue holding > an associated set of atomic coordinates, or may just the C-alpha back > bone coordinates (three floats per residue). One final motivating > example, you might want to hold the solvent accessibility of each > residue (one float per residue). > > First of all, have any of the other Bio* project implemented anything > like this? If so, I'd like to have a look at the relevant > documentation (and depending on the language, even the > implementation). And secondly, how would you go about storing it in > BioSQL? As far as I can see, there isn't anything in BioSQL at the > moment suitable (other than abusing the sequence features). It sounds like in essence you want to store alternative sequences in other alphabets for a sequence? In BioPerl we have Bio::Seq::SeqWithQuality and the more generic Bio::Seq::MetaI. However, BioSQL in v1.0 really only supports a 1-1 relationship between Bioentry and Biosequence, i.e., a bioentry can only have a single sequence, and hence additional sequences (quality values, secondary structure, etc) would need to be stored as a flat annotation value, or through a the biosequence of a second bioentry that is linked to the first through a bioentry_relationship. (Biosequence in principle allows any alphabet.) Neither of those kludges (in fact, quite bad hacks) seem particularly attractive, so this would actually be another use case in favor of relaxing the 1-1 cardinality constraint to one that's 1-n. (Feel free to add this to the roadmap on the wiki.) As you say, you could indeed do this using seqfeatures too, but that'd be an abuse. -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From debrown at unity.ncsu.edu Wed May 21 18:50:09 2008 From: debrown at unity.ncsu.edu (Doug Brown) Date: Wed, 21 May 2008 14:50:09 -0400 Subject: [BioSQL-l] [Biojava-l] Load/Update Genbank sequence issue In-Reply-To: <4833C100.7040304@molbio.mgh.harvard.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> Message-ID: <48346EE1.70004@unity.ncsu.edu> Hi Gang wu, I recognize your problem. I to had to build a loader for genbank flat files. When attempting to 'replace' a record stored in the database, one needs to explicitly delete it before doing the save. I found that the hibernate code does not seem to understand that an in-memory deletion should be realized in the data base prior to the new insertion. My solution, see attached code, was to commit the transaction for the deletion and then open a new transaction for the insertion. Try inserting the following after "System.out.println("Loaded sequence"": // delete any extant sequence from the database. The cascaded // constraints will result in removal of all associated features // and what-not. Query q = session.createQuery( "from BioEntry as s where s.name = :acc"); q.setString( "acc", sequence.getAccession()); BioEntry be = (BioEntry)q.uniqueResult(); if ( be != null) { // Interestingly, hibernate does not seem to do transactions in the // same sense that a database would. Thus, I need to commit the // delete operation before I attempt to insert the replacement // information. session.delete( be); tx.commit(); tx = session.beginTransaction(); } Regards, Doug gang wu wrote: > I got another problem with almost the same code(see attached code and > output). If I call the loadSeq() only once, everything works fine. The > second call of the same method will fail. By the exception message, it > looks like the session is not cleaned up yet though at the end of the > method the session has been flush/clear/closed. Anything wrong? -- Doug Brown - Bioinformatics Fungal Genomics Laboratory Center for Integrated Fungal Research North Carolina State University Campus Box 7251, Raleigh, NC 27695-7251 https://www.fungalgenomics.ncsu.edu/~debrown/ Tel: (919) 513-0394, Fax (919) 513-0024 e-mail: doug_brown AtSign ncsu.edu -------------- next part -------------- A non-text attachment was scrubbed... Name: BriefLoader.java Type: text/x-java Size: 11672 bytes Desc: not available URL: From gwu at molbio.mgh.harvard.edu Thu May 22 20:42:22 2008 From: gwu at molbio.mgh.harvard.edu (gang wu) Date: Thu, 22 May 2008 16:42:22 -0400 Subject: [BioSQL-l] [Biojava-l] Load/Update Genbank sequence issue In-Reply-To: <48346EE1.70004@unity.ncsu.edu> References: <48331277.7060105@molbio.mgh.harvard.edu> <4833C100.7040304@molbio.mgh.harvard.edu> <48346EE1.70004@unity.ncsu.edu> Message-ID: <4835DAAE.6080609@molbio.mgh.harvard.edu> Hi Doug and Richard, Thanks for your reply. I've been following your suggestions and finding a way that works for me. Basically, if there is anything in the code that flush/clear the session, it's going to be a problem for the following calls to the same method. I'm not sure if it's Hibernate bug or is like Richard suggested that it is a feature. Attached is the code I am using to load/update Genbank sequences. It could be easily generalized to load other sequences(if the process works). Seems it works for me now(still running test on bigger sequences). It's pretty fast to load those small bacteria sequences, usually 10-60 seconds. But it seems it's getting choked with the bigger sequences. I started it last night at about 11pm to load the 5 Arabidopsis thaliana genome sequences(about 280MB total). The first one finished in about 1.5 hours and it's stilling hanging there now on the second sequence. I saw a 100% CPU usage and 2.6GB memory assigned for the program. The MySQL server is running on the same server. The machine has 8GB RAM and 2 dual core exon CPUS running at 3.73GHZ. Doug, I tested your code and seems the output is not always consistent: I tried to load two sequences. Sometimes succeeded and sometimes failed. I wonder it's still the session issue. I did not try with removing those flush/clear code. Thanks again for your response. It really helps me out. I'll post my code here if I work out a better solution. Gang Doug Brown wrote: > Hi Gang wu, > > I recognize your problem. I to had to build a loader for genbank flat > files. When attempting to 'replace' a record stored in the database, > one needs to explicitly delete it before doing the save. I found that > the hibernate code does not seem to understand that an in-memory > deletion should be realized in the data base prior to the new > insertion. My solution, see attached code, was to commit the > transaction for the deletion and then open a new transaction for the > insertion. > > Try inserting the following after "System.out.println("Loaded sequence"": > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name > = :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > // Interestingly, hibernate does not seem to do transactions > in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > > Regards, > Doug > > gang wu wrote: >> I got another problem with almost the same code(see attached code and >> output). If I call the loadSeq() only once, everything works fine. >> The second call of the same method will fail. By the exception >> message, it looks like the session is not cleaned up yet though at >> the end of the method the session has been flush/clear/closed. >> Anything wrong? > > ------------------------------------------------------------------------ > > // Copyright 2008, by North Carolina State University. All rights reserved. > > /** > * > * javac -cp "C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" bioinformatics\biojava\BriefLoader.java > * > * java -Xmx100m -cp "c:\jars\asm.jar;c:\jars\asm-attrs.jar;c:\jars\cglib-2.1.3.jar;c:\jars\jta.jar;c:\jars\antlr-2.7.6.jar;c:\jars\commons-collections-2.1.1.jar;c:\jars\commons-logging-1.0.4.jar;c:\jars\dom4j-1.6.1.jar;C:\WorkData\javaCode\;C:\JavaDev\biojava-live\biojava-live.jar;C:\jars\hibernate3.jar;C:\jars\mysql-connector-java-3.1.13-bin.jar" -Djdbc.drivers=com.mysql.jdbc.Driver bioinformatics.biojava.BriefLoader C:\WorkData\genomes\M_grisea_genbank_v5\CH476760.gb > */ > package bioinformatics.biojavaTools; > > import java.io.BufferedReader; > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileReader; > import java.io.IOException; > > import org.biojava.bio.BioException; > import org.biojavax.*; > import org.biojavax.RichObjectFactory; > import org.biojavax.bio.db.biosql.BioSQLRichSequenceDB; > import org.biojavax.bio.seq.*; > import org.biojavax.bio.seq.RichSequence.*; > import org.biojavax.bio.seq.RichSequence.IOTools; > import org.biojavax.bio.seq.io.*; > import org.biojavax.bio.BioEntry; > > import org.hibernate.*; > import org.hibernate.cfg.*; > > //import java.util.logging.*; > //import org.apache.commons.logging.*; > > > > > public class BriefLoader > { > static SessionFactory sessionFactory; > static boolean verbose = false; > public static void main(String[] args) > { > int argPos = 0; > if ( args.length > 0 && args[argPos].equals( "-v")) > { > verbose = true; > argPos++; > } > if ( argPos == args.length) > { > System.out.println( "Usage: BriefLoader [-v] file1.bg [file2.gb ...]"); > return; > } > > BriefLoader bf = new BriefLoader(); > > // logging: > // I want to suppress the verbose info messages. > // After some investigation, it seems that commons > // logging uses a default of Jdk14Logger (the standard java logger). > // Thus, I can control the commons logger via the java.util.logging API. > // API > java.util.logging.Logger jdklogger = java.util.logging.Logger.getLogger("org.hibernate"); > jdklogger.setLevel(java.util.logging.Level.WARNING); > > sessionFactory = new > // Configuration is very expensive and can only be done once. > // > // properties can be specified via the file hibernate.properties located > // on the classpath, > // on the command line via -D, > // via the defaut "hibernate.cfg.xml" file in the current working directory, > // via an explicitly identified file, e.g. "specific_file.cfg.xml", > // via explicit calls to setProperty. The same goes for resources. > // Later definitions override earlier ones. > Configuration() > // Note: > // specifying the resource location of the configuration file > // works ONLY if I also modify the > // hibernate.cfg.xml file to add the class' package as a prefix > // for every resource. Hibernate does not understand the > // concept of relative locations based on the location of the > // configuratin file. Nonetheless, this allows me to organize the > // mapping files based on java packages. > .configure( bf.getClass().getResource( "hibernate.cfg.xml")) > // the following should allows use of a generic configuration file > // by overriding the items that need to be customized. > //.setProperty( "connection.url", "jdbc:mysql://someMachine.ncsu.edu:3306/M_grisea_genbank_biosql") > //.setProperty( "connection.username", "aUser") > //.setProperty( "connection.password", "aPassword") > // > // The following can be used to adjust memory consumption. > //.setProperty( "hibernate.jdbc.batch_size", "20") > //.setProperty( "hibernate.cache.use_second_level_cache", "false") > // > // examining the generated SQL can be informative... > //.setProperty( "hibernate.show_sql", "true") > > // Go and make the support interfaces... > .buildSessionFactory(); > > Session session = null; > try > { > session = bf.doSessionFactoryBindings( sessionFactory); > > while ( argPos < args.length) > { > File f = new File( args[argPos++]); > > // handle one level of directories > if ( f.isDirectory()) > { > File contents[] = f.listFiles(); > for ( int j=contents.length-1;j>=0;j--) > bf.loadNSave( session, contents[j]); > } > > bf.loadNSave( session, f); > } > } > finally > { > if ( session != null) > { > session.flush(); // force in-memory to disk. > session.close(); // only for local sessions > } > } > } > > /** > * The session is the primary interaction layer between Hibernate and > * the underlying database. Closely allied with that is a suite of > * Biojavax classes handling the load and save operations. These classes > * are coordinated throught the RichObjectFactory. Thus, correctly > * setting up and using the factory for all object operations is > * critical! > */ > Session doSessionFactoryBindings( SessionFactory sessionFactory) > { > if ( verbose) System.out.println( "doing bindings."); > // open a session before processing the files. This allows the > // session to survive across the multiple transactions. And, hopefully, > // to provide level-2 caching services for the objects.... > // Contrast with getCurrentSession wich only survives for the current > // transaction. > Session session = sessionFactory.openSession(); > > // Change DefaultNamespaceName binding from "biojavax" > RichObjectFactory.setDefaultNamespaceName( "genbankBiosqlRich"); > > // Change DefaultOntologyName binding from "lcl". Hopefully, this will > // map the genbank annotation information into the SO term space. This > // works for some, but not all features. Those which donto map are > // flagged as "auto-generated by biojavax". > // nota bene: may be dangerous if semantics are not exactly the same! > // examination of the SO mapping indicated that were the terms align, the > // semantics also align. > // Benefit is that semantic queries can be performed on the loaded info. > RichObjectFactory.setDefaultOntologyName( "sequence"); //"SO" ); > > > // Hook to BiojavaX and BioSQL. This sets up the proper conditions for > // transparently hooking to the database and supplying objects from > // that db if they exist within it. This is accomplished via hooking the > // Builder, Resolver, and Handler to BioSQL implementations. > // Establishes standard bindings for: > // RichObjectBuilder, > // DefaultCrossReferenceResolver, > // DefaultRichSequenceHandler. > // nb: PositionResolver is left as new AverageResolver(); > RichObjectFactory.connectToBioSQL(session); > > // also grab a reference to the underlying database (so that I can use > // the convenience wrapper methods for delting entries). > //db = new BioSQLRichSequenceDB( session); // create the RichSequenceDB wrapper around the Hibernate session > > return session; > } > > /** > * This works for genbank files containing multiple sequences. > * Originaly concept from: http://portal.open-bio.org/pipermail/biojava-l/2007-April/005824.html > * It fails on inserting existant record(s) - does not replace... > * This causes grief when loading multiple files... > */ > public void loadNSave( Session session, File fileName) > { > boolean localSession = (session == null); > Transaction tx = null; > // ensure that an acceptable session configuration exists. > if ( session == null) throw new Error( "session object not established"); > > // Note the retrieval of namespace VIA the factory. The interface > // documentation did not make clear the requirement to use the > // established 'singleton' object (via getDefaultNamespace or equivalent). > // The underlying hibernate code does not attempt to automatically ensure > // the uniqueness (singleton) by attempting a load of any instances. > // Failure to use the factory will result in attempts to create a > // duplicate namespace in the database. > org.biojavax.Namespace ns = RichObjectFactory.getDefaultNamespace(); > > try > { > if ( verbose) System.out.println( "*********** Loading "+fileName+"..."); > BufferedReader br = new BufferedReader( new FileReader( fileName) ); > > // readGenbankDNA loads the objects from the stream and uses the > // established factory(ies) and defaults for object creation. > if ( verbose) System.out.println( "*********** readGenbankDNA..."); > RichSequenceIterator rsi = RichSequence.IOTools.readGenbankDNA( br, ns); > > while ( rsi.hasNext() ) // for each sequence in the file... > { > if ( verbose) System.out.println( "*********** start transaction."); > // Hibernate seems to REQUIRE transactions when objects are modified. > tx = session.beginTransaction(); > > if ( verbose) System.out.println( "*********** Loading next sequence..."); > RichSequence sequence = rsi.nextRichSequence(); > System.out.println( "loaded sequence "+sequence.getAccession()+ > ", identifier: "+ sequence.getIdentifier()); > > // delete any extant sequence from the database. The cascaded > // constraints will result in removal of all associated features > // and what-not. > Query q = session.createQuery( "from BioEntry as s where s.name = :acc"); > q.setString( "acc", sequence.getAccession()); > BioEntry be = (BioEntry)q.uniqueResult(); > if ( be != null) > { > if ( verbose) System.out.println( "*********** DELETING extant sequence..."); > // Interesintly, hibernate does not seem to do transactions in the > // same sense that a database would. Thus, I need to commit the > // delete operation before I attempt to insert the replacement > // information. > session.delete( be); > tx.commit(); > tx = session.beginTransaction(); > } > > try > { > // Loading entire genomes from genbank consumes large amounts > // of memory. Thus, each sequence and its associated > // annotations are wrapped in a transaction, the transaction saved, > // and the in-memory cache is cleared. While being somewhat > // inefficient, this approach does limit memory consumption. > if ( verbose) System.out.println( "*********** saving..."); > > // synchronize in-memory representation w/ the database > session.saveOrUpdate( "Sequence", sequence ); > if ( verbose) System.out.println( "*********** comitting..."); > tx.commit(); // save to database - does an automatic flush > // batch operations overwhelm the hibernate cache - clear it out! > if ( verbose) System.out.println( "*********** flushing..."); > session.flush(); // force in-memory to disk. > if ( verbose) System.out.println( "*********** clearing..."); > session.clear(); // clean out cache. > } > catch (HibernateException ex) > { > tx.rollback(); // discard the sequence and all its annotations > ex.printStackTrace(); > } > } > } > catch (FileNotFoundException ex) > { > ex.printStackTrace(); > } > catch ( BioException bex) > { > bex.printStackTrace(); > } > } > > } > > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: SequenceLoaderNew.java URL: From biopython at maubp.freeserve.co.uk Sun May 25 09:49:36 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Sun, 25 May 2008 10:49:36 +0100 Subject: [BioSQL-l] *** SPAM *** Re: Storing "per letter" annotation? In-Reply-To: <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> Message-ID: <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> > It sounds like in essence you want to store alternative sequences in other > alphabets for a sequence? I hadn't thought of it like that, but for many of the examples it would just be one character per letter of sequence, so could be held as an alternative sequence. This doesn't really extend to cover things like a list of integers or a list of floats, but would certainly cover a number of use-cases. > In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > Bio::Seq::MetaI. I'll have to look at those. Thanks for you comments Hilmar - I'm not yet sure what would be the best way forward for extending BioSQL for this sort of thing. I guess some real world examples of where it would be useful would be a helpful guide. Peter From biopython at maubp.freeserve.co.uk Sun May 25 10:00:36 2008 From: biopython at maubp.freeserve.co.uk (Peter) Date: Sun, 25 May 2008 11:00:36 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? Message-ID: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Hilmar Wrote: >> It sounds like in essence you want to store alternative sequences in other >> alphabets for a sequence? Peter wrote: > I hadn't thought of it like that, but for many of the examples it > would just be one character per letter of sequence, so could be held > as an alternative sequence. This doesn't really extend to cover > things like a list of integers or a list of floats, but would > certainly cover a number of use-cases. Now that I know which bits of BioPerl to search for, I see there has been some similar BioSQL discussion in the past, e.g. http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html Hilmar Wrote: >> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >> Bio::Seq::MetaI. I had wondered what metals had to do with sequences, in a different font MetaI is of course short for MetaInformation! Peter P.S. I'll be away next week, so I probably won't follow up on this topic immediately, From dicknetherlands at gmail.com Sun May 25 11:55:32 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Sun, 25 May 2008 12:55:32 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: For what it's worth, BioJava allows you to define sequences as lists of symbols, and each symbol can contain as much info as you want. e.g. if you consider DNA to be an alphabet of ATCG etc., and you consider quality scores as an alphabet consisting of the integer numbers, then to construct a quality-scored sequence you use BioJava to make a cross-product alphabet of the two, where each symbol in the sequence actually consists of a pair of symbols, one from each alphabet. This means you can combine any number of alphabets to define complex and informative objects to represent each symbol in your sequence. cheers, Richard. 2008/5/25 Peter : > Hilmar Wrote: >>> It sounds like in essence you want to store alternative sequences in other >>> alphabets for a sequence? > > Peter wrote: >> I hadn't thought of it like that, but for many of the examples it >> would just be one character per letter of sequence, so could be held >> as an alternative sequence. This doesn't really extend to cover >> things like a list of integers or a list of floats, but would >> certainly cover a number of use-cases. > > Now that I know which bits of BioPerl to search for, I see there has > been some similar BioSQL discussion in the past, e.g. > http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html > > Hilmar Wrote: >>> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >>> Bio::Seq::MetaI. > > I had wondered what metals had to do with sequences, in a different > font MetaI is of course short for MetaInformation! > > Peter > > P.S. I'll be away next week, so I probably won't follow up on this > topic immediately, > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From hlapp at gmx.net Sun May 25 15:43:26 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sun, 25 May 2008 11:43:26 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: <341678E5-69E1-4486-A176-893762849D68@gmx.net> Indeed, when building a cross-product you can mix alphabets too of course (as compared to codons, which is DNA x DNA x DNA). That's a nice concept - so given proper de/serialization from/into one flat string the present BioSQL model could hold the cross-product sequence already. Do you guys have a standard notation for the alphabet in this case? More concretely, if you store a cross-product sequence in BioSQL, what do you put into the biosequence.alphabet column? Peter - I had included integer or floating point sequences in my response; there is no restriction that individual symbols need to be representable by at most 7 or 8 bits. -hilmar On May 25, 2008, at 7:55 AM, Richard Holland wrote: > For what it's worth, BioJava allows you to define sequences as lists > of symbols, and each symbol can contain as much info as you want. e.g. > if you consider DNA to be an alphabet of ATCG etc., and you consider > quality scores as an alphabet consisting of the integer numbers, then > to construct a quality-scored sequence you use BioJava to make a > cross-product alphabet of the two, where each symbol in the sequence > actually consists of a pair of symbols, one from each alphabet. This > means you can combine any number of alphabets to define complex and > informative objects to represent each symbol in your sequence. > > cheers, > Richard. > > 2008/5/25 Peter : >> Hilmar Wrote: >>>> It sounds like in essence you want to store alternative >>>> sequences in other >>>> alphabets for a sequence? >> >> Peter wrote: >>> I hadn't thought of it like that, but for many of the examples it >>> would just be one character per letter of sequence, so could be held >>> as an alternative sequence. This doesn't really extend to cover >>> things like a list of integers or a list of floats, but would >>> certainly cover a number of use-cases. >> >> Now that I know which bits of BioPerl to search for, I see there has >> been some similar BioSQL discussion in the past, e.g. >> http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html >> >> Hilmar Wrote: >>>> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >>>> Bio::Seq::MetaI. >> >> I had wondered what metals had to do with sequences, in a different >> font MetaI is of course short for MetaInformation! >> >> Peter >> >> P.S. I'll be away next week, so I probably won't follow up on this >> topic immediately, >> _______________________________________________ >> BioSQL-l mailing list >> BioSQL-l at lists.open-bio.org >> http://lists.open-bio.org/mailman/listinfo/biosql-l >> -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Sun May 25 15:44:05 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sun, 25 May 2008 11:44:05 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: <5BA0181B-C815-4B46-904D-05BA2504FFF3@gmx.net> On May 25, 2008, at 6:12 AM, Robson Francisco de Souza wrote: > Anyone might correct me if I'm wrong but I believe MetaI it is > short for "Meta Interface", which means this package defines the > methods any Bio::Seq::MetaI-complaint object should implement. That is correct. Bio::Seq::MetaI is the interface, and Bio::Seq::Meta is an implementation. -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From hlapp at gmx.net Sun May 25 16:44:36 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Sun, 25 May 2008 12:44:36 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: <595C5BBE-A07A-4ECA-A054-35CD9462AE3F@gmx.net> On May 25, 2008, at 6:00 AM, Peter wrote: > Now that I know which bits of BioPerl to search for, I see there has > been some similar BioSQL discussion in the past, e.g. > http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html Oops - indeed - I'm glad we arrive at the same conclusion 3 years later :-)) -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From dicknetherlands at gmail.com Sun May 25 19:21:36 2008 From: dicknetherlands at gmail.com (Richard Holland) Date: Sun, 25 May 2008 20:21:36 +0100 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <341678E5-69E1-4486-A176-893762849D68@gmx.net> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> <341678E5-69E1-4486-A176-893762849D68@gmx.net> Message-ID: The notation is to enclose each symbol in square brackets, with comma separate sub-symbols, each of which can be square bracketed itself if it consists of further sub-divisions. The alphabet name is then just the name of the alphabet object in BioJava - you'd have to decode this externally to the db, unless you introduce some kind of fixed format description for the alphabet to store in the name field. We've never tried storing this kind of sequence to my knowledge. Something to try in future! Richard. 2008/5/25 Hilmar Lapp : > Indeed, when building a cross-product you can mix alphabets too of course > (as compared to codons, which is DNA x DNA x DNA). > > That's a nice concept - so given proper de/serialization from/into one flat > string the present BioSQL model could hold the cross-product sequence > already. > > Do you guys have a standard notation for the alphabet in this case? More > concretely, if you store a cross-product sequence in BioSQL, what do you put > into the biosequence.alphabet column? > > Peter - I had included integer or floating point sequences in my response; > there is no restriction that individual symbols need to be representable by > at most 7 or 8 bits. > > -hilmar > > On May 25, 2008, at 7:55 AM, Richard Holland wrote: >> >> For what it's worth, BioJava allows you to define sequences as lists >> of symbols, and each symbol can contain as much info as you want. e.g. >> if you consider DNA to be an alphabet of ATCG etc., and you consider >> quality scores as an alphabet consisting of the integer numbers, then >> to construct a quality-scored sequence you use BioJava to make a >> cross-product alphabet of the two, where each symbol in the sequence >> actually consists of a pair of symbols, one from each alphabet. This >> means you can combine any number of alphabets to define complex and >> informative objects to represent each symbol in your sequence. >> >> cheers, >> Richard. >> >> 2008/5/25 Peter : >>> >>> Hilmar Wrote: >>>>> >>>>> It sounds like in essence you want to store alternative sequences in >>>>> other >>>>> alphabets for a sequence? >>> >>> Peter wrote: >>>> >>>> I hadn't thought of it like that, but for many of the examples it >>>> would just be one character per letter of sequence, so could be held >>>> as an alternative sequence. This doesn't really extend to cover >>>> things like a list of integers or a list of floats, but would >>>> certainly cover a number of use-cases. >>> >>> Now that I know which bits of BioPerl to search for, I see there has >>> been some similar BioSQL discussion in the past, e.g. >>> http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html >>> >>> Hilmar Wrote: >>>>> >>>>> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic >>>>> Bio::Seq::MetaI. >>> >>> I had wondered what metals had to do with sequences, in a different >>> font MetaI is of course short for MetaInformation! >>> >>> Peter >>> >>> P.S. I'll be away next week, so I probably won't follow up on this >>> topic immediately, >>> _______________________________________________ >>> BioSQL-l mailing list >>> BioSQL-l at lists.open-bio.org >>> http://lists.open-bio.org/mailman/listinfo/biosql-l >>> > > -- > =========================================================== > : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : > =========================================================== > > > > From markjschreiber at gmail.com Mon May 26 02:23:01 2008 From: markjschreiber at gmail.com (Mark Schreiber) Date: Mon, 26 May 2008 10:23:01 +0800 Subject: [BioSQL-l] *** SPAM *** Re: Storing "per letter" annotation? In-Reply-To: <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> Message-ID: <93b45ca50805251923q6f443078l415d59317eba0b04@mail.gmail.com> Hi - Genbank/EMBL format has options for partial locations that have ends less than the start or greater than the end of a sequence. This would let you retain feature information after obtaining a subsequence. I think these locations can be stored in BioSQL?? - Mark On 5/25/08, Peter wrote: > > It sounds like in essence you want to store alternative sequences in other > > alphabets for a sequence? > > I hadn't thought of it like that, but for many of the examples it > would just be one character per letter of sequence, so could be held > as an alternative sequence. This doesn't really extend to cover > things like a list of integers or a list of floats, but would > certainly cover a number of use-cases. > > > In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > > Bio::Seq::MetaI. > > I'll have to look at those. > > Thanks for you comments Hilmar - I'm not yet sure what would be the > best way forward for extending BioSQL for this sort of thing. I guess > some real world examples of where it would be useful would be a > helpful guide. > > Peter > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From markjschreiber at gmail.com Mon May 26 02:30:31 2008 From: markjschreiber at gmail.com (Mark Schreiber) Date: Mon, 26 May 2008 10:30:31 +0800 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <341678E5-69E1-4486-A176-893762849D68@gmx.net> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> <341678E5-69E1-4486-A176-893762849D68@gmx.net> Message-ID: <93b45ca50805251930o790f54f1v3337aca6f9fd17bb@mail.gmail.com> Hi - BioJava has Interfaces for tokenizers which can be String or character. Most cross product alphabets don't have official character tokenizers however there is no reason why they can't. I think the only reason why they don't as yet is that there is no official IUB type nomenclature, however he who codes it wins! Because this is an issue that mostly affects BioSQL serialization it would be nice if when people develop these they could become official BioSQL standards so that Bio* et al all speak the same language. - Mark On 5/25/08, Hilmar Lapp wrote: > Indeed, when building a cross-product you can mix alphabets too of course > (as compared to codons, which is DNA x DNA x DNA). > > That's a nice concept - so given proper de/serialization from/into one flat > string the present BioSQL model could hold the cross-product sequence > already. > > Do you guys have a standard notation for the alphabet in this case? More > concretely, if you store a cross-product sequence in BioSQL, what do you put > into the biosequence.alphabet column? > > Peter - I had included integer or floating point sequences in my response; > there is no restriction that individual symbols need to be representable by > at most 7 or 8 bits. > > -hilmar > > > On May 25, 2008, at 7:55 AM, Richard Holland wrote: > > For what it's worth, BioJava allows you to define sequences as lists > > of symbols, and each symbol can contain as much info as you want. e.g. > > if you consider DNA to be an alphabet of ATCG etc., and you consider > > quality scores as an alphabet consisting of the integer numbers, then > > to construct a quality-scored sequence you use BioJava to make a > > cross-product alphabet of the two, where each symbol in the sequence > > actually consists of a pair of symbols, one from each alphabet. This > > means you can combine any number of alphabets to define complex and > > informative objects to represent each symbol in your sequence. > > > > cheers, > > Richard. > > > > 2008/5/25 Peter : > > > > > Hilmar Wrote: > > > > > > > > > > > > It sounds like in essence you want to store alternative sequences in > other > > > > > alphabets for a sequence? > > > > > > > > > > > > > > > Peter wrote: > > > > > > > I hadn't thought of it like that, but for many of the examples it > > > > would just be one character per letter of sequence, so could be held > > > > as an alternative sequence. This doesn't really extend to cover > > > > things like a list of integers or a list of floats, but would > > > > certainly cover a number of use-cases. > > > > > > > > > > Now that I know which bits of BioPerl to search for, I see there has > > > been some similar BioSQL discussion in the past, e.g. > > > > http://bioperl.org/pipermail/bioperl-l/2005-July/019280.html > > > > > > Hilmar Wrote: > > > > > > > > > > > > In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > > > > > Bio::Seq::MetaI. > > > > > > > > > > > > > > > I had wondered what metals had to do with sequences, in a different > > > font MetaI is of course short for MetaInformation! > > > > > > Peter > > > > > > P.S. I'll be away next week, so I probably won't follow up on this > > > topic immediately, > > > _______________________________________________ > > > BioSQL-l mailing list > > > BioSQL-l at lists.open-bio.org > > > http://lists.open-bio.org/mailman/listinfo/biosql-l > > > > > > > > > > -- > =========================================================== > : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : > =========================================================== > > > > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > From hlapp at gmx.net Mon May 26 17:52:32 2008 From: hlapp at gmx.net (Hilmar Lapp) Date: Mon, 26 May 2008 13:52:32 -0400 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <93b45ca50805251923q6f443078l415d59317eba0b04@mail.gmail.com> References: <320fb6e00805240521l6d7445c4rafa79dcccb46b67f@mail.gmail.com> <37A679E9-AC76-43C3-809D-36F58EA9324D@gmx.net> <320fb6e00805250249o239bc168gff72b95fe196ec89@mail.gmail.com> <93b45ca50805251923q6f443078l415d59317eba0b04@mail.gmail.com> Message-ID: On May 25, 2008, at 10:23 PM, Mark Schreiber wrote: > Genbank/EMBL format has options for partial locations that have ends > less than the start or greater than the end of a sequence. This would > let you retain feature information after obtaining a subsequence. > > I think these locations can be stored in BioSQL?? Yes they can. However, I don't think Biojava can handle fuzzy locations, or can it? -hilmar -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net : =========================================================== From robfsouza at gmail.com Sun May 25 10:12:47 2008 From: robfsouza at gmail.com (Robson Francisco de Souza) Date: Sun, 25 May 2008 07:12:47 -0300 Subject: [BioSQL-l] Storing "per letter" annotation? In-Reply-To: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> References: <320fb6e00805250300g20721627u3cb5a7387b4c248f@mail.gmail.com> Message-ID: 2008/5/25 Peter : > Hilmar Wrote: > >> In BioPerl we have Bio::Seq::SeqWithQuality and the more generic > >> Bio::Seq::MetaI. > > I had wondered what metals had to do with sequences, in a different > font MetaI is of course short for MetaInformation! > Anyone might correct me if I'm wrong but I believe MetaI it is short for "Meta Interface", which means this package defines the methods any Bio::Seq::MetaI-complaint object should implement. Cheers, Robson > Peter > > > P.S. I'll be away next week, so I probably won't follow up on this > topic immediately, > _______________________________________________ > BioSQL-l mailing list > BioSQL-l at lists.open-bio.org > http://lists.open-bio.org/mailman/listinfo/biosql-l > >