- Find all the terms in a given ontology:
use OBO::Parser::OBOParser;
my $my_parser = OBO::Parser::OBOParser->new();
my $ontology = $my_parser->work("gene_ontology_edit.obo");
my @my_terms = @{$ontology->get_terms()}; # get all the terms
foreach my $t (@my_terms) {
print "The name of the term is: ", $t->name(), ", and its ID is:", $t->id(), "\n";
}
- Find all the relationships in a given ontology:
use OBO::Parser::OBOParser;
my $my_parser = OBO::Parser::OBOParser->new();
my $ontology = $my_parser->work("my_obo_ontology.obo");
my @my_rels= @{$ontology->get_relationships()}; # get all the relationships
foreach my $r (@my_rels) {
print "The ID of the relationhip is: ", $r->id();
}
- Find all the terms using a regular expression for the ID:
use OBO::Parser::OBOParser;
my $my_parser = OBO::Parser::OBOParser->new();
my $ontology = $my_parser->work("my_obo_ontology.obo");
my @my_terms = @{$ontology->get_terms("CCO:G.*")}; # get all the terms with such an ID
foreach my $t (@my_terms) {
print "The name of the term is: ", $t->name();
}
- Get a specific term by name:
use OBO::Parser::OBOParser;
my $my_parser = OBO::Parser::OBOParser->new();
my $ontology = $my_parser->work("my_obo_ontology.obo");
my $my_term = $ontology->get_term_by_name("protein"); # get the term by name
print "The ID of my term is: ", $t->id();
- Get a specific term by ID:
use OBO::Parser::OBOParser;
my $my_parser = OBO::Parser::OBOParser->new();
my $ontology1 = $my_parser->work("go.obo");
my $ontology2 = $my_parser->work("cco.obo");
my $my_term1 = $ontology1->get_term_by_id("GO:00007049"); # get the term by ID
my $my_term2 = $ontology2->get_term_by_id("CCO:P0000056"); # get the term by ID
print "\nThe name of the term1 is: ", $my_term1->name();
print "\nThe name of the term2 is: ", $my_term2->name();