[Biojava-l] SimpleRichAnnotation

Richard Holland holland at eaglegenomics.com
Sun Dec 7 19:19:36 UTC 2008


Your email is basically four questions as far as I can tell?

(a) why doesn't getProperties on a RichAnnotation work the way you'd
expect it to

(b) how can you get a singleton ontology instance loaded from BioSQL

(c) how can you change the default ontology returned by RichObjectFactory

(d) why are Terms using the == equality test instead of equals().

I'll answer them last first!

(d) for speed, and on the assumption that nobody would want to have two
copies of the exact same ontology in memory at any one time. But, you
are right, two terms of the same name from two ontologies of the same
name from two different sources will not match. It can be argued both
ways - it is a good thing because you don't want a collection to report
it contains a specific object when it in fact contains only a copy that
is like that object but not the exact same object - and it is a bad
thing because you can't load two copies of the same ontology twice for
comparison. If you want to test for equality without making an ==
comparison because of the above assumption, you can compare them using
the equals() methods on the name string and ontology reference provided
by the terms getter methods rather than using equals() on the term itself.

(c) You can change the default ontology. Call
RichObjectFactory.setDefaultOntologyName() with the name of the ontology
you want to use. It will create a new ontology of this name, or if you
have already created one of that name recently (you MUST have done so
using the getObject() method of the RichObjectFactory for this to work),
then it will use that one instead. However, if you have already called
the connectToBioSQL() method on the factory,
then this will load (or create if it doesn't exist) the ontology from
BioSQL and use that instance instead of creating a new one.

(b) Use the getObject() method on the RichObjectFactory after already
having called the connectToBioSQL() method.

(a) getProperty()/getProperties() is deprecated but hasn't been marked
so yet. Instead, you should use getNote()/getNoteSet(). This will work
the way you expect it to. It accepts an actual term, rather than a term
name, so you can pass in any ontology term you wish.

I hope this helps.

cheers,
Richard


James Procter wrote:
> Hello.
>
> I'm going to re-itereate Augusto's question here - and plead (if not
> grovel) for some kind of answer:
> Augusto Fernandes Vellozo wrote:
>> I am having problems with the class SimpleRichAnnotation.
>> I have one term t of ontology o and I put one note n (with the term t)
>> in an SimpleRichAnnotation object a, but in the moment i call the
>> method
>> a.getProperties(t) it didn't return the note n.
> I have this same problem - but in this case its when I'm trying to get
> at anything from a bioSQL backed database.
>
>> I saw in the code of Biojava that the method getProperties imports the
>> term t into of the ontology default before to do the search. Because
>> this it doesn't return the correct note.
>>
>> Please, someone knows why is this method changing the ontology?
> .. and if it 'should be' changing the ontology, why doesn't the
> getOrImport method work properly ?
>
> Here are my observations:
>
> After my initial failing to get my feature annotation properties by the
> obvious means: via the Feauture's getAnnotation("note name"); I thought
> that it was due to the default ontology namespace not matching the
> BioSQL ontology namespace (that is, the ontology name prefix didn't
> match). I therefore created a new ontology with a matching namespace,
> thinking that would be sufficient. However, looking at the
> implementation of the biojavax SimpleRichAnnotation 'contains' method, I
> think I'm on a hiding to nothing, since I made the same observation as
> Augusto: it always calls the default ontology import or create term
> function to make a local instance of the Term passed as argument.
>
> Logically, this sounds fine, although messy and not thread-safe since
> the RichObjectFactory holds a single static instance of the default
> Ontology - except that it completely breaks in more ways than I thought
> possible. The reason this doesn't work is that the as far as I can tell,
> the Term equivalence relationship is implemented by object reference
> equivalence, rather than by equals method equivalence. That is, Terms
> can only be equal if they come from the same ComparableOntology object
> instance, and have the same string constant reference. That means terms
> can never be compared from different instances of the same ontology
> (such as would be returned from two independent sources - ie a
> persistence framework and an external ontology resource).
>
> I note that in the deprecated org.biojava.bio.seq.db.biosql
> implementation, there are methods to handle the BioSQL ontology index.
> These are, however, deprecated, and so there is currently no way to
> retrieve a singleton instance of the Biosql database's ontology, and
> therefore no way that the above equivalence method is ever going to
> retrieve the corresponding Note for a particular named property... even
> if I could set the RichSequenceObjectFactory's default ontology to be
> the one retrieved from the BioSQL database back end!
>
> sorry to be long winded... but it would be nice to know if I've missed
> something completely here!
>
> thanks
> Jim.
>

-- 
Richard Holland, BSc MBCS
Finance Director, Eagle Genomics Ltd
M: +44 7500 438846 | E: holland at eaglegenomics.com
http://www.eaglegenomics.com/



More information about the Biojava-l mailing list