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 # Ensembl module for Bio::EnsEMBL::Variation::StructuralVariationFeature
|
|
22 #
|
|
23 # Copyright (c) 2011 Ensembl
|
|
24 #
|
|
25
|
|
26
|
|
27 =head1 NAME
|
|
28
|
|
29 Bio::EnsEMBL::Variation::StructuralVariationFeature - A genomic position for a structural variation.
|
|
30
|
|
31 =head1 SYNOPSIS
|
|
32
|
|
33 # Structural variation feature representing a CNV
|
|
34 $svf = Bio::EnsEMBL::Variation::StructuralVariationFeature->new
|
|
35 (-start => 100,
|
|
36 -end => 200,
|
|
37 -strand => 1,
|
|
38 -slice => $slice,
|
|
39 -variation_name => 'esv1001',
|
|
40 -class_so_term => 'copy_number_variation',
|
|
41 -source => 'DGVa',
|
|
42 -source_description => 'Database of Genomic Variants Archive',
|
|
43 );
|
|
44
|
|
45 ...
|
|
46
|
|
47 print $svf->start(), "-", $svf->end(), '(', $svf->strand(), ')', "\n";
|
|
48
|
|
49 print $svf->variation_name(), ":", $svf->var_class();
|
|
50
|
|
51 =head1 DESCRIPTION
|
|
52
|
|
53 This is a class representing the genomic position of a structural variant
|
|
54 from the ensembl-variation database. A StructuralVariationFeature behaves as any other
|
|
55 Ensembl feature. See B<Bio::EnsEMBL::Feature> and
|
|
56 B<Bio::EnsEMBL::Variation::Variation>.
|
|
57
|
|
58 =head1 METHODS
|
|
59
|
|
60 =cut
|
|
61
|
|
62 use strict;
|
|
63 use warnings;
|
|
64
|
|
65 package Bio::EnsEMBL::Variation::StructuralVariationFeature;
|
|
66
|
|
67 use Scalar::Util qw(weaken isweak);
|
|
68
|
|
69 use Bio::EnsEMBL::Variation::BaseVariationFeature;
|
|
70 use Bio::EnsEMBL::Utils::Exception qw(throw warning deprecate);
|
|
71 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
|
|
72 use Bio::EnsEMBL::Utils::Scalar qw(assert_ref);
|
|
73 use Bio::EnsEMBL::Slice;
|
|
74 use Bio::EnsEMBL::Variation::Utils::Constants qw(%VARIATION_CLASSES);
|
|
75 use Bio::EnsEMBL::Variation::Utils::VariationEffect qw(MAX_DISTANCE_FROM_TRANSCRIPT);
|
|
76 use Bio::EnsEMBL::Variation::StructuralVariationOverlap;
|
|
77 use Bio::EnsEMBL::Variation::TranscriptStructuralVariation;
|
|
78 use Bio::EnsEMBL::Variation::IntergenicStructuralVariation;
|
|
79
|
|
80 our @ISA = ('Bio::EnsEMBL::Variation::BaseVariationFeature');
|
|
81
|
|
82 =head2 new
|
|
83
|
|
84 Arg [-dbID] :
|
|
85 see superclass constructor
|
|
86
|
|
87 Arg [-ADAPTOR] :
|
|
88 see superclass constructor
|
|
89
|
|
90 Arg [-START] :
|
|
91 see superclass constructor
|
|
92 Arg [-END] :
|
|
93 see superclass constructor
|
|
94
|
|
95 Arg [-STRAND] :
|
|
96 see superclass constructor
|
|
97
|
|
98 Arg [-SLICE] :
|
|
99 see superclass constructor
|
|
100
|
|
101 Arg [-INNER_START] :
|
|
102 int - the 5'-greater coordinate of the underlying structural variation
|
|
103
|
|
104 Arg [-INNER_END] :
|
|
105 int - the 3'-less coordinate of the underlying structural variation
|
|
106
|
|
107 Arg [-OUTER_START] :
|
|
108 int - the 5'-less coordinate of the underlying structural variation
|
|
109
|
|
110 Arg [-OUTER_END] :
|
|
111 int - the 3'-greater coordinate of the underlying structural variation
|
|
112
|
|
113 Arg [-VARIATION_NAME] :
|
|
114 string - the name of the variation this feature is for (denormalisation
|
|
115 from Variation object).
|
|
116
|
|
117 Arg [-CLASS_SO_TERM] :
|
|
118 string - the sequence ontology term defining the class of the structural variation.
|
|
119
|
|
120 Arg [-ALLELE_STRING] :
|
|
121 string - allele sequence of the structural variation.
|
|
122
|
|
123 Arg [-SOURCE] :
|
|
124 string - the name of the source where the variation comes from
|
|
125
|
|
126 Arg [-SOURCE_VERSION]:
|
|
127 string - version number of the source
|
|
128
|
|
129 Arg [-IS_SOMATIC] :
|
|
130 int - flag to inform whether the structural variant is a somatic (1) or germline (0).
|
|
131
|
|
132 Arg [-BREAKPOINT_ORDER] :
|
|
133 int - For a structural variant with multiple breakpoints, this gives the predicted order of the breakpoint event.
|
|
134
|
|
135 Example :
|
|
136 $svf = Bio::EnsEMBL::Variation::StructuralVariationFeature->new
|
|
137 (-start => 100,
|
|
138 -end => 200,
|
|
139 -strand => 1,
|
|
140 -slice => $slice,
|
|
141 -variation_name => 'esv25480',
|
|
142 -class_so_term => 'structural_variant',
|
|
143 -source => 'DGVa');
|
|
144
|
|
145 Description: Constructor. Instantiates a new StructuralVariationFeature object.
|
|
146 Returntype : Bio::EnsEMBL::Variation::StructuralVariationFeature
|
|
147 Exceptions : none
|
|
148 Caller : general
|
|
149 Status : At Risk
|
|
150
|
|
151 =cut
|
|
152
|
|
153 sub new {
|
|
154 my $caller = shift;
|
|
155 my $class = ref($caller) || $caller;
|
|
156
|
|
157 my $self = $class->SUPER::new(@_);
|
|
158
|
|
159 my (
|
|
160 $var_name,
|
|
161 $source,
|
|
162 $source_version,
|
|
163 $class_so_term,
|
|
164 $inner_start,
|
|
165 $inner_end,
|
|
166 $outer_start,
|
|
167 $outer_end,
|
|
168 $allele_string,
|
|
169 $is_somatic,
|
|
170 $breakpoint_order
|
|
171 ) = rearrange([qw(
|
|
172 VARIATION_NAME
|
|
173 SOURCE
|
|
174 SOURCE_VERSION
|
|
175 CLASS_SO_TERM
|
|
176 INNER_START
|
|
177 INNER_END
|
|
178 OUTER_START
|
|
179 INNER_START
|
|
180 ALLELE_STRING
|
|
181 IS_SOMATIC
|
|
182 BREAKPOINT_ORDER
|
|
183 )], @_);
|
|
184
|
|
185
|
|
186 $self->{'variation_name'} = $var_name;
|
|
187 $self->{'source'} = $source;
|
|
188 $self->{'source_version'} = $source_version;
|
|
189 $self->{'class_SO_term'} = $class_so_term;
|
|
190 $self->{'inner_start'} = $inner_start;
|
|
191 $self->{'inner_end'} = $inner_end;
|
|
192 $self->{'outer_start'} = $outer_start;
|
|
193 $self->{'outer_end'} = $outer_end;
|
|
194 $self->{'allele_string'} = $allele_string;
|
|
195 $self->{'is_somatic'} = $is_somatic || 0;
|
|
196 $self->{'breakpoint_order'} = $breakpoint_order;
|
|
197
|
|
198 return $self;
|
|
199 }
|
|
200
|
|
201
|
|
202
|
|
203 sub new_fast {
|
|
204 my $class = shift;
|
|
205 my $hashref = shift;
|
|
206 return bless $hashref, $class;
|
|
207 }
|
|
208
|
|
209
|
|
210 =head2 display_id
|
|
211
|
|
212 Arg [1] : none
|
|
213 Example : print $svf->display_id(), "\n";
|
|
214 Description: Returns the 'display' identifier for this feature. For
|
|
215 StructuralVariationFeatures this is simply the name of the structural variation
|
|
216 it is associated with.
|
|
217 Returntype : string
|
|
218 Exceptions : none
|
|
219 Caller : webcode
|
|
220 Status : At Risk
|
|
221
|
|
222 =cut
|
|
223
|
|
224 sub display_id {
|
|
225 my $self = shift;
|
|
226 return $self->{'variation_name'} || '';
|
|
227 }
|
|
228
|
|
229
|
|
230
|
|
231 =head2 variation_name
|
|
232
|
|
233 Arg [1] : string $newval (optional)
|
|
234 The new value to set the variation_name attribute to
|
|
235 Example : $variation_name = $obj->variation_name()
|
|
236 Description: Getter/Setter for the variation_name attribute. This is the
|
|
237 name of the structural variant associated with this feature.
|
|
238 Returntype : string
|
|
239 Exceptions : none
|
|
240 Caller : general
|
|
241 Status : Stable
|
|
242
|
|
243 =cut
|
|
244
|
|
245 sub variation_name{
|
|
246 my $self = shift;
|
|
247 return $self->{'variation_name'} = shift if(@_);
|
|
248 return $self->{'variation_name'};
|
|
249 }
|
|
250
|
|
251 =head2 allele_string
|
|
252
|
|
253 Arg [1] : string $newval (optional)
|
|
254 The new value to set the allele_string attribute to
|
|
255 Example : $allele_string = $obj->allele_string()
|
|
256 Description: Getter/Setter for the allele_string attribute. This is the
|
|
257 genomic sequence represented by this feature.
|
|
258 Returntype : string
|
|
259 Exceptions : none
|
|
260 Caller : general
|
|
261 Status : Stable
|
|
262
|
|
263 =cut
|
|
264
|
|
265 sub allele_string{
|
|
266 my $self = shift;
|
|
267 return $self->{'allele_string'} = shift if(@_);
|
|
268 return $self->{'allele_string'};
|
|
269 }
|
|
270
|
|
271
|
|
272
|
|
273 =head2 structural_variation
|
|
274
|
|
275 Arg [1] : (optional) Bio::EnsEMBL::Variation::StructuralVariation or
|
|
276 Bio::EnsEMBL::Variation::SupportingStructuralVariation $structural_variation
|
|
277 Example : $sv = $svf->structural_variation();
|
|
278 Description: Getter/Setter for the structural variant associated with this feature.
|
|
279 If not set, and this StructuralVariationFeature has an associated adaptor
|
|
280 an attempt will be made to lazy-load the structural variation from the
|
|
281 database.
|
|
282 Returntype : Bio::EnsEMBL::Variation::StructuralVariation or
|
|
283 Bio::EnsEMBL::Variation::SupportingStructuralVariation
|
|
284 Exceptions : throw on incorrect argument
|
|
285 Caller : general
|
|
286 Status : Stable
|
|
287
|
|
288 =cut
|
|
289
|
|
290 sub structural_variation {
|
|
291 my $self = shift;
|
|
292
|
|
293 if(@_) {
|
|
294 if(!ref($_[0]) || (!$_[0]->isa('Bio::EnsEMBL::Variation::StructuralVariation') &&
|
|
295 !$_[0]->isa('Bio::EnsEMBL::Variation::SupportingStructuralVariation')
|
|
296 )) {
|
|
297 throw("Bio::EnsEMBL::Variation::StructuralVariation or Bio::EnsEMBL::Variation::SupportingStructuralVariation argument expected");
|
|
298 }
|
|
299 $self->{'structural_variation'} = shift;
|
|
300 }
|
|
301 elsif(!defined($self->{'structural_variation'}) && $self->{'adaptor'} &&
|
|
302 defined($self->{'structural_variation_id'})) {
|
|
303 # lazy-load from database on demand
|
|
304 my $sva = $self->{'adaptor'}->db()->get_StructuralVariationAdaptor();
|
|
305 $self->{'structural_variation'} = $sva->fetch_by_dbID($self->{'structural_variation_id'});
|
|
306 if (!defined($self->{'structural_variation'})) {
|
|
307 $sva = $self->{'adaptor'}->db()->get_SupportingStructuralVariationAdaptor();
|
|
308 $self->{'structural_variation'} = $sva->fetch_by_dbID($self->{'structural_variation_id'});
|
|
309 }
|
|
310 }
|
|
311
|
|
312 return $self->{'structural_variation'};
|
|
313 }
|
|
314
|
|
315
|
|
316
|
|
317
|
|
318
|
|
319 =head2 get_all_VariationSets
|
|
320
|
|
321 Args : none
|
|
322 Example : my @vs = @{$svf->get_all_VariationSets()};
|
|
323 Description : returns a reference to a list of all the VariationSets this
|
|
324 StructuralVariationFeature is a member of
|
|
325 ReturnType : reference to list of Bio::EnsEMBL::Variation::VariationSets
|
|
326 Exceptions : if no adaptor is attached to this object
|
|
327 Caller : general
|
|
328 Status : At Risk
|
|
329 =cut
|
|
330
|
|
331 sub get_all_VariationSets {
|
|
332 my $self = shift;
|
|
333
|
|
334 if (!$self->adaptor()) {
|
|
335 throw('An adaptor must be attached in order to get all variation sets');
|
|
336 }
|
|
337 my $vs_adaptor = $self->adaptor()->db()->get_VariationSetAdaptor();
|
|
338 my $variation_sets = $vs_adaptor->fetch_all_by_StructuralVariation($self->structural_variation());
|
|
339
|
|
340 return $variation_sets;
|
|
341 }
|
|
342
|
|
343
|
|
344 =head2 get_nearest_Gene
|
|
345
|
|
346 Example : $svf->get_nearest_Gene($flanking_size);
|
|
347 Description : Getter a Gene which is associated to or nearest to the StructuralVariationFeature
|
|
348 Returntype : Listref of objects of Bio::EnsEMBL::Gene
|
|
349 Exceptions : None
|
|
350 Caller : general
|
|
351 Status : At Risk
|
|
352
|
|
353 =cut
|
|
354
|
|
355 sub get_nearest_Gene{
|
|
356
|
|
357 my $self = shift;
|
|
358 my $flanking_size = shift; #flanking size is optional
|
|
359 $flanking_size ||= 0;
|
|
360 my $sa = $self->{'adaptor'}->db()->dnadb->get_SliceAdaptor();
|
|
361 my $slice = $sa->fetch_by_Feature($self,$flanking_size);
|
|
362 my @genes = @{$slice->get_all_Genes};
|
|
363 return \@genes if @genes; #$svf is on the gene
|
|
364
|
|
365 if (! @genes) { #if $svf is not on the gene, increase flanking size
|
|
366 warning("flanking_size $flanking_size is not big enough to overlap a gene, increase it by 1,000,000");
|
|
367 $flanking_size += 1000000;
|
|
368 $slice = $sa->fetch_by_Feature($self,$flanking_size);
|
|
369 @genes = @{$slice->get_all_Genes};
|
|
370 }
|
|
371 if (@genes) {
|
|
372 my %distances = ();
|
|
373 foreach my $g (@genes) {
|
|
374 if ($g->seq_region_start > $self->start) {
|
|
375 $distances{$g->seq_region_start-$self->start}=$g;
|
|
376 }
|
|
377 else {
|
|
378 $distances{$self->start-$g->seq_region_end}=$g;
|
|
379 }
|
|
380 }
|
|
381 my @distances = sort {$a<=>$b} keys %distances;
|
|
382 my $shortest_distance = $distances[0];
|
|
383 if ($shortest_distance) {
|
|
384 my $nearest_gene = $distances{$shortest_distance};
|
|
385 return [$nearest_gene];
|
|
386 }
|
|
387 }
|
|
388 else {
|
|
389 throw("variation_feature with flanking_size $flanking_size is not overlap with a gene, try a bigger flanking_size");
|
|
390 }
|
|
391 }
|
|
392
|
|
393
|
|
394 =head2 is_somatic
|
|
395
|
|
396 Arg [1] : boolean $is_somatic (optional)
|
|
397 The new value to set the is_somatic flag to
|
|
398 Example : $is_somatic = $svf->is_somatic
|
|
399 Description: Getter/Setter for the is_somatic flag, which identifies this structural variation feature as either somatic or germline
|
|
400 Returntype : boolean
|
|
401 Exceptions : none
|
|
402 Caller : general
|
|
403 Status : Stable
|
|
404
|
|
405 =cut
|
|
406
|
|
407 sub is_somatic {
|
|
408 my ($self, $is_somatic) = @_;
|
|
409 $self->{'is_somatic'} = $is_somatic if defined $is_somatic;
|
|
410 return $self->{'is_somatic'};
|
|
411 }
|
|
412
|
|
413
|
|
414 =head2 breakpoint_order
|
|
415
|
|
416 Arg [1] : string $bp_order (optional)
|
|
417 The new value to set the breakpoint order to
|
|
418 Example : $bp_order = $svf->breakpoint_order()
|
|
419 Description: Getter/Setter for the breakpoint_order attribute
|
|
420 Returntype : string
|
|
421 Exceptions : none
|
|
422 Caller : general
|
|
423 Status : At Risk
|
|
424
|
|
425 =cut
|
|
426
|
|
427 sub breakpoint_order {
|
|
428 my $self = shift;
|
|
429 return $self->{'breakpoint_order'} = shift if(@_);
|
|
430 return $self->{'breakpoint_order'};
|
|
431 }
|
|
432
|
|
433 =head2 get_all_StructuralVariationOverlaps
|
|
434
|
|
435 Description : Get all the StructuralVariationOverlaps associated with this StructuralVariation, this
|
|
436 includes TranscriptStructuralVariations and regulatory feature overlap object.
|
|
437 Returntype : listref of Bio::EnsEMBL::Variation::StructuralVariationOverlap objects
|
|
438 Exceptions : none
|
|
439 Status : At Risk
|
|
440
|
|
441 =cut
|
|
442
|
|
443 sub get_all_StructuralVariationOverlaps {
|
|
444 my $self = shift;
|
|
445
|
|
446 my $vfos = [
|
|
447 @{ $self->get_all_TranscriptStructuralVariations },
|
|
448 @{ $self->get_all_RegulatoryFeatureStructuralVariations },
|
|
449 @{ $self->get_all_MotifFeatureStructuralVariations },
|
|
450 ];
|
|
451
|
|
452 if (my $iv = $self->get_IntergenicStructuralVariation) {
|
|
453 push @$vfos, $iv;
|
|
454 }
|
|
455
|
|
456 return $vfos;
|
|
457 }
|
|
458
|
|
459 =head2 get_all_TranscriptStructuralVariations
|
|
460
|
|
461 Arg [1] : (optional) listref of Bio::EnsEMBL::Transcript objects
|
|
462 Example : $svf->get_all_TranscriptStructuralVariations;
|
|
463 Description : Get all the TranscriptStructuralVariations associated with this
|
|
464 StructuralVariationFeature. If the optional list of Transcripts
|
|
465 is supplied, get only TranscriptStructuralVariations
|
|
466 associated with those Transcripts.
|
|
467 Returntype : listref of Bio::EnsEMBL::Variation::TranscriptVariation objects
|
|
468 Exceptions : Thrown on wrong argument type
|
|
469 Caller : general
|
|
470 Status : At Risk
|
|
471
|
|
472 =cut
|
|
473
|
|
474 sub get_all_TranscriptStructuralVariations {
|
|
475 my ($self, $transcripts) = @_;
|
|
476
|
|
477 if ($transcripts) {
|
|
478 assert_ref($transcripts, 'ARRAY');
|
|
479 map { assert_ref($_, 'Bio::EnsEMBL::Transcript') } @$transcripts;
|
|
480 }
|
|
481
|
|
482 elsif (not defined $self->{transcript_structural_variations}) {
|
|
483 # this VariationFeature is not in the database so we have to build the
|
|
484 # TranscriptVariations ourselves
|
|
485
|
|
486 unless ($transcripts) {
|
|
487 # if the caller didn't supply some transcripts fetch those around this VariationFeature
|
|
488 # get a slice around this transcript including the maximum distance up and down-stream
|
|
489 # that we still call consequences for
|
|
490 my $slice = $self->feature_Slice->expand(
|
|
491 MAX_DISTANCE_FROM_TRANSCRIPT,
|
|
492 MAX_DISTANCE_FROM_TRANSCRIPT
|
|
493 );
|
|
494
|
|
495 # fetch all transcripts on this slice
|
|
496 $transcripts = $slice->get_all_Transcripts(1);
|
|
497 }
|
|
498
|
|
499 my @unfetched_transcripts = grep {
|
|
500 not exists $self->{transcript_structural_variations}->{$_->stable_id}
|
|
501 } @$transcripts;
|
|
502
|
|
503 for my $transcript (@unfetched_transcripts) {
|
|
504 $self->add_TranscriptStructuralVariation(
|
|
505 Bio::EnsEMBL::Variation::TranscriptStructuralVariation->new(
|
|
506 -structural_variation_feature => $self,
|
|
507 -transcript => $transcript,
|
|
508 -adaptor => undef,
|
|
509 )
|
|
510 );
|
|
511 }
|
|
512 }
|
|
513
|
|
514 if ($transcripts) {
|
|
515 # just return TranscriptVariations for the requested Transcripts
|
|
516 return [ map { $self->{transcript_structural_variations}->{$_->stable_id} } @$transcripts ];
|
|
517 }
|
|
518 else {
|
|
519 # return all TranscriptVariations
|
|
520 return [ values %{ $self->{transcript_structural_variations} } ];
|
|
521 }
|
|
522 }
|
|
523
|
|
524 =head2 get_all_RegulatoryFeatureStructuralVariations
|
|
525
|
|
526 Description : Get all the RegulatoryFeatureStructuralVariations associated with this VariationFeature.
|
|
527 Returntype : listref of Bio::EnsEMBL::Variation::StructuralVariationOverlap objects
|
|
528 Exceptions : none
|
|
529 Status : At Risk
|
|
530
|
|
531 =cut
|
|
532
|
|
533 sub get_all_RegulatoryFeatureStructuralVariations {
|
|
534 my $self = shift;
|
|
535 return $self->_get_all_RegulationStructuralVariations('RegulatoryFeature', @_);
|
|
536 }
|
|
537
|
|
538 =head2 get_all_MotifFeatureStructuralVariations
|
|
539
|
|
540 Description : Get all the MotifFeatureStructuralVariations associated with this VariationFeature.
|
|
541 Returntype : listref of Bio::EnsEMBL::Variation::StructuralVariationOverlap objects
|
|
542 Exceptions : none
|
|
543 Status : At Risk
|
|
544
|
|
545 =cut
|
|
546
|
|
547 sub get_all_MotifFeatureStructuralVariations {
|
|
548 my $self = shift;
|
|
549 return $self->_get_all_RegulationStructuralVariations('MotifFeature', @_);
|
|
550 }
|
|
551
|
|
552 =head2 get_all_ExternalFeatureStructuralVariations
|
|
553
|
|
554 Description : Get all the ExternalFeatureStructuralVariations associated with this VariationFeature.
|
|
555 Returntype : listref of Bio::EnsEMBL::Variation::StructuralVariationOverlap objects
|
|
556 Exceptions : none
|
|
557 Status : At Risk
|
|
558
|
|
559 =cut
|
|
560
|
|
561 sub get_all_ExternalFeatureStructuralVariations {
|
|
562 my $self = shift;
|
|
563 return $self->_get_all_RegulationStructuralVariations('ExternalFeature', @_);
|
|
564 }
|
|
565
|
|
566 sub _get_all_RegulationStructuralVariations {
|
|
567 my ($self, $type) = @_;
|
|
568
|
|
569 unless ($type && ($type eq 'RegulatoryFeature' || $type eq 'MotifFeature' || $type eq 'ExternalFeature')) {
|
|
570 throw("Invalid Ensembl Regulation type '$type'");
|
|
571 }
|
|
572
|
|
573 unless ($self->{regulation_structural_variations}->{$type}) {
|
|
574 my $fg_adaptor;
|
|
575
|
|
576 if (my $adap = $self->adaptor) {
|
|
577 if(my $db = $adap->db) {
|
|
578 $fg_adaptor = Bio::EnsEMBL::DBSQL::MergedAdaptor->new(
|
|
579 -species => $adap->db->species,
|
|
580 -type => $type,
|
|
581 );
|
|
582 }
|
|
583
|
|
584 unless ($fg_adaptor) {
|
|
585 warning("Failed to get adaptor for $type");
|
|
586 return [];
|
|
587 }
|
|
588 }
|
|
589 else {
|
|
590 warning('Cannot get variation features without attached adaptor');
|
|
591 return [];
|
|
592 }
|
|
593
|
|
594 my $slice = $self->feature_Slice;
|
|
595
|
|
596 my $constructor = 'Bio::EnsEMBL::Variation::StructuralVariationOverlap';
|
|
597
|
|
598 eval {
|
|
599 $self->{regulation_structural_variations}->{$type} = [
|
|
600 map {
|
|
601 $constructor->new(
|
|
602 -structural_variation_feature => $self,
|
|
603 -feature => $_,
|
|
604 );
|
|
605 } map { $_->transfer($self->slice) } @{ $fg_adaptor->fetch_all_by_Slice($slice) }
|
|
606 ];
|
|
607 };
|
|
608
|
|
609 $self->{regulation_structural_variations}->{$type} ||= [];
|
|
610 }
|
|
611
|
|
612 return $self->{regulation_structural_variations}->{$type};
|
|
613 }
|
|
614
|
|
615
|
|
616 sub get_IntergenicStructuralVariation {
|
|
617 my $self = shift;
|
|
618 my $no_ref_check = shift;
|
|
619
|
|
620 unless (exists $self->{intergenic_structural_variation}) {
|
|
621 if (scalar(@{ $self->get_all_TranscriptStructuralVariations }) == 0) {
|
|
622 $self->{intergenic_structural_variation} = Bio::EnsEMBL::Variation::IntergenicStructuralVariation->new(
|
|
623 -structural_variation_feature => $self,
|
|
624 -no_ref_check => $no_ref_check,
|
|
625 );
|
|
626 }
|
|
627 else {
|
|
628 $self->{intergenic_structural_variation} = undef;
|
|
629 }
|
|
630 }
|
|
631
|
|
632 return $self->{intergenic_structural_variation};
|
|
633 }
|
|
634
|
|
635
|
|
636
|
|
637 =head2 TranscriptStructuralVariation
|
|
638
|
|
639 Arg [1] : Bio::EnsEMBL::Variation::TranscriptStructuralVariation
|
|
640 Example : $vf->add_TranscriptStructuralVariation($tsv);
|
|
641 Description : Adds a TranscriptStructuralVariation to the structural variation
|
|
642 feature object.
|
|
643 Exceptions : thrown on bad argument
|
|
644 Caller : Bio::EnsEMBL::Variation::StructuralVariationFeature,
|
|
645 Bio::EnsEMBL::Varaition::Utils::VEP
|
|
646 Status : Stable
|
|
647
|
|
648 =cut
|
|
649
|
|
650 sub add_TranscriptStructuralVariation {
|
|
651 my ($self, $tsv) = @_;
|
|
652 assert_ref($tsv, 'Bio::EnsEMBL::Variation::TranscriptStructuralVariation');
|
|
653 # we need to weaken the reference back to us to avoid a circular reference
|
|
654 weaken($tsv->{base_variation_feature});
|
|
655 $self->{transcript_structural_variations}->{$tsv->transcript_stable_id} = $tsv;
|
|
656 }
|
|
657
|
|
658
|
|
659 =head2 var_class
|
|
660
|
|
661 Args : None
|
|
662 Example : my $sv_class = $svf->var_class()
|
|
663 Description : Getter for the class of structural variation
|
|
664 ReturnType : String
|
|
665 Exceptions : none
|
|
666 Caller : General
|
|
667 Status : At Risk
|
|
668
|
|
669 =cut
|
|
670
|
|
671 sub var_class {
|
|
672 my $self = shift;
|
|
673
|
|
674 unless ($self->{class_display_term}) {
|
|
675 my $display_term = $VARIATION_CLASSES{$self->{class_SO_term}}->{display_term};
|
|
676
|
|
677 warn "No display term for SO term: ".$self->{class_SO_term} unless $display_term;
|
|
678
|
|
679 $self->{class_display_term} = $display_term || $self->{class_SO_term};
|
|
680 }
|
|
681
|
|
682 return $self->{class_display_term};
|
|
683 }
|
|
684
|
|
685
|
|
686 =head2 class_SO_term
|
|
687
|
|
688 Args : None
|
|
689 Example : my $sv_so_term = $svf->class_SO_term()
|
|
690 Description : Getter for the class of structural variation, returning the SO term
|
|
691 ReturnType : String
|
|
692 Exceptions : none
|
|
693 Caller : General
|
|
694 Status : At Risk
|
|
695
|
|
696 =cut
|
|
697
|
|
698 sub class_SO_term {
|
|
699 my $self = shift;
|
|
700
|
|
701 return $self->{class_SO_term};
|
|
702 }
|
|
703
|
|
704
|
|
705 =head2 source
|
|
706
|
|
707 Arg [1] : string $source (optional)
|
|
708 The new value to set the source attribute to
|
|
709 Example : $source = $svf->source()
|
|
710 Description: Getter/Setter for the source attribute
|
|
711 Returntype : string
|
|
712 Exceptions : none
|
|
713 Caller : general
|
|
714 Status : At Risk
|
|
715
|
|
716 =cut
|
|
717
|
|
718 sub source{
|
|
719 my $self = shift;
|
|
720 return $self->{'source'} = shift if(@_);
|
|
721 return $self->{'source'};
|
|
722 }
|
|
723
|
|
724 =head2 source_version
|
|
725
|
|
726 Arg [1] : string $source_version (optional)
|
|
727 The new value to set the source_version attribute to
|
|
728 Example : $source_version = $svf->source_version()
|
|
729 Description: Getter/Setter for the source_version attribute
|
|
730 Returntype : string
|
|
731 Exceptions : none
|
|
732 Caller : general
|
|
733 Status : At Risk
|
|
734
|
|
735 =cut
|
|
736
|
|
737 sub source_version {
|
|
738 my $self = shift;
|
|
739 return $self->{'source_version'} = shift if(@_);
|
|
740 return $self->{'source_version'};
|
|
741 }
|
|
742
|
|
743 =head2 bound_start
|
|
744
|
|
745 Args : None
|
|
746 Example : my $bound_start = $svf->bound_start();
|
|
747 Description : Getter/setter for the 5'-most coordinate defined for this StructuralVariationFeature (outer_start or start)
|
|
748 ReturnType : int
|
|
749 Exceptions : none
|
|
750 Caller : general
|
|
751 Status : At risk
|
|
752 =cut
|
|
753
|
|
754 sub bound_start{
|
|
755 my $self = shift;
|
|
756 return $self->{'outer_start'} if (defined($self->{'outer_start'}));
|
|
757 return $self->{'start'};
|
|
758 }
|
|
759
|
|
760
|
|
761 =head2 bound_end
|
|
762
|
|
763 Args : None
|
|
764 Example : my $bound_end = $svf->bound_end();
|
|
765 Description : Getter/setter for the 3'-most coordinate defined for this StructuralVariationFeature (outer_end or end)
|
|
766 ReturnType : int
|
|
767 Exceptions : none
|
|
768 Caller : general
|
|
769 Status : At risk
|
|
770 =cut
|
|
771
|
|
772 sub bound_end{
|
|
773 my $self = shift;
|
|
774 return $self->{'outer_end'} if (defined($self->{'outer_end'}));
|
|
775 return $self->{'end'};
|
|
776 }
|
|
777
|
|
778
|
|
779 =head2 outer_start
|
|
780
|
|
781 Arg [1] : int $outer_start (optional)
|
|
782 The new value to set the outer_start attribute to
|
|
783 Example : my $outer_start = $svf->outer_start();
|
|
784 Description : Getter/setter for the 5'-most coordinate defined for this StructuralVariationFeature
|
|
785 ReturnType : int
|
|
786 Exceptions : none
|
|
787 Caller : general
|
|
788 Status : At risk
|
|
789 =cut
|
|
790
|
|
791 sub outer_start{
|
|
792 my $self = shift;
|
|
793 return $self->{'outer_start'} = shift if(@_);
|
|
794 return $self->{'outer_start'};
|
|
795 }
|
|
796
|
|
797
|
|
798 =head2 outer_end
|
|
799
|
|
800 Arg [1] : int $outer_end (optional)
|
|
801 The new value to set the outer_end attribute to
|
|
802 Example : my $outer_end = $svf->outer_end();
|
|
803 Description : Getter/setter for the 3'-most coordinate defined for this StructuralVariationFeature
|
|
804 ReturnType : int
|
|
805 Exceptions : none
|
|
806 Caller : general
|
|
807 Status : At risk
|
|
808 =cut
|
|
809
|
|
810 sub outer_end{
|
|
811 my $self = shift;
|
|
812 return $self->{'outer_end'} = shift if(@_);
|
|
813 return $self->{'outer_end'};
|
|
814 }
|
|
815
|
|
816
|
|
817 =head2 inner_start
|
|
818
|
|
819 Arg [1] : int $inner_start (optional)
|
|
820 The new value to set the inner_start attribute to
|
|
821 Example : my $inner_start = $svf->inner_start();
|
|
822 Description : Getter/setter for the 5'-less coordinate defined for this StructuralVariationFeature
|
|
823 ReturnType : int
|
|
824 Exceptions : none
|
|
825 Caller : general
|
|
826 Status : At Risk
|
|
827 =cut
|
|
828
|
|
829 sub inner_start{
|
|
830 my $self = shift;
|
|
831 return $self->{'inner_start'} = shift if(@_);
|
|
832 return $self->{'inner_start'};
|
|
833 }
|
|
834
|
|
835
|
|
836 =head2 inner_end
|
|
837
|
|
838 Arg [1] : int $inner_end (optional)
|
|
839 The new value to set the inner_end attribute to
|
|
840 Example : my $inner_end = $svf->inner_end();
|
|
841 Description : Getter/setter for the 3'-less coordinate defined for this StructuralVariationFeature
|
|
842 ReturnType : int
|
|
843 Exceptions : none
|
|
844 Caller : general
|
|
845 Status : At Risk
|
|
846 =cut
|
|
847
|
|
848 sub inner_end{
|
|
849 my $self = shift;
|
|
850 return $self->{'inner_end'} = shift if(@_);
|
|
851 return $self->{'inner_end'};
|
|
852 }
|
|
853
|
|
854
|
|
855 =head2 get_reference_sequence
|
|
856
|
|
857 Args : none
|
|
858 Example : my $seq = $svf->get_reference_sequence
|
|
859 Description : returns a string containing the reference sequence for the region
|
|
860 covered by this StructuralVariationFeature
|
|
861 ReturnType : string
|
|
862 Exceptions : none
|
|
863 Caller : general
|
|
864 Status : At Risk
|
|
865 =cut
|
|
866
|
|
867 sub get_reference_sequence{
|
|
868 my $self = shift;
|
|
869
|
|
870 return $self->feature_Slice->seq();
|
|
871 }
|
|
872
|
|
873
|
|
874 sub transform {
|
|
875 my $self = shift;
|
|
876
|
|
877 # run the transform method from the parent class
|
|
878 my $transformed = $self->SUPER::transform(@_);
|
|
879
|
|
880 if(defined $transformed) {
|
|
881 # fit the start and end coords to the new coords
|
|
882 $transformed->_fix_bounds($self);
|
|
883 }
|
|
884
|
|
885 return $transformed;
|
|
886 }
|
|
887
|
|
888
|
|
889 sub transfer {
|
|
890 my $self = shift;
|
|
891
|
|
892 # run the transfer method from the parent class
|
|
893 my $transferred = $self->SUPER::transfer(@_);
|
|
894
|
|
895 if(defined $transferred) {
|
|
896 # fit the start and end coords to the new coords
|
|
897 $transferred->_fix_bounds($self);
|
|
898 }
|
|
899
|
|
900 return $transferred;
|
|
901 }
|
|
902
|
|
903
|
|
904 sub _fix_bounds {
|
|
905 my $self = shift;
|
|
906 my $old = shift;
|
|
907
|
|
908 if(defined $old->{'outer_start'}) {
|
|
909 $self->{'outer_start'} = $self->start - ($old->start - $old->{'outer_start'});
|
|
910 }
|
|
911
|
|
912 if(defined $old->{'outer_end'}) {
|
|
913 $self->{'outer_end'} = $self->end + ($old->{'outer_end'} - $old->end);
|
|
914 }
|
|
915 }
|
|
916
|
|
917 sub _sort_svos {
|
|
918 my $self = shift;
|
|
919
|
|
920 return unless defined $self->{structural_variation_overlaps};
|
|
921
|
|
922 my @svos = @{$self->{structural_variation_overlaps}};
|
|
923
|
|
924 # define a feature order for sorting
|
|
925 my %feature_order = (
|
|
926 'Bio::EnsEMBL::Gene' => 1,
|
|
927 'Bio::EnsEMBL::Transcript' => 2,
|
|
928 'Bio::EnsEMBL::Exon' => 3,
|
|
929 );
|
|
930
|
|
931 # sort them nicely by feature type and position
|
|
932 @svos = sort {
|
|
933 $feature_order{ref($a->feature)} <=> $feature_order{ref($b->feature)} ||
|
|
934 $a->feature->start <=> $b->feature->start
|
|
935 } @svos;
|
|
936
|
|
937 $self->{structural_variation_overlaps} = \@svos;
|
|
938 }
|
|
939
|
|
940 1;
|