[Bioperl-l] Bio::Ontology overhaul

Hilmar Lapp hlapp at gnf.org
Thu Feb 27 19:32:09 EST 2003


On Thursday, February 27, 2003, at 12:29  PM, Aaron J Mackey wrote:

>
> Can I get an OntologyTermI without having first made an OntologyI and
> OntologyEngineI?
>

Yes, you can. Terms can even live without ontologies.

> (why is it an engine and not an OntologyTerm factory?

The "engine" is only the ontology query engine. It doesn't actually 
create terms, it just manages their relationships.

>   I guess the
> OntologyEngineI could be given an OntologyFactoryI to produce the
> OntologyTermI's it needed

If it actually created terms, then yes.

You might actually write a query engine that doesn't store terms as 
objects but only as identifiers and names (uhmm, I think I recall the 
Graph.pm-based engine does exactly that - hmm). So when creating the 
terms on the fly, the right approach would be to use a factory.

>  ... All this pattern-speak gets very confusing).
>
> Does accessing an OntologyTermI via a seqfeature (or some other
> OntologyTerm-associated container with a $term = $obj->term 
> functionality)
> auto-instantiate the OntologyI "namespace" of the term, which then 
> creates
> an OntologyEngineI to build the OntologyTermI that was requested (thus
> setting up the circular reference)?

Well, yes and no. The engine doesn't create terms, but if an object has 
a TermI attribute, that term should also have a namespace i.e. an 
ontology. If you don't set the engine for an ontology but call a query 
operation, it will auto-create an engine. It will not auto-add terms 
though. This is the responsibility of whoever sets up the ontology in 
the first place.

I.e., if you say

	$term = Bio::Ontology::Term->new(-name => "bla", -ontology => "foo");
	@roots = $term->ontology->get_root_terms();
	@all_terms = (@roots,
	              map { $term->ontology->get_descendant_terms($_); } 
@roots);

the @all_terms would have length zero, unless someone created ontology 
"foo" before and populated it.

>
> If so, how could an OntologyEngineI object manage to be reused for 
> another
> OntologyTermI that lived in a different OntologyI?

$term1 = Bio::Ontology::Term->new(-name => "bla1", -ontology => "foo");
$term2 = Bio::Ontology::Term->new(-name => "bla2", -ontology => "bar");
$term1->ontology->engine($term2->ontology->engine);

ok ($term1->ontology->name, "foo");
ok ($term2->ontology->name, "bar");
ok ($term1->ontology->engine, $term2->ontology->engine);

>
> Or do I (the lowly biologist trying to program with BioPerl), need to
> instantiate my own OntologyEngineI (and/or OntologyI) before getting at
> OntologyTermI's?

You should never *have* to worry about OntologyEngineI. You *can* worry 
about it if you've got a special requirement that calls for a special 
engine implementation (light-weight, or heavy-weight, or whatever).

Normally, a client script would only be concerned with OntologyI (which 
inherits all its query capabilities from OntologyEngineI - I did 
duplicate the documentation to spare people from having to look at 
another POD).

	-hilmar
-- 
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------



More information about the Bioperl-l mailing list