0
|
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::OntologyTerm
|
|
24
|
|
25 =head1 DESCRIPTION
|
|
26
|
|
27 An ontology term object, (most often) created by
|
|
28 Bio::EnsEMBL::DBSQL::GOTermAdaptor and used in querying for
|
|
29 transcripts, genes, and translations using the relevant adaptors and
|
|
30 methods.
|
|
31
|
|
32 =head1 METHODS
|
|
33
|
|
34 =cut
|
|
35
|
|
36 package Bio::EnsEMBL::OntologyTerm;
|
|
37
|
|
38 use strict;
|
|
39 use warnings;
|
|
40
|
|
41 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
|
|
42
|
|
43 use base qw( Bio::EnsEMBL::Storable );
|
|
44
|
|
45 =head2 new
|
|
46
|
|
47 Arg [-ACCESSION] : String
|
|
48 The accession of the ontology term.
|
|
49
|
|
50 Arg [-ONTOLOGY] : String
|
|
51 The ontology that the term belongs to.
|
|
52
|
|
53 Arg [-NAMESPACE] : String
|
|
54 The namespace of the ontology term.
|
|
55
|
|
56 Arg [-NAME] : String
|
|
57 The name of the ontology term.
|
|
58
|
|
59 Arg [-SUBSETS] : (optional) Listref of strings
|
|
60 The subsets within the ontology to which this
|
|
61 term belongs.
|
|
62
|
|
63 Arg [-DEFINITION] : (optional) String
|
|
64 The definition of the ontology term.
|
|
65
|
|
66 Arg [-SYNONYMS] : (optional) Listref of strings
|
|
67 The synonyms of this term.
|
|
68
|
|
69 Arg : Further arguments required for parent class
|
|
70 Bio::EnsEMBL::Storable.
|
|
71
|
|
72 Description : Creates an ontology term object.
|
|
73
|
|
74 Example :
|
|
75
|
|
76 my $term = Bio::EnsEMBL::OntologyTerm->new(
|
|
77 '-accession' => 'GO:0021785',
|
|
78 '-ontology' => 'GO',
|
|
79 '-namespace' => 'biological_process',
|
|
80 '-name' => 'branchiomotor neuron axon guidance',
|
|
81 '-definition' => 'The process in which a branchiomotor '
|
|
82 . 'neuron growth cone is directed to a specific target site. '
|
|
83 . 'Branchiomotor neurons are located in the hindbrain and '
|
|
84 . 'innervate branchial arch-derived muscles that control jaw '
|
|
85 . 'movements, facial expression, the larynx, and the pharynx.',
|
|
86 '-synonyms' => [ 'BMN axon guidance',
|
|
87 'branchial motor axon guidance',
|
|
88 'special visceral motor neuron axon guidance' ]
|
|
89
|
|
90 # ... other arguments required by Bio::EnsEMBL::Storable.
|
|
91 );
|
|
92
|
|
93 Return type : Bio::EnsEMBL::OntologyTerm
|
|
94
|
|
95 =cut
|
|
96
|
|
97 sub new {
|
|
98 my $proto = shift(@_);
|
|
99
|
|
100 my $this = $proto->SUPER::new(@_);
|
|
101
|
|
102 my ( $accession, $ontology, $namespace, $name, $definition, $subsets )
|
|
103 = rearrange( [ 'ACCESSION', 'ONTOLOGY', 'NAMESPACE', 'NAME',
|
|
104 'DEFINITION', 'SUBSETS' ],
|
|
105 @_ );
|
|
106
|
|
107 $this->{'accession'} = $accession;
|
|
108 $this->{'ontology'} = $ontology;
|
|
109 $this->{'namespace'} = $namespace;
|
|
110 $this->{'name'} = $name;
|
|
111 $this->{'definition'} = $definition;
|
|
112 $this->{'subsets'} = [ @{$subsets} ];
|
|
113
|
|
114 $this->{'child_terms_fetched'} = 0;
|
|
115 $this->{'parent_terms_fetched'} = 0;
|
|
116
|
|
117 return $this;
|
|
118 }
|
|
119
|
|
120 =head2 accession
|
|
121
|
|
122 Arg : None
|
|
123
|
|
124 Description : Returns the accession for the ontology term in question.
|
|
125
|
|
126 Example : my $accession = $term->accession();
|
|
127
|
|
128 Return type : String
|
|
129
|
|
130 =cut
|
|
131
|
|
132 sub accession {
|
|
133 my ($this) = @_;
|
|
134 return $this->{'accession'};
|
|
135 }
|
|
136
|
|
137 =head2 ontology
|
|
138
|
|
139 Arg : None
|
|
140
|
|
141 Description : Returns the ontology for the ontology term in question.
|
|
142
|
|
143 Example : my $ontology = $term->ontology();
|
|
144
|
|
145 Return type : String
|
|
146
|
|
147 =cut
|
|
148
|
|
149 sub ontology {
|
|
150 my ($this) = @_;
|
|
151 return $this->{'ontology'};
|
|
152 }
|
|
153
|
|
154 =head2 namespace
|
|
155
|
|
156 Arg : None
|
|
157
|
|
158 Description : Returns the namespace for the ontology term in question.
|
|
159
|
|
160 Example : my $acc = $term->namespace();
|
|
161
|
|
162 Return type : String
|
|
163
|
|
164 =cut
|
|
165
|
|
166 sub namespace {
|
|
167 my ($this) = @_;
|
|
168 return $this->{'namespace'};
|
|
169 }
|
|
170
|
|
171 =head2 name
|
|
172
|
|
173 Arg : None
|
|
174
|
|
175 Description : Returns the name for the ontology term in question.
|
|
176
|
|
177 Example : my $name = $term->name();
|
|
178
|
|
179 Return type : String
|
|
180
|
|
181 =cut
|
|
182
|
|
183 sub name {
|
|
184 my ($this) = @_;
|
|
185 return $this->{'name'};
|
|
186 }
|
|
187
|
|
188 =head2 definition
|
|
189
|
|
190 Arg : None
|
|
191
|
|
192 Description : Returns the definition for the ontology term in question.
|
|
193
|
|
194 Example : my $definition = $term->definition();
|
|
195
|
|
196 Return type : String
|
|
197
|
|
198 =cut
|
|
199
|
|
200 sub definition {
|
|
201 my ($this) = @_;
|
|
202 return $this->{'definition'};
|
|
203 }
|
|
204
|
|
205 =head2 synonyms
|
|
206
|
|
207 Arg : None
|
|
208
|
|
209 Description : Returns the list of synonyms defined for this term
|
|
210 (if any).
|
|
211
|
|
212 Example : my @synonyms = @{ $term->synonyms() };
|
|
213
|
|
214 Return type : Listref of strings
|
|
215
|
|
216 =cut
|
|
217
|
|
218 sub synonyms {
|
|
219 my ($this) = @_;
|
|
220
|
|
221 if ( !exists( $this->{'synonyms'} ) ) {
|
|
222 $this->{'synonyms'} =
|
|
223 $this->adaptor()->_fetch_synonyms_by_dbID( $this->dbID() );
|
|
224 }
|
|
225
|
|
226 return $this->{'synonyms'};
|
|
227 }
|
|
228
|
|
229 =head2 subsets
|
|
230
|
|
231 Arg : None
|
|
232
|
|
233 Description : Returns a list of subsets that this term is part
|
|
234 of. The list might be empty.
|
|
235
|
|
236 Example : my @subsets = @{ $term->subsets() };
|
|
237
|
|
238 Return type : listref of strings
|
|
239
|
|
240 =cut
|
|
241
|
|
242 sub subsets {
|
|
243 my ($this) = @_;
|
|
244 return $this->{'subsets'};
|
|
245 }
|
|
246
|
|
247 =head2 children
|
|
248
|
|
249 Arg : (optional) List of strings
|
|
250 The type of relations to retrieve children for.
|
|
251
|
|
252 Description : Returns the children terms of this ontology term.
|
|
253
|
|
254 Example : my @children =
|
|
255 @{ $term->children( 'is_a', 'part_of' ) };
|
|
256
|
|
257 Return type : listref of Bio::EnsEMBL::OntologyTerm
|
|
258
|
|
259 =cut
|
|
260
|
|
261 sub children {
|
|
262 my ( $this, @relations ) = @_;
|
|
263
|
|
264 my @terms = @{ $this->adaptor()->fetch_all_by_parent_term($this) };
|
|
265
|
|
266 if (@relations) {
|
|
267 @terms = ();
|
|
268 foreach my $relation (@relations) {
|
|
269 if ( exists( $this->{'children'}{$relation} ) ) {
|
|
270 push( @terms, @{ $this->{'children'}{$relation} } );
|
|
271 }
|
|
272 }
|
|
273 }
|
|
274
|
|
275 return \@terms;
|
|
276 }
|
|
277
|
|
278 =head2 descendants
|
|
279
|
|
280 Arg : None
|
|
281
|
|
282 Description : Returns the complete set of 'is_a' and 'part_of'
|
|
283 descendant terms of this ontology term, down to
|
|
284 and including any leaf terms.
|
|
285
|
|
286 Example : my @descendants = @{ $term->descendants() };
|
|
287
|
|
288 Return type : listref of Bio::EnsEMBL::OntologyTerm
|
|
289
|
|
290 =cut
|
|
291
|
|
292 sub descendants {
|
|
293 my ($this) = @_;
|
|
294 return $this->adaptor()->fetch_all_by_ancestor_term($this);
|
|
295 }
|
|
296
|
|
297 =head2 parents
|
|
298
|
|
299 Arg : (optional) List of strings
|
|
300 The type of relations to retrieve parents for.
|
|
301
|
|
302 Description : Returns the parent terms of this ontology term.
|
|
303
|
|
304 Example : my @parents =
|
|
305 @{ $term->parents( 'is_a', 'part_of' ) };
|
|
306
|
|
307 Return type : listref of Bio::EnsEMBL::OntologyTerm
|
|
308
|
|
309 =cut
|
|
310
|
|
311 sub parents {
|
|
312 my ( $this, @relations ) = @_;
|
|
313
|
|
314 my @terms = @{ $this->adaptor()->fetch_all_by_child_term($this) };
|
|
315
|
|
316 if (@relations) {
|
|
317 @terms = ();
|
|
318 foreach my $relation (@relations) {
|
|
319 if ( exists( $this->{'parents'}{$relation} ) ) {
|
|
320 push( @terms, @{ $this->{'parents'}{$relation} } );
|
|
321 }
|
|
322 }
|
|
323 }
|
|
324
|
|
325 return \@terms;
|
|
326 }
|
|
327
|
|
328 =head2 ancestors
|
|
329
|
|
330 Arg : None
|
|
331
|
|
332 Description : Returns the complete set of 'is_a' and 'part_of'
|
|
333 ancestor terms of this ontology term, up to and
|
|
334 including the root term.
|
|
335
|
|
336 Example : my @ancestors = @{ $term->ancestors() };
|
|
337
|
|
338 Return type : listref of Bio::EnsEMBL::OntologyTerm
|
|
339
|
|
340 =cut
|
|
341
|
|
342 sub ancestors {
|
|
343 my ($this) = @_;
|
|
344 return $this->adaptor()->fetch_all_by_descendant_term($this);
|
|
345 }
|
|
346
|
|
347 1;
|