comparison variant_effect_predictor/Bio/EnsEMBL/Variation/OverlapConsequence.pm @ 0:21066c0abaf5 draft

Uploaded
author willmclaren
date Fri, 03 Aug 2012 10:04:48 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:21066c0abaf5
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::Variation::OverlapConsequence
24
25 =head1 SYNOPSIS
26
27 use Bio::EnsEMBL::Variation::OverlapConsequence;
28
29 my $oc = Bio::EnsEMBL::Variation::OverlapConsequence->new(
30 -display_term => 'NON_SYNONYMOUS_CODING',
31 -SO_term => 'non_synonymous_codon',
32 -SO_accession => 'SO:0001583',
33 -NCBI_term => 'missense',
34 -feature_SO_term => 'mRNA',
35 -description => 'In coding sequence and results in an amino acid change in the encoded peptide sequence',
36 -predicate => 'Bio::EnsEMBL::Variation::Utils::VariationEffect::non_synonymous_codon',
37 -label => 'Non-synonymous coding',
38 -rank => 7,
39 -feature_class => 'Bio::EnsEMBL::Transcript',
40 );
41
42 if ($oc->predicate($transcript_variation_allele)) {
43 print "This allele is: ", $oc->display_term, "\n";
44 }
45
46 =head1 DESCRIPTION
47
48 An OverlapConsequence represents the consequence of an allele of a VariationFeature overlapping
49 some other Ensembl Feature (and therefore applies to VariationFeatureOverlapAllele objects as these
50 represent just such an event). It contains various values that represent the consequence type, such
51 as the Sequence Ontology (SO) term and accession (which should always be unique), the Ensembl
52 display_term (which will not always be unique), the relative rank of this consequence when compared
53 to other consequences etc. It also contains a reference to a subroutine, referred to as the
54 'predicate', which if a called with a VariationFeatureOverlapAllele (or a subclass) as the first and
55 only argument, will return a true or false value if this consequence type applies to this allele.
56
57 The list of OverlapConsequences used by Ensembl is defined in the Bio::EnsEMBL::Variation::Utils::Constants
58 module, and can be imported from there.
59
60 =cut
61
62 package Bio::EnsEMBL::Variation::OverlapConsequence;
63
64 use strict;
65 use warnings;
66
67 use Bio::EnsEMBL::Utils::Exception qw(throw);
68 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
69 use Bio::EnsEMBL::Variation::Utils::VariationEffect;
70
71 =head2 new
72
73 Arg [-SO_ACCESSION] :
74 The Sequence Ontology accession for this consequence type
75
76 Arg [-SO_TERM] :
77 The Sequence Ontology term for this consequence type
78
79 Arg [-FEATURE_SO_TERM] :
80 The Sequence Ontology term for the feature affected by this consequence type
81
82 Arg [-FEATURE_CLASS] :
83 The Ensembl class that represents the feature affected by this consequence type
84
85 Arg [-VARIANT_FEATURE_CLASS] :
86 The Ensembl class that represents the variation feature this consequence applies to
87
88 Arg [-PREDICATE] :
89 A reference to a subroutine that checks if this consequence type holds for
90 a given VariationFeatureOverlapAllele (or the name of such a subroutine)
91
92 Arg [-RANK] :
93 The relative rank of this consequence type when compred to other OverlapConsequence
94 objects
95
96 Arg [-DISPLAY_TERM] :
97 The Ensembl display term for this consequence type (used by default on the website)
98
99 Arg [-NCBI_TERM] :
100 The NCBI term for this consequence type
101
102 Arg [-DESCRIPTION] :
103 A freetext description of this consequence type (used on the website)
104
105 Arg [-LABEL] :
106 A freetext label briefly describing this consequence type (used on the website)
107
108 Arg [-IS_DEFAULT] :
109 A flag indicating if this is the default consequence type used when none other applies
110 (in Ensembl this currently set on the intergenic OverlapConsequence)
111
112 Example :
113 my $oc = Bio::EnsEMBL::Variation::OverlapConsequence->new(
114 -display_term => 'NON_SYNONYMOUS_CODING',
115 -SO_term => 'non_synonymous_codon',
116 -SO_accession => 'SO:0001583',
117 -NCBI_term => 'missense',
118 -feature_SO_term => 'mRNA',
119 -description => 'In coding sequence and results in an amino acid change in the encoded peptide sequence',
120 -predicate => 'Bio::EnsEMBL::Variation::Utils::VariationEffect::non_synonymous_codon',
121 -label => 'Non-synonymous coding',
122 -rank => 7,
123 -tier => 1,
124 -feature_class => 'Bio::EnsEMBL::Transcript',
125 );
126
127 Description: Constructs a new OverlapConsequence instance
128 Returntype : A new Bio::EnsEMBL::Variation::OverlapConsequence instance
129 Exceptions : none
130 Status : At Risk
131
132 =cut
133
134 sub new {
135 my $class = shift;
136
137 my (
138 $SO_accession,
139 $SO_term,
140 $feature_SO_term,
141 $feature_class,
142 $variant_feature_class,
143 $predicate,
144 $rank,
145 $tier,
146 $display_term,
147 $NCBI_term,
148 $description,
149 $label,
150 $is_default,
151 ) = rearrange([qw(
152 SO_ACCESSION
153 SO_TERM
154 FEATURE_SO_TERM
155 FEATURE_CLASS
156 VARIANT_FEATURE_CLASS
157 PREDICATE
158 RANK
159 TIER
160 DISPLAY_TERM
161 NCBI_TERM
162 DESCRIPTION
163 LABEL
164 IS_DEFAULT
165 )], @_);
166
167 my $self = bless {
168 SO_accession => $SO_accession,
169 SO_term => $SO_term,
170 feature_SO_term => $feature_SO_term,
171 feature_class => $feature_class,
172 variant_feature_class => $variant_feature_class,
173 predicate => $predicate,
174 rank => $rank,
175 tier => $tier,
176 display_term => $display_term,
177 NCBI_term => $NCBI_term,
178 description => $description,
179 label => $label,
180 is_default => $is_default,
181 }, $class;
182
183 return $self;
184 }
185
186 sub new_fast {
187 my ($class, $hashref) = @_;
188 return bless $hashref, $class;
189 }
190
191 =head2 SO_accession
192
193 Arg [1] : (optional) accession to set
194 Description: Get/set the Sequence Ontology accession for this consequence type
195 Returntype : string
196 Exceptions : none
197 Status : At Risk
198
199 =cut
200
201 sub SO_accession {
202 my ($self, $SO_accession) = @_;
203 $self->{SO_accession} = $SO_accession if $SO_accession;
204 return $self->{SO_accession};
205 }
206
207 =head2 SO_term
208
209 Arg [1] : (optional) term to set
210 Description: Get/set the Sequence Ontology term for this consequence type
211 Returntype : string
212 Exceptions : none
213 Status : At Risk
214
215 =cut
216
217 sub SO_term {
218 my ($self, $SO_term) = @_;
219 $self->{SO_term} = $SO_term if $SO_term;
220 return $self->{SO_term};
221 }
222
223 =head2 feature_SO_term
224
225 Arg [1] : (optional) term to set
226 Description: Get/set the Sequence Ontology term for the feature affected by this consequence type
227 Returntype : string
228 Exceptions : none
229 Status : At Risk
230
231 =cut
232
233 sub feature_SO_term {
234 my ($self, $feature_SO_term) = @_;
235 $self->{feature_SO_term} = $feature_SO_term if $feature_SO_term;
236 return $self->{feature_SO_term};
237 }
238
239 =head2 feature_class
240
241 Arg [1] : (optional) class to set
242 Description: Get/set the Ensembl class representing the feature affected by this consequence type
243 Returntype : string
244 Exceptions : none
245 Status : At Risk
246
247 =cut
248
249 sub feature_class {
250 my ($self, $feature_class) = @_;
251 $self->{feature_class} = $feature_class if $feature_class;
252 return $self->{feature_class} || '';
253 }
254
255 =head2 predicate
256
257 Arg [1] : (optional) reference to subroutine (or the name of a subroutine)
258 Description: Get/set the predicate used to check if this consequence type applies
259 to a given VariationFeatureOverlapAllele. Currently, if you supply
260 a name (rather than a coderef), this subroutine must be found in the
261 Bio::EnsEMBL::Variation::Utils::VariationEffect module.
262 Returntype : coderef
263 Exceptions : throws if a name is supplied and the subroutine cannot be found in
264 the expected module
265 Status : At Risk
266
267 =cut
268
269 sub predicate {
270 my ($self, $predicate) = @_;
271
272 $self->{predicate} = $predicate if $predicate;
273
274 if ($self->{predicate} && ref $self->{predicate} ne 'CODE') {
275 my $name = $self->{predicate};
276
277 if (defined &$name && $name =~ /^Bio::EnsEMBL::Variation::Utils::VariationEffect/) {
278 $self->{predicate} = \&$name;
279 }
280 else {
281 throw("Can't find a subroutine called $name in the VariationEffect module?");
282 }
283 }
284
285 return $self->{predicate};
286 }
287
288 =head2 rank
289
290 Arg [1] : (optional) rank to set
291 Description: Get/set the relative rank of this OverlapConsequence when compared to other
292 OverlapConsequence objects. This is used, for example, to determine the most
293 severe consequence of a VariationFeature.
294 Returntype : integer
295 Exceptions : none
296 Status : At Risk
297
298 =cut
299
300 sub rank {
301 my ($self, $rank) = @_;
302 $self->{rank} = $rank if $rank;
303 return $self->{rank};
304 }
305
306 =head2 tier
307
308 Arg [1] : (optional) tier to set
309 Description: Get/set the tier this OverlapConsequence belongs to. Variations will be
310 assigned consequences in tier order; if a tier 1 consequence is assigned,
311 no tier 2 consequences will be checked/assigned.
312 Returntype : integer
313 Exceptions : none
314 Status : At Risk
315
316 =cut
317
318 sub tier {
319 my ($self, $tier) = @_;
320 $self->{tier} = $tier if $tier;
321 return $self->{tier};
322 }
323
324
325 =head2 display_term
326
327 Arg [1] : (optional) term to set
328 Description: Get/set the Ensembl display term for this consequence type. This is
329 used by default on the website.
330 Returntype : string
331 Exceptions : none
332 Status : At Risk
333
334 =cut
335
336 sub display_term {
337 my ($self, $display_term) = @_;
338 $self->{display_term} = $display_term if $display_term;
339 return $self->{display_term} || $self->SO_term;
340 }
341
342 =head2 NCBI_term
343
344 Arg [1] : (optional) term to set
345 Description: Get/set the NCBI term for this consequence type
346 Returntype : string
347 Exceptions : none
348 Status : At Risk
349
350 =cut
351
352 sub NCBI_term {
353 my ($self, $NCBI_term) = @_;
354 $self->{NCBI_term} = $NCBI_term if $NCBI_term;
355 return $self->{NCBI_term} || $self->SO_term;
356 }
357
358 =head2 description
359
360 Arg [1] : (optional) description to set
361 Description: Get/set the description for this consequence type. This is used on the
362 website and is intended to be a freetext description of this consequence.
363 Returntype : string
364 Exceptions : none
365 Status : At Risk
366
367 =cut
368
369 sub description {
370 my ($self, $description) = @_;
371 $self->{description} = $description if $description;
372 return $self->{description};
373 }
374
375 =head2 label
376
377 Arg [1] : (optional) label to set
378 Description: Get/set the label for this consequence type. This is used on the
379 website and is intended to be a short description of this consequence.
380 Returntype : string
381 Exceptions : none
382 Status : At Risk
383
384 =cut
385
386 sub label {
387 my ($self, $label) = @_;
388 $self->{label} = $label if $label;
389 return $self->{label};
390 }
391
392 =head2 variant_feature_class
393
394 Arg [1] : (optional) class as a atring
395 Description: Get/set the class of variant features that this consequence can apply to
396 Returntype : string
397 Exceptions : none
398 Status : At Risk
399
400 =cut
401
402 sub variant_feature_class {
403 my ($self, $class) = @_;
404 $self->{variant_feature_class} = $class if $class;
405 return $self->{variant_feature_class};
406 }
407
408 =head2 is_default
409
410 Arg [1] : (optional) flag
411 Description: Get/set a flag indicating if this is the default consequence type.
412 There should only be one default OverlapConsequence, in Ensembl this
413 flag is only set on the INTERGENIC OverlapConsequence object.
414 Returntype : bool
415 Exceptions : none
416 Status : At Risk
417
418 =cut
419
420 sub is_default {
421 my ($self, $is_default) = @_;
422 $self->{is_default} = $is_default if defined $is_default;
423 return $self->{is_default};
424 }
425
426 sub get_all_parent_SO_terms {
427 my ($self) = @_;
428
429 if (my $adap = $self->{adaptor}) {
430 if (my $goa = $adap->db->get_SOTermAdaptor) {
431
432 }
433 }
434 }
435
436 1;