id
Usage - print $ontology->id()
Returns - the ontology ID (string)
Args - the ontology ID (string)
Function - gets/sets the ontology ID
name
Usage - print $ontology->name()
Returns - the name (string) of the ontology
Args - the name (string) of the ontology
Function - gets/sets the name of the ontology
date
Usage - print $ontology->date()
Returns - the current date (in dd:MM:yyyy HH:mm format) of the ontology
Args - the current date (in dd:MM:yyyy HH:mm format) of the ontology
Function - gets/sets the date of the ontology
namespace
Usage - print $ontology->namespace()
Returns - the namespace (string) of this ontology
Args - the namespace (string) of this ontology
Function - gets/sets the namespace of this ontolog
data_version
Usage - print $ontology->data_version()
Returns - the data version (string) of this ontology
Args - the data version (string) of this ontology
Function - gets/sets the data version of this ontology
saved_by
Usage - print $ontology->saved_by()
Returns - the username of the person (string) to last save this ontology
Args - the username of the person (string) to last save this ontology
Function - gets/sets the username of the person to last save this ontology
remark
Usage - print $ontology->remark()
Returns - the remark (string) of this ontology
Args - the remark (string) of this ontology
Function - gets/sets the remark of this ontology
add_term
Usage - $ontology->add_term($term)
Returns - the just added term (CCO::Core::Term)
Args - the term (CCO::Core::Term) to be added
Function - adds a term to this ontology
add_term_as_string
Usage - $ontology->add_term_as_string($term_id, $term_name)
Returns - the just added term (CCO::Core::Term)
Args - the term id (string) and the term name (string) of term to be added
Function - adds a term to this ontology
add_relationship_type
Usage - $ontology->add_relationship_type($relationship_type)
Returns - the just added relationship type (CCO::Core::RelationshipType)
Args - the relationship type to be added (CCO::Core::RelationshipType)
Function - adds a relationship type to this ontology
add_relationship_type_as_string
Usage - $ontology->add_relationship_type_as_string($relationship_type_id, $relationship_type_name)
Returns - the just added relationship type (CCO::Core::RelationshipType)
Args - the relationship type id (string) and the relationship type name (string) of the relationship type to be added
Function - adds a relationship type to this ontology
delete_term
Usage - $ontology->delete_term($term)
Returns - none
Args - the term (CCO::Core::Term) to be deleted
Function - deletes a term from this ontology
has_term
Usage - print $ontology->has_term($term)
Returns - true or false
Args - the term (CCO::Core::Term) to be tested
Function - checks if the given term belongs to this ontology
has_term_id
Usage - print $ontology->has_term_id($term)
Returns - true or false
Args - the term id (string) to be tested
Function - checks if the given term id corresponds to a term held by this ontology
has_relationship_type
Usage - print $ontology->has_relationship_type($relationship_type)
Returns - true or false
Args - the relationship type (CCO::Core::RelationshipType) to be tested
Function - checks if the given relationship type belongs to this ontology
has_relationship_type_id
Usage - print $ontology->has_relationship_type_id($relationship_type_id)
Returns - true or false
Args - the relationship type id (string) to be tested
Function - checks if the given relationship type id corresponds to a relationship type held by this ontology
equals
Usage - print $ontology->equals($another_ontology)
Returns - either 1 (true) or 0 (false)
Args - the ontology (CCO::Core::Ontology) to compare with
Function - tells whether this ontology is equal to the parameter
get_terms
Usage - $ontology->get_terms() or $ontology->get_terms("CCO:I.*")
Returns - the terms held by this ontology as a reference to an array of CCO::Core::Term's
Args - none or the regular expression for filtering the terms by id's
Function - returns the terms held by this ontology
get_terms_by_subnamespace
Usage - $ontology->get_terms_by_subnamespace() or $ontology->get_terms_by_subnamespace("P")
Returns - the terms held by this ontology corresponding to the requested subnamespace as a reference to an array of CCO::Core::Term's
Args - none or the subnamespace: 'P', 'I', and so on.
Function - returns the terms held by this ontology corresponding to the requested subnamespace
get_relationships
Usage - $ontology->get_relationships()
Returns - the relationships held by this ontology as a reference to an array of CCO::Core::Relationship's
Args - none
Function - returns the relationships held by this ontology
get_relationship_types
Usage - $ontology->get_relationship_types()
Returns - a reference to an array with the relationship types (CCO::Core::RelationshipType) held by this ontology
Args - none
Function - returns the relationship types held by this ontology
get_relationships_by_source_term
Usage - $ontology->get_relationships_by_source_term($source_term)
Returns - a reference to an array with the relationship (CCO::Core::Relationship) connecting this term to its children
Args - the term (CCO::Core::Term) for which its relationships will be found out
Function - returns the relationships associated to the given source term
get_relationships_by_target_term
Usage - $ontology->get_relationships_by_target_term($target_term)
Returns - a reference to an array with the relationship (CCO::Core::Relationship) connecting this term to its parents
Args - the term (CCO::Core::Term) for which its relationships will be found out
Function - returns the relationships associated to the given target term
get_term_by_id
Usage - $ontology->get_term_by_id($id)
Returns - the term (CCO::Core::Term) associated to the given ID
Args - the term's ID (string)
Function - returns the term associated to the given ID
set_term_id
Usage - $ontology->set_term_id($term, $new_id)
Returns - the term (CCO::Core::Term) with its new ID
Args - the term (CCO::Core::Term) and its new term's ID (string)
Function - sets a new term ID for the given term
get_relationship_type_by_id
Usage - $ontology->get_relationship_type_by_id($id)
Returns - the relationship type (CCO::Core::RelationshipType) associated to the given id
Args - the relationship type's id (string)
Function - returns the relationship type associated to the given id
get_term_by_name
Usage - $ontology->get_term_by_name($name)
Returns - the term (CCO::Core::Term) associated to the given name
Args - the term's name (string)
Function - returns the term associated to the given name
get_terms_by_name
Usage - $ontology->get_terms_by_name($name)
Returns - the term set (CCO::Util::TermSet) with all the terms (CCO::Core::Term) having $name in their names
Args - the term's name (string)
Function - returns the terms having $name in their names
get_relationship_type_by_name
Usage - $ontology->get_relationship_type_by_name($name)
Returns - the relationship type (CCO::Core::RelationshipType) associated to the given name
Args - the relationship type's name (string)
Function - returns the relationship type associated to the given name
add_relationship
Usage - $ontology->add_relationship($relationship)
Returns - none
Args - the relationship (CCO::Core::Relationship) to be added between two existing terms or two relationship types
Function - adds a relationship between two terms or relationship types
get_relationship_by_id
Usage - print $ontology->get_relationship_by_id()
Returns - the relationship (CCO::Core::Relationship) associated to the given id
Args - the relationship id (string)
Function - returns the relationship associated to the given relationship id
get_child_terms
Usage - $ontology->get_child_terms($term)
Returns - a reference to an array with the child terms (CCO::Core::Term) of the given term
Args - the term (CCO::Core::Term) for which the children will be found
Function - returns the child terms of the given term
get_parent_terms
Usage - $ontology->get_parent_terms($term)
Returns - a reference to an array with the parent terms (CCO::Core::Term) of the given term
Args - the term (CCO::Core::Term) for which the parents will be found
Function - returns the parent terms of the given term
get_head_by_relationship_type
Usage - $ontology->get_head_by_relationship_type($term, $relationship_type) or $ontology->get_head_by_relationship_type($rel_type, $relationship_type)
Returns - a reference to an array of terms (CCO::Core::Term) or relationship types (CCO::Core::RelationshipType) pointed out by the relationship of the given type; otherwise undef
Args - the term (CCO::Core::Term) or relationship type (CCO::Core::RelationshipType) and the pointing relationship type (CCO::Core::RelationshipType)
Function - returns the terms or relationship types pointed out by the relationship of the given type
get_tail_by_relationship_type
Usage - $ontology->get_tail_by_relationship_type($term, $relationship_type) or $ontology->get_tail_by_relationship_type($rel_type, $relationship_type)
Returns - a reference to an array of terms (CCO::Core::Term) or relationship types (CCO::Core::RelationshipType) pointing out the given term by means of the given relationship type; otherwise undef
Args - the term (CCO::Core::Term) or relationship type (CCO::Core::RelationshipType) and the relationship type (CCO::Core::RelationshipType)
Function - returns the terms or relationship types pointing out the given term by means of the given relationship type
get_number_of_terms
Usage - $ontology->get_number_of_terms()
Returns - the number of terms held by this ontology
Args - none
Function - returns the number of terms held by this ontology
get_number_of_relationships
Usage - $ontology->get_number_of_relationships()
Returns - the number of relationships held by this ontology
Args - none
Function - returns the number of relationships held by this ontology
get_number_of_relationship_types
Usage - $ontology->get_number_of_relationship_types()
Returns - the number of relationship types held by this ontology
Args - none
Function - returns the number of relationship types held by this ontology
export
Usage - $ontology->export($file_handle, $export_format)
Returns - exports this ontology
Args - the file handle (STDOUT, STDERR, ...) and the format: obo (by default), xml, owl, dot, gml, xgmml, sbml. Default file handle: STDOUT.
Function - exports this ontology
subontology_by_terms
Usage - $ontology->subontology_by_terms($term_set)
Returns - a subontology with the given terms from this ontology
Args - the terms (CCO::Util::TermSet) that will be included in the subontology
Function - creates a subontology based on the given terms from this ontology
obo_id2owl_id
Usage - $ontology->obo_id2owl_id($term)
Returns - the ID for OWL representation.
Args - the OBO-type ID.
Function - Transform an OBO-type ID into an OWL-type one. E.g. CCO:I1234567 -> CCO_I1234567
get_descendent_terms
Usage - $ontology->get_descendent_terms($term)
Returns - a set with the descendent terms (CCO::Core::Term) of the given term
Args - the term (CCO::Core::Term) for which all the descendent will be found
Function - returns recursively all the child terms of the given term
get_ancestor_terms
Usage - $ontology->get_ancestor_terms($term)
Returns - a set with the ancestor terms (CCO::Core::Term) of the given term
Args - the term (CCO::Core::Term) for which all the ancestors will be found
Function - returns recursively all the parent terms of the given term
get_descendent_terms_by_subnamespace
Usage - $ontology->get_descendent_terms_by_subnamespace($term, subnamespace)
Returns - a set with the descendent terms (CCO::Core::Term) of the given subnamespace
Args - the term (CCO::Core::Term), the subnamespace (string, e.g. 'P', 'R' etc)
Function - returns recursively the given term's children of the given subnamespace
get_ancestor_terms_by_subnamespace
Usage - $ontology->get_ancestor_terms_by_subnamespace($term, subnamespace)
Returns - a set with the ancestor terms (CCO::Core::Term) of the given subnamespace
Args - the term (CCO::Core::Term), the subnamespace (string, e.g. 'P', 'R' etc)
Function - returns recursively the given term's parents of the given subnamespace
get_descendent_terms_by_relationship_type
Usage - $ontology->get_descendent_terms_by_relationship_type($term, $rel_type)
Returns - a set with the descendent terms (CCO::Core::Term) of the given term linked by the given relationship type
Args - CCO::Core::Term object, CCO::Core::RelationshipType object
Function - returns recursively all the child terms of the given term linked by the given relationship type
get_ancestor_terms_by_relationship_type
Usage - $ontology->get_ancestor_terms_by_relationship_type($term, $rel_type)
Returns - a set with the ancestor terms (CCO::Core::Term) of the given term linked by the given relationship type
Args - CCO::Core::Term object, CCO::Core::RelationshipType object
Function - returns recursively the parent terms of the given term linked by the given relationship type
get_ancestor_terms_by_relationship_type
Usage - $ontology->create_rel->($tail, $head, $type)
Returns - CCO::Core::Ontology object
Args - CCO::Core::(Term|Relationship) object, CCO::Core::(Term|Relationship) object, relationship type string
Function - creates and adds to the ontology a new relationship
NAME
CCO::Core::Ontology - an ontology
SYNOPSIS
use CCO::Core::Ontology; use CCO::Core::Term; use CCO::Core::Relationship; use CCO::Core::RelationshipType; use strict;
# three new terms my $n1 = CCO::Core::Term->new(); my $n2 = CCO::Core::Term->new(); my $n3 = CCO::Core::Term->new();
# new ontology my $onto = CCO::Core::Ontology->new;
$n1->id("CCO:P0000001"); $n2->id("CCO:P0000002"); $n3->id("CCO:P0000003");
$n1->name("One"); $n2->name("Two"); $n3->name("Three");
my $def1 = CCO::Core::Def->new(); $def1->text("Definition of One"); my $def2 = CCO::Core::Def->new(); $def2->text("Definition of Two"); my $def3 = CCO::Core::Def->new(); $def3->text("Definition of Three"); $n1->def($def1); $n2->def($def2); $n3->def($def3);
$onto->add_term($n1); $onto->add_term($n2); $onto->add_term($n3);
$onto->delete_term($n1);
$onto->add_term($n1);
# new term my $n4 = CCO::Core::Term->new(); $n4->id("CCO:P0000004"); $n4->name("Four"); my $def4 = CCO::Core::Def->new(); $def4->text("Definition of Four"); $n4->def($def4); $onto->delete_term($n4); $onto->add_term($n4);
# add term as string my $new_term = $onto->add_term_as_string("CCO:P0000005", "Five"); $new_term->def_as_string("This is a dummy definition", "[CCO:vm, CCO:ls, CCO:ea \"Erick Antezana\"]"); my $n5 = $new_term;
# five new relationships my $r12 = CCO::Core::Relationship->new(); my $r23 = CCO::Core::Relationship->new(); my $r13 = CCO::Core::Relationship->new(); my $r14 = CCO::Core::Relationship->new(); my $r35 = CCO::Core::Relationship->new();
$r12->id("CCO:P0000001_is_a_CCO:P0000002"); $r23->id("CCO:P0000002_part_of_CCO:P0000003"); $r13->id("CCO:P0000001_participates_in_CCO:P0000003"); $r14->id("CCO:P0000001_participates_in_CCO:P0000004"); $r35->id("CCO:P0000003_part_of_CCO:P0000005");
$r12->type("is_a"); $r23->type("part_of"); $r13->type("participates_in"); $r14->type("participates_in"); $r35->type("part_of");
$r12->link($n1, $n2); $r23->link($n2, $n3); $r13->link($n1, $n3); $r14->link($n1, $n4); $r35->link($n3, $n5);
# get all terms my $c = 0; my %h; foreach my $t (@{$onto->get_terms()}) { $h{$t->id()} = $t; $c++; }
# get terms with argument my @processes = sort {$a->id() cmp $b->id()} @{$onto->get_terms("CCO:P.*")}; my @odd_processes = sort {$a->id() cmp $b->id()} @{$onto->get_terms("CCO:P000000[35]")}; $onto->namespace("CCO"); my @same_processes = @{$onto->get_terms_by_subnamespace("P")}; my @no_processes = @{$onto->get_terms_by_subnamespace("p")};
# get terms
# add relationships $onto->add_relationship($r12); $onto->add_relationship($r23); $onto->add_relationship($r13); $onto->add_relationship($r14); $onto->add_relationship($r35);
# add relationships and terms linked by this relationship my $n11 = CCO::Core::Term->new(); my $n21 = CCO::Core::Term->new(); $n11->id("CCO:P0000011"); $n11->name("One one"); $n11->def_as_string("Definition One one", ""); $n21->id("CCO:P0000021"); $n21->name("Two one"); $n21->def_as_string("Definition Two one", ""); my $r11_21 = CCO::Core::Relationship->new(); $r11_21->id("CCO:R0001121"); $r11_21->type("r11-21"); $r11_21->link($n11, $n21); $onto->add_relationship($r11_21); # adds to the ontology the terms linked by this relationship
# get all relationships my %hr; foreach my $r (@{$onto->get_relationships()}) { $hr{$r->id()} = $r; }
# recover a previously stored relationship
# get children my @children = @{$onto->get_child_terms($n1)};
@children = @{$onto->get_child_terms($n3)}; my %ct; foreach my $child (@children) { $ct{$child->id()} = $child; }
@children = @{$onto->get_child_terms($n2)};
# get parents my @parents = @{$onto->get_parent_terms($n3)}; @parents = @{$onto->get_parent_terms($n1)}; @parents = @{$onto->get_parent_terms($n2)};
# get all descendents my @descendents1 = @{$onto->get_descendent_terms($n1)}; my @descendents2 = @{$onto->get_descendent_terms($n2)}; my @descendents3 = @{$onto->get_descendent_terms($n3)}; my @descendents5 = @{$onto->get_descendent_terms($n5)};
# get all ancestors my @ancestors1 = @{$onto->get_ancestor_terms($n1)}; my @ancestors2 = @{$onto->get_ancestor_terms($n2)}; my @ancestors3 = @{$onto->get_ancestor_terms($n3)};
# get descendents by term subnamespace my @descendents4 = @{$onto->get_descendent_terms_by_subnamespace($n1, 'P')}; my @descendents5 = @{$onto->get_descendent_terms_by_subnamespace($n2, 'P')}; my @descendents6 = @{$onto->get_descendent_terms_by_subnamespace($n3, 'P')}; my @descendents6 = @{$onto->get_descendent_terms_by_subnamespace($n3, 'R')};
# get ancestors by term subnamespace my @ancestors4 = @{$onto->get_ancestor_terms_by_subnamespace($n1, 'P')}; my @ancestors5 = @{$onto->get_ancestor_terms_by_subnamespace($n2, 'P')}; my @ancestors6 = @{$onto->get_ancestor_terms_by_subnamespace($n3, 'P')}; my @ancestors6 = @{$onto->get_ancestor_terms_by_subnamespace($n3, 'R')};
# three new relationships types my $r1 = CCO::Core::RelationshipType->new(); my $r2 = CCO::Core::RelationshipType->new(); my $r3 = CCO::Core::RelationshipType->new();
$r1->id("CCO:R0000001"); $r2->id("CCO:R0000002"); $r3->id("CCO:R0000003");
$r1->name("is_a"); $r2->name("part_of"); $r3->name("participates_in");
# add relationship types $onto->add_relationship_type($r1); $onto->add_relationship_type($r2); $onto->add_relationship_type($r3);
# get descendents or ancestors linked by a particular relationship type my $rel_type1 = $onto->get_relationship_type_by_name("is_a"); my $rel_type2 = $onto->get_relationship_type_by_name("part_of"); my $rel_type3 = $onto->get_relationship_type_by_name("participates_in");
my @descendents7 = @{$onto->get_descendent_terms_by_relationship_type($n5, $rel_type1)}; @descendents7 = @{$onto->get_descendent_terms_by_relationship_type($n5, $rel_type2)}; @descendents7 = @{$onto->get_descendent_terms_by_relationship_type($n2, $rel_type1)}; @descendents7 = @{$onto->get_descendent_terms_by_relationship_type($n3, $rel_type3)};
my @ancestors7 = @{$onto->get_ancestor_terms_by_relationship_type($n1, $rel_type1)}; @ancestors7 = @{$onto->get_ancestor_terms_by_relationship_type($n1, $rel_type2)}; @ancestors7 = @{$onto->get_ancestor_terms_by_relationship_type($n1, $rel_type3)}; @ancestors7 = @{$onto->get_ancestor_terms_by_relationship_type($n2, $rel_type2)};
# add relationship type as string my $relationship_type = $onto->add_relationship_type_as_string("CCO:R0000004", "has_participant");
# get relationship types my @rt = @{$onto->get_relationship_types()}; my %rrt; foreach my $relt (@rt) { $rrt{$relt->name()} = $relt; }
my @rtbt = @{$onto->get_relationship_types_by_term($n1)};
my %rtbth; foreach my $relt (@rtbt) { $rtbth{$relt} = $relt; }
# get_head_by_relationship_type my @heads_n1 = @{$onto->get_head_by_relationship_type($n1, $onto->get_relationship_type_by_name("participates_in"))}; my %hbrt; foreach my $head (@heads_n1) { $hbrt{$head->id()} = $head; }
DESCRIPTION
This module has several methods to work with Ontologies in OBO and OWL formats, such as the Cell Cycle Ontology (http://www.cellcycleontology.org). Basically, it is a directed acyclic graph (DAG) holding the terms (CCO::Core::Term) which in turn are linked by relationships (CCO::Core::Relationship). These relationships have an associated relationship type (CCO::Core::RelationshipType).
AUTHOR
Erick Antezana, <erant@psb.ugent.be>
COPYRIGHT AND LICENSE
Copyright (C) 2006 by erant
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.