Skip to content
Snippets Groups Projects
Commit 465106e3 authored by Andy Yates's avatar Andy Yates
Browse files

[ENSCORESW-477]. Added methods to allow lookup of OntologyTerm from an OntologyXref

parent 465d3bc0
No related branches found
No related tags found
No related merge requests found
......@@ -64,9 +64,40 @@ identifier but with different evidence tags. For this reason a single
package Bio::EnsEMBL::OntologyXref;
use strict;
use warnings;
use base qw( Bio::EnsEMBL::DBEntry );
require Bio::EnsEMBL::Registry;
=head2 get_OntologyTerm
Example : $ontology_xref->get_OntologyTerm();
Description: Queries the OntologyTermAdaptor for a term which is the same
as the primary id of this object. This method requires a
OntologyDBAdaptor to be available in the Bio::EnsEMBL::Registry.
If you have loaded data from an Ensembl release using
Bio::EnsEMBL::Registry->load_registry_from_db() then this should
work.
Returntype : Bio::EnsEMBL::OntologyTerm
Exceptions : None
Caller : general
Status : Experimantal
=cut
sub get_OntologyTerm {
my ($self) = @_;
my $dbas = Bio::EnsEMBL::Registry->get_all_DBAdaptors(-GROUP => 'ontology');
foreach my $ontology_dba (@{$dbas}) {
my $ota = $ontology_dba->get_OntologyTermAdaptor();
my $term = $ota->fetch_by_accession($self->primary_id());
return $term if $term;
}
return;
}
=head2 add_linkage_type
Arg [1] : string $value
......
......@@ -14,21 +14,21 @@ use Bio::EnsEMBL::Translation;
use Bio::EnsEMBL::Gene;
use Bio::EnsEMBL::DnaDnaAlignFeature;
# switch on the debug prints
# switch on the note prints
our $verbose = 0;
debug("Startup test");
note("Startup test");
ok(1);
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new('ontology');
my $odb = $multi->get_DBAdaptor("ontology");
debug("Ontology database instatiated");
note("Ontology database instatiated");
ok($odb);
my $human = Bio::EnsEMBL::Test::MultiTestDB->new();
my $db = $human->get_DBAdaptor("core");
debug("Test database instatiated");
note("Test database instatiated");
ok($db);
my $go_adaptor = $odb->get_OntologyTermAdaptor();
......@@ -69,6 +69,16 @@ is(@{$go_roots}, 1, "Found go roots");
my $efo_roots = $go_adaptor->fetch_all_roots('efo');
is(@{$efo_roots}, 0, "Found no efo roots");
#Now go back to the OntologyXref & see if we can do the reverse lookup
{
my $go_db_links = $genes->[0]->get_all_DBLinks('GO');
foreach my $dbentry (@{$go_db_links}) {
my $term = $dbentry->get_OntologyTerm();
my $direct_term = $go_adaptor->fetch_by_accession($dbentry->primary_id());
is_deeply($term, $direct_term, 'Fetching the OntologyTerm from the OntologyXref should match the same object from OntologyTermAdaptor');
}
}
done_testing();
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment