[Biojava-l] features of a sequence
Richard Holland
dicknetherlands at gmail.com
Thu Jun 5 16:25:00 UTC 2008
Oh dear, you found a bug.....! This is occurring in the location
flattening routines in RichLocation.Tools, where it is inadvertently
overwriting location data collection objects that should have been
just emptied and repopulated instead of being replaced.
I'll try and fix this. Can't promise it soon - I'm away for the next 7
days and am a bit busy after that - but will make a note. Maybe
someone else here could fix it quicker? (please?! :) )
cheers,
Richard
2008/6/5 Gabrielle Doan <gabrielle_doan at gmx.net>:
> Hi all,
>
> I would like to query the features of a sequence with following code:
>
> <code>
> public class Test{
> public static void main(String[] args) {
> // load Hibernate config
>
> SessionFactory sessionFactory = new
> Configuration().configure().buildSessionFactory(); // open the
> session
> Session session = sessionFactory.openSession();
> // connect it to BioJavaX
> RichObjectFactory.connectToBioSQL(session);
>
> Transaction tx = session.beginTransaction();
> Query q1 = session.createQuery(
> "from Feature as f " +
> "inner join fetch f.noteSet as n " +
> "where n.value=:val and f.typeTerm.name=:term");
> q1.setString("val","TRNF");
> q1.setString("term","gene"); List<SimpleRichFeature> li = q1.list();
> System.out.println("Found:\t"+li.size());
> for (Iterator<SimpleRichFeature> i = li.iterator(); i.hasNext(); ){
> SimpleRichFeature f = i.next();
> System.out.println("Term:\t"+f.getTypeTerm().getName());
>
> System.out.println("Location:\t"+f.getLocation().getMin()+"\t"+f.getLocation().getMax());
> System.out.println(f.getSequence().seqString());
> Annotation a = f.getAnnotation();
> for (Iterator keys = a.keys().iterator(); keys.hasNext(); ){
> Object key = keys.next();
> System.out.println(key+"\t"+a.getProperty(key));
> }
> }
> tx.commit();
> session.close();
> }
>
> }
> </code>
>
>
> When I try to print the SymbolList associated with the feature I receive the
> following exception. I appreciate any hint because I do not know what to do
> as it seems that the exception occurs somewhere within BioJava code.
>
>
> Exception in thread "main" org.hibernate.PropertyAccessException: Exception
> occurred inside setter of org.biojavax.bio.seq.SimpleRichFeature.locationSet
> at
> org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:65)
> at
> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
> at
> org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
> at
> org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3571)
> at
> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:133)
> at
> org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
> at org.hibernate.loader.Loader.doQuery(Loader.java:729)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
> at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
> at
> org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
> at
> org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
> at
> org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:63)
> at
> org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
> at
> org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
> at
> org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:844)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241)
> at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
> at
> org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
> at
> org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
> at
> org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049)
> at
> org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399)
> at
> org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
> at
> org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
> at
> org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:98)
> at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
> at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:836)
> at
> org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:66)
> at
> org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
> at
> org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
> at
> org.biojavax.bio.seq.ThinRichSequence$$EnhancerByCGLIB$$e3c3c7ff.seqString(<generated>)
> at meinVersuch.TestAbfragen.main(TestAbfragen.java:59)
> Caused by: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
> ... 30 more
> Caused by: java.lang.RuntimeException: Error while trying to call new class
> org.biojavax.ontology.SimpleComparableOntology(class java.lang.String)
> at
> org.biojavax.bio.db.biosql.BioSQLRichObjectBuilder.buildObject(BioSQLRichObjectBuilder.java:166)
> at org.biojavax.RichObjectFactory.getObject(RichObjectFactory.java:105)
> at
> org.biojavax.RichObjectFactory.getDefaultOntology(RichObjectFactory.java:221)
> at
> org.biojavax.bio.seq.CompoundRichLocation.getJoinTerm(CompoundRichLocation.java:61)
> at
> org.biojavax.bio.seq.CompoundRichLocation.<init>(CompoundRichLocation.java:90)
> at
> org.biojavax.bio.seq.SimpleRichLocation.union(SimpleRichLocation.java:494)
> at org.biojavax.bio.seq.RichLocation$Tools.merge(RichLocation.java:363)
> at
> org.biojavax.bio.seq.SimpleRichFeature.setLocationSet(SimpleRichFeature.java:181)
> ... 35 more
> Caused by: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.biojavax.bio.db.biosql.BioSQLRichObjectBuilder.buildObject(BioSQLRichObjectBuilder.java:133)
> ... 42 more
> Caused by: org.hibernate.HibernateException: A collection with
> cascade="all-delete-orphan" was no longer referenced by the owning entity
> instance: Feature.locationSet
> at
> org.hibernate.engine.Collections.processDereferencedCollection(Collections.java:96)
> at
> org.hibernate.engine.Collections.processUnreachableCollection(Collections.java:39)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:218)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:77)
> at
> org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
> at
> org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at
> org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811)
> ... 47 more
>
> It would be very nice if someone can help me. I am grateful for any hints.
> Thanks a lot.
>
> Cheers,
> Gabrielle
> _______________________________________________
> Biojava-l mailing list - Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
>
More information about the Biojava-l
mailing list