[Bioperl-l] ontology error

Hilmar Lapp hlapp at gmx.net
Thu Jun 10 11:38:07 EDT 2004


The second section adds a term to an ontology, which the first doesn't,  
it just adds a term to an annotation collection.

When you add terms to an ontology, the engine implementation may check  
that you don't add a term that has been added already. (NB It is  
debatable as to whether this is useful or not. Generally the intention  
behind it is to guard against programming errors. If a term is added  
that is present already you also have an update issue, i.e., do you  
replace the already existing term or not.)

The default engine implementation for Ontology.pm needs to identify  
terms by a scalar, which currently it does using a term's identifier.  
Since you didn't assign identifiers to your terms I suspect this is  
what gives rise to the problem.

You could either make up unique identifiers for your terms, or you  
could choose another ontology engine:
	$ont = Bio::Ontology::Ontology->new(-name => "myname",
								   -engine => Bio::Ontology::SimpleGOEngine->new());

SimpleGOEngine depends on Graph.pm, so it won't work unless you install  
Graph.pm from CPAN.

	-hilmar

On Wednesday, June 9, 2004, at 01:28  PM, S.Paul wrote:

> Hi Everybody:
>
> I am trying to write an ontology based on the structure of the PDB  
> file and  am not sure why I am getting the following error message:
>
> ------------- EXCEPTION  -------------
> MSG: term  already defined
>
> STACK Bio::Ontology::SimpleOntologyEngine::add_term  
> C:/Perl/site/lib/Bio/Ontolog
> y/SimpleOntologyEngine.pm:230
> STACK Bio::Ontology::Ontology::add_term  
> C:/Perl/site/lib/Bio/Ontology/Ontology.p
> m:337
> STACK toplevel js3_ontology2.pl:19
>
> *********************************************************************** 
> ********************************
> If I run only section 1 then it works but when I run section 2 I get  
> the above error message.
>
> Thanks for the help in advance
>
> Sujoy
>
> *********************************************************************** 
> **************************
>
>
> #SECTION 1:
>        use Bio::Annotation::OntologyTerm;
>        use Bio::Annotation::Collection;
>        use Bio::Ontology::Term;
>        use Bio::Ontology::Ontology;
>        use Bio::Ontology::RelationshipType;
>
>         my $coll = new Bio::Annotation::Collection;
>
>        # this also implements a tag/value pair, where tag _and_ value  
> are treated
>        # as ontology terms; tagname is synonym to ontology and label  
> is the same as name
>        my $annterm = new Bio::Annotation::OntologyTerm(-label => 'Dopa  
> Decarboxylase',
>                                                        -tagname =>  
> 'Protein Name',
>                                                        -identifier  
> =>'1JS3',
>                                                        -definition =>
>      'Crystal Structure of Dopa Decarboxylase in complex with the
>       2 Inhibitor Carbidopa');
>        # ontology terms can be added directly - they implicitly have a  
> tag
>        $coll->add_Annotation($annterm);
>
>        # implementation is by composition - you can get/set the term  
> object
>        # e.g.
>        my $term = $annterm->term(); # term is-a Bio::Ontology::TermI
>        print "ontology term: \n",$term->name(),"(ID  
> ",$term->identifier(),
>              "), ontology: ",$term->ontology()->name(),"\n",
>              "\n",$term->definition(),"\n";
>
>
> #SECTION 2
>  #ontology for 1JS3 pdb file: Crystal structure of Dopa decarboxylase  
> in complex with the 2
>  #inhibitor carbidopa
>
>  # create ontology object
>  my $ont = Bio::Ontology::Ontology->new(-name => "PDSequence_PDB");
>  # add terms, relationships ...
>  my $bp = Bio::Ontology::Term->new(-name => "Title");
>  my $obf = Bio::Ontology::Term->new(-name => "Compound");
>
>
>
>  my $partof = Bio::Ontology::RelationshipType->get_instance("PART_OF");
>  $ont->add_term($bp);
>  $ont->add_term($obf);
>  $ont->add_relationship($bp, $obf, $partof);
>  print "the ontology \n",$ont;
> *********************************************************************** 
> ******************************************************
>
> Sujoy Paul, PRISE Centre, UniS,  
> s.paul at surrey.ac.uk_______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
-- 
-------------------------------------------------------------
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