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

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

comment

Usage    - print $ontology->comment()
Returns  - the comment (string) of the ontology
Args     - the comment (string) of the ontology
Function - gets/sets the comment of the 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_relationship_type

Usage    - print $ontology->has_relationship_type($relationship_type)
Returns  - true or false
Args     - the relationship (CCO::Core::Relationship) type to be tested
Function - checks if the given relationship type belongs to this ontology

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_relationship_types_by_term

Usage    - $ontology->get_relationship_types_by_term($term)
Returns  - a reference to an array with the relationship types (CCO::Core::RelationshipType) held by this ontology
Args     - the term (CCO::Core::Term) for which its relationship types will be found
Function - returns the relationship types associated to the given 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

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_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 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_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_recursive_child_terms

Usage    - $ontology->get_recursive_child_terms($term)
Returns  - a set with the child terms (CCO::Core::Term) of the given term
Args     - the term (CCO::Core::Term) for which all the children will be found
Function - returns all the child terms of the given term

get_parent_terms

Usage    - $ontology->get_parent_terms($term)
Returns  - 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_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. Default file handle: STDOUT.
Function - exports 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

NAME Core::Ontology - an ontology =head1 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\"]");

# three 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();

$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");

$r12->type("is_a"); $r23->type("part_of"); $r13->type("participates_in"); $r14->type("participates_in");

$r12->link($n1, $n2); $r23->link($n2, $n3); $r13->link($n1, $n3); $r14->link($n1, $n4);

# get all terms my $c = 0; my %h; foreach my $t (@{$onto->get_terms()}) { $h{$t->id()} = $t; $c++; }

# add relationships $onto->add_relationship($r12); $onto->add_relationship($r23); $onto->add_relationship($r13); $onto->add_relationship($r14);

# 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 linked terms by this relationship

# get all relationships my %hr; foreach my $r (@{$onto->get_relationships()}) { $hr{$r->id()} = $r; }

# get children my @children = @{$onto->get_child_terms($n1)}; my %ct; foreach my $child (@children) { $ct{$child->id()} = $child; }

@children = @{$onto->get_child_terms($n3)}; @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);

# 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);

# 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 cope with the CCO. Basically, it is a directed acyclic graph (DAG) holding the terms and nodes which in turn are linked by relationships. These relationships have an associated relationship type.

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.