Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/OntologyXref.pm @ 0:1f6dce3d34e0
Uploaded
| author | mahtabm |
|---|---|
| date | Thu, 11 Apr 2013 02:01:53 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1f6dce3d34e0 |
|---|---|
| 1 =head1 LICENSE | |
| 2 | |
| 3 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
| 4 Genome Research Limited. All rights reserved. | |
| 5 | |
| 6 This software is distributed under a modified Apache license. | |
| 7 For license details, please see | |
| 8 | |
| 9 http://www.ensembl.org/info/about/code_licence.html | |
| 10 | |
| 11 =head1 CONTACT | |
| 12 | |
| 13 Please email comments or questions to the public Ensembl | |
| 14 developers list at <dev@ensembl.org>. | |
| 15 | |
| 16 Questions may also be sent to the Ensembl help desk at | |
| 17 <helpdesk@ensembl.org>. | |
| 18 | |
| 19 =cut | |
| 20 | |
| 21 =head1 NAME | |
| 22 | |
| 23 Bio::EnsEMBL::OntologyXref | |
| 24 | |
| 25 =head1 DESCRIPTION | |
| 26 | |
| 27 This class extends the DBEntry in order to associate Evidence Tags | |
| 28 to the relationship between EnsEMBL objects and ontology accessions | |
| 29 (primarily GO accessions). | |
| 30 | |
| 31 The relationship to GO that is stored in the database is actually | |
| 32 derived through the relationship of EnsEMBL peptides to SwissProt | |
| 33 peptides, i.e. the relationship is derived like this: | |
| 34 | |
| 35 ENSP -> SWISSPROT -> GO | |
| 36 | |
| 37 And the evidence tag describes the relationship between the SwissProt | |
| 38 Peptide and the GO entry. | |
| 39 | |
| 40 In reality, however, we store this in the database like this: | |
| 41 | |
| 42 ENSP -> SWISSPROT | |
| 43 ENSP -> GO | |
| 44 | |
| 45 and the evidence tag hangs off of the relationship between the ENSP and | |
| 46 the GO identifier. Some ENSPs are associated with multiple closely | |
| 47 related Swissprot entries which may both be associated with the same GO | |
| 48 identifier but with different evidence tags. For this reason a single | |
| 49 'OntologyXref' can have multiple evidence tags. | |
| 50 | |
| 51 =head1 SYNOPSIS | |
| 52 | |
| 53 my $ontology_xref = Bio::EnsEMBL::OntologyXref->new(); | |
| 54 $ontology_xref->add_linkage_type('IEA'); | |
| 55 | |
| 56 foreach my $evtag ( @{ $ontology_xref->get_all_linkage_types() } ) { | |
| 57 print "$evtag\n"; | |
| 58 } | |
| 59 | |
| 60 =head1 METHODS | |
| 61 | |
| 62 =cut | |
| 63 | |
| 64 package Bio::EnsEMBL::OntologyXref; | |
| 65 | |
| 66 use strict; | |
| 67 | |
| 68 use base qw( Bio::EnsEMBL::DBEntry ); | |
| 69 | |
| 70 =head2 add_linkage_type | |
| 71 | |
| 72 Arg [1] : string $value | |
| 73 allowed values: | |
| 74 'IC', 'IDA', 'IEA', 'IEP', 'IGI', 'IMP', 'IPI', | |
| 75 'ISS', NAS', 'ND', 'TAS', 'NR', 'RCA' | |
| 76 Arg [2] : (optional) Bio::EnsEMBL::DBEntry $source | |
| 77 Example : $ontology_xref->add_linkage_type('IGI'); | |
| 78 Description: Associates a linkage type and source DBEntry with | |
| 79 this ontology_xref | |
| 80 Returntype : integer; number of linkages | |
| 81 Exceptions : thrown if $linkage_type argument not supplied or | |
| 82 the optional DBEntry is not a DBEntry object. | |
| 83 Caller : DBEntryAdaptor | |
| 84 Status : Experimantal | |
| 85 | |
| 86 =cut | |
| 87 | |
| 88 sub add_linkage_type { | |
| 89 my ( $self, $lt, $source_dbentry ) = @_; | |
| 90 | |
| 91 if ( !defined($lt) ) { | |
| 92 $self->throw("linkage type argument required"); | |
| 93 } | |
| 94 | |
| 95 if ( defined($source_dbentry) | |
| 96 && !$source_dbentry->isa('Bio::EnsEMBL::DBEntry') ) | |
| 97 { | |
| 98 $self->throw("source_dbentry must be a Bio::EnsEMBL::DBEntry"); | |
| 99 } | |
| 100 | |
| 101 $self->{'linkage_types'} ||= []; | |
| 102 | |
| 103 push @{ $self->{'linkage_types'} }, | |
| 104 [ $lt, ( $source_dbentry || () ) ]; | |
| 105 } | |
| 106 | |
| 107 | |
| 108 =head2 get_all_linkage_info | |
| 109 | |
| 110 Arg [1] : none | |
| 111 Example : | |
| 112 | |
| 113 foreach ( @{ $ontology_xref->get_all_linkage_info() } ) { | |
| 114 print "evidence: $_->[0] via $_->[1]->display_id"; | |
| 115 } | |
| 116 | |
| 117 Description: Retrieves a list of evidence-tag/source-DBEntry pairs | |
| 118 associated with this ontology_xref | |
| 119 Returntype : listref of listrefs | |
| 120 Exceptions : none | |
| 121 Caller : geneview? general. | |
| 122 Status : Experimental | |
| 123 | |
| 124 =cut | |
| 125 | |
| 126 sub get_all_linkage_info { | |
| 127 my ($self) = @_; | |
| 128 | |
| 129 return $self->{'linkage_types'} || []; | |
| 130 } | |
| 131 | |
| 132 | |
| 133 =head2 get_all_linkage_types | |
| 134 | |
| 135 Arg [1] : none | |
| 136 Example : | |
| 137 | |
| 138 print( join( ' ', @{ $ontology_xref->get_all_linkage_types() } ), | |
| 139 "\n" ); | |
| 140 | |
| 141 Description: Retrieves a unique list of evidence tags associated with | |
| 142 this ontology_xref | |
| 143 Returntype : none | |
| 144 Exceptions : none | |
| 145 Caller : geneview? general | |
| 146 Status : Stable | |
| 147 | |
| 148 =cut | |
| 149 | |
| 150 sub get_all_linkage_types { | |
| 151 my ($self) = @_; | |
| 152 | |
| 153 my %seen; | |
| 154 return [ grep { !$seen{$_}++ } | |
| 155 map { $_->[0] } @{ $self->{'linkage_types'} } ]; | |
| 156 | |
| 157 #return [ map{ $_->[0]} @{ $self->{'linkage_types'} || [] } ]; | |
| 158 } | |
| 159 | |
| 160 | |
| 161 =head2 flush_linkage_types | |
| 162 | |
| 163 Arg [1] : none | |
| 164 Example : $ontology_xref->flush_linkage_types(); | |
| 165 Description: Removes any associated evidence tags | |
| 166 Returntype : none | |
| 167 Exceptions : none | |
| 168 Caller : general | |
| 169 Status : Stable | |
| 170 | |
| 171 =cut | |
| 172 | |
| 173 sub flush_linkage_types { | |
| 174 my ($self) = @_; | |
| 175 | |
| 176 $self->{'linkage_types'} = []; | |
| 177 } | |
| 178 | |
| 179 1; |
