3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
37 This
class extends the DBEntry in order to associate Evidence Tags
38 to the relationship between
EnsEMBL objects and ontology accessions
39 (primarily GO accessions).
41 The relationship to GO that is stored in the database is actually
42 derived through the relationship of
EnsEMBL peptides to SwissProt
43 peptides, i.e. the relationship is derived like this:
45 ENSP -> SWISSPROT -> GO
47 And the evidence tag describes the relationship between the SwissProt
48 Peptide and the GO entry.
50 In reality, however, we store this in the database like this:
55 and the evidence tag hangs off of the relationship between the ENSP and
56 the GO identifier. Some ENSPs are associated with multiple closely
57 related Swissprot entries which may both be associated with the same GO
58 identifier but with different evidence tags. For this reason a single
64 $ontology_xref->add_linkage_type('IEA');
66 foreach my $evtag ( @{ $ontology_xref->get_all_linkage_types() } ) {
74 package Bio::EnsEMBL::OntologyXref;
83 =head2 get_OntologyTerm
85 Example : $ontology_xref->get_OntologyTerm();
86 Description: Queries the OntologyTermAdaptor
for a term which is the same
87 as the primary
id of
this object. This method requires a
89 If you have loaded data from an Ensembl release
using
100 sub get_OntologyTerm {
103 foreach my $ontology_dba (@{$dbas}) {
104 my $ota = $ontology_dba->get_OntologyTermAdaptor();
105 my $term = $ota->fetch_by_accession($self->primary_id());
106 return $term
if $term;
111 =head2 add_linkage_type
113 Arg [1] :
string $value
115 'IC',
'IDA',
'IEA',
'IEP',
'IGI',
'IMP',
'IPI',
116 'ISS', NAS
', 'ND
', 'TAS
', 'NR
', 'RCA
'
117 Arg [2] : (optional) Bio::EnsEMBL::DBEntry $source
118 Example : $ontology_xref->add_linkage_type('IGI
');
119 Description: Associates a linkage type and source DBEntry with
121 Returntype : integer; number of linkages
122 Exceptions : thrown if $linkage_type argument not supplied or
123 the optional DBEntry is not a DBEntry object.
124 Caller : DBEntryAdaptor
125 Status : Experimantal
129 sub add_linkage_type {
130 my ( $self, $lt, $source_dbentry ) = @_;
132 if ( !defined($lt) ) {
133 $self->throw("linkage type argument required");
136 if ( defined($source_dbentry)
139 $self->throw("source_dbentry must be a Bio::EnsEMBL::DBEntry");
142 $self->{'linkage_types
'} ||= [];
144 push @{ $self->{'linkage_types
'} },
145 [ $lt, ( $source_dbentry || () ) ];
149 =head2 get_all_linkage_info
154 foreach ( @{ $ontology_xref->get_all_linkage_info() } ) {
155 print "evidence: $_->[0] via $_->[1]->display_id";
158 Description: Retrieves a list of evidence-tag/source-DBEntry pairs
159 associated with this ontology_xref
160 Returntype : listref of listrefs
162 Caller : geneview? general.
163 Status : Experimental
167 sub get_all_linkage_info {
170 return $self->{'linkage_types
'} || [];
174 =head2 get_all_linkage_types
179 print( join( ' ', @{ $ontology_xref->get_all_linkage_types() } ),
182 Description: Retrieves a unique list of evidence tags associated with
186 Caller : geneview? general
191 sub get_all_linkage_types {
195 return [ grep { !$seen{$_}++ }
196 map { $_->[0] } @{ $self->{'linkage_types
'} } ];
198 #return [ map{ $_->[0]} @{ $self->{'linkage_types
'} || [] } ];
202 =head2 flush_linkage_types
205 Example : $ontology_xref->flush_linkage_types();
206 Description: Removes any associated evidence tags
214 sub flush_linkage_types {
217 $self->{'linkage_types
'} = [];
221 =head2 add_associated_xref
223 Arg [1] : Bio::EnsEMBL::DBEntry $associated_xref
224 or an Array of Bio::EnsEMBL::DBEntry for compound annotations
225 Arg [2] : Bio::EnsEMBL::DBEntry $source_dbentry
226 Arg [3] : string $condition_type or an Array of string $condition_types
227 matching the order of Arg[1] for compound queries.
228 Arg [4] : (optional) Integer $group id for compound annotations.
229 Arg [5] : (optional) Integer $rank order for a term within a compound annotation.
230 Example : $ontology_xref->add_associated_xref(
236 Description: Associates a linkage type and source DBEntry with
239 Exceptions : thrown if $linkage_type argument not supplied or
240 the optional DBEntry is not a DBEntry object.
241 Caller : DBEntryAdaptor
242 Status : Experimantal
246 sub add_associated_xref {
247 my ( $self, $associated_xref, $source_dbentry, $condition_type, $group, $rank ) = @_;
248 if ( ref($associated_xref) eq 'ARRAY
' )
250 foreach my $e ( @{ $associated_xref } ) {
252 $self->throw("associated_xref must be a Bio::EnsEMBL::DBEntry or an
253 Array of Bio::EnsEMBL::DBEntry objects.");
256 } elsif ( defined($associated_xref)
259 $self->throw("associated_xref must be a Bio::EnsEMBL::DBEntry or an Array
260 of Bio::EnsEMBL::DBEntry objects.");
263 if ( defined($source_dbentry)
266 $self->throw("source_dbentry must be a Bio::EnsEMBL::DBEntry");
269 if ( !defined $condition_type ) {
270 $self->throw("condition must be a string");
273 if (!defined $group) {
274 $group = 1 + scalar keys %{ $self->{'associated_xref
'} };
277 if (!defined $rank) {
279 $rank = 1 + scalar keys %{ $self->{'associated_xref
'}->{ $group } };
282 $self->{'associated_xref
'} ||= {};
284 $self->{'associated_xref
'}->{ $group }->{$rank} =
285 [ $associated_xref, $source_dbentry, $condition_type ];
289 =head2 add_linked_associated_xref
291 Arg [1] : Bio::EnsEMBL::DBEntry $associated_xref
292 or an Array of Bio::EnsEMBL::DBEntry for compound annotations
293 Arg [2] : Bio::EnsEMBL::DBEntry $source_dbentry
294 Arg [3] : string $condition_type or an Array of string $condition_types
295 matching the order of Arg[1] for compound queries.
296 Arg [4] : Integer $group id.
297 Arg [5] : Integer $rank id.
298 Example : $ontology_xref->add_associated_xref(
304 Description: Associates a linkage type and source DBEntry with this
305 ontology_xref that have come from the same annotation source
307 Exceptions : thrown if $linkage_type argument not supplied or
308 the optional DBEntry is not a DBEntry object.
309 Caller : DBEntryAdaptor
310 Status : Experimantal
314 sub add_linked_associated_xref {
315 my ( $self, $associated_xref, $source_dbentry, $condition_type, $associate_group_id, $associate_group_rank ) = @_;
317 if ( !defined($associated_xref) )
319 $self->throw("associated_xref must be a Bio::EnsEMBL::DBEntry or an Array
320 of Bio::EnsEMBL::DBEntry objects.");
323 if ( defined($associated_xref)
326 $self->throw("associated_xref must be a Bio::EnsEMBL::DBEntry or an Array
327 of Bio::EnsEMBL::DBEntry objects.");
330 if ( defined($source_dbentry)
333 $self->throw("source_dbentry must be a Bio::EnsEMBL::DBEntry");
336 if ( !defined $condition_type ) {
337 $self->throw("condition must be a string");
340 if ( !defined $associate_group_id )
342 $self->throw("$associate_group_id must be an integer");
345 if ( !defined $associate_group_rank )
347 $self->throw("$associate_group_rank must be an integer");
350 # print "\t" . $associate_group_id;
351 # print "\t" . $associate_group_rank;
352 # print "\t|" . defined($associated_xref) . '|
';
353 # #print "\t" . defined($associated_xref->primary_id);
354 # print "\t" . $associated_xref->primary_id;# . ' (
' . $associated_xref->display_id . ')
';
355 # print "\t" . $source_dbentry->primary_id;
356 # print "\t" . $condition_type . "\n";
358 my $associated_xref_array = {};
359 my $matching_link = 0;
361 my $load_postion = 0;
362 if ( !defined $self->{'associated_xref
'} ) {
363 $associated_xref_array->{$associate_group_id}->{$associate_group_rank} = [
370 $associated_xref_array = $self->{'associated_xref
'};
372 if (!defined $associated_xref_array->{$associate_group_id} ) {
373 $associated_xref_array->{$associate_group_id}->{$associate_group_rank} = [
380 my $already_loaded = 0;
381 foreach my $rank ( keys %{$associated_xref_array->{$associate_group_id}} ) {
382 my @ax_gr_set = @{ $associated_xref_array->{$associate_group_id}->{$rank} };
384 $ax_gr_set[0]->primary_id eq $associated_xref->primary_id &&
385 $ax_gr_set[1]->primary_id eq $source_dbentry->primary_id &&
386 $ax_gr_set[2] eq $condition_type
393 if ( !$already_loaded ) {
394 if (!defined $associated_xref_array->{$associate_group_id}->{$associate_group_rank} ) {
395 $associated_xref_array->{$associate_group_id}->{$associate_group_rank} = [
402 $associated_xref_array->{$associate_group_id}->{scalar keys %{ $associated_xref_array->{$associate_group_id} }} = [
412 $self->{'associated_xref
'} = $associated_xref_array;
413 # print "\t\tLoaded at " . $load_postion . "\n";
414 # if ($associate_group_id == 28792 || $associate_group_id == 28793) {
415 # print Data::Dumper->Dumper([$self->{'associated_xref
'}]);
420 =head2 get_all_associated_xrefs
425 foreach ( @{ $ontology_xref->get_all_associated_xref() } ) {
426 print "evidence: $_->[0] via $_->[1]->display_id";
429 Description: Retrieves a list of associated-DBEntry/source-DBEntry/condition
430 sets associated with this ontology_xref
431 Returntype : listref of listrefs
433 Caller : geneview? general.
434 Status : Experimental
438 sub get_all_associated_xrefs {
441 return $self->{'associated_xref
'} || {};
444 =head2 get_extensions
449 print Dumper @{ $ontology_xref->get_extensions_for_web() }
453 'source
' => '<a href=
"<Link to CiteXplore>">11937031</a>
',
455 'description
' => '<strong>has_direct_input</strong>
456 <a href=
"http://www.pombase.org/gene/SPBC32F12.09">
461 Description: Retrieves a list of associated-DBEntry/source-DBEntry/condition
462 sets associated with this ontology_xref and formats them ready
463 for web display in a group per row fashion.
464 The accessions for ontologies are linkable. Extra links need to
465 be added for each distinct database that is reference.
466 Returntype : listref of hashrefs
469 Status : Experimental
474 if ( !defined $self->{'associated_xref
'} ) {
478 my @annotExtRows = ();
480 my %external_urls = (
482 'GO_REF' =>
'http://www.geneontology.org/cgi-bin/references.cgi#',
483 'SO' =>
'http://www.sequenceontology.org/miso/current_cvs/term/',
484 #
'MOD' =>
'href=mod',
485 'PomBase' =>
'http://www.pombase.org/gene/',
486 'PomBase_Systematic_ID' =>
'http://www.pombase.org/gene/',
487 'PUBMED' =>
'http://europepmc.org/abstract/MED/'
490 foreach my $groupId (keys %{ $self->{
'associated_xref'} } ) {
491 my $description =
'';
495 foreach my $rank ( keys %{ $self->{
'associated_xref'}->{$groupId} } ) {
496 if ( $self->{
'associated_xref'}->{$groupId}->{$rank}->[2]
498 if ( exists $external_urls{$self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->
dbname} ) {
499 $evidence =
'<a href="' . $external_urls{$self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->dbname}
500 . $self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->primary_id .
'">'
501 . $self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->display_id
504 $evidence = $self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->display_id;
507 if (length $description > 0) {
508 $description .=
', ';
510 $description .=
'<strong>' . $self->{
'associated_xref'}->{$groupId}->{$rank}->[2] .
'</strong> ';
512 if (exists $external_urls{$self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->dbname} ) {
513 $description .=
'<a href="' . $external_urls{$self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->dbname}
514 . $self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->primary_id .
'">'
515 . $self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->display_id
518 $description .= $self->{
'associated_xref'}->{$groupId}->{$rank}->[0]->display_id;
524 if ( !undef $external_urls{$self->{
'associated_xref'}->{$groupId}->{$rank}->[1]} ) {
525 if ( exists $external_urls{$self->{
'associated_xref'}->{$groupId}->{$rank}->[1]->dbname} ) {
526 $source =
'<a href="' . $external_urls{$self->{
'associated_xref'}->{$groupId}->{$rank}->[1]->dbname}
527 . $self->{
'associated_xref'}->{$groupId}->{$rank}->[1]->primary_id .
'">';
528 if ( $self->{
'associated_xref'}->{$groupId}->{$rank}->[1]->dbname ne
'GO_REF' ) {
531 $source .= $self->{
'associated_xref'}->{$groupId}->{$rank}->[1]->display_id .
'</a>';
532 } elsif ($self->{
'associated_xref'}->{$groupId}->{$rank}->[1]->display_id eq
'PMPB:0') {
535 $source = $self->{
'associated_xref'}->{$groupId}->{$rank}->[1]->display_id;
540 if ($evidence ne
'' and $description ne
'') {
541 my %row = (
'description' => $description,
542 'evidence' => $evidence,
543 'source' => $source);
544 push @annotExtRows, (\%row);
548 return \@annotExtRows;