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::External::ExternalFeatureAdaptor
|
|
24
|
|
25 =head 1 SUMMARY
|
|
26
|
|
27 Allows features created externally from Ensembl in a single
|
|
28 coordinate system to be retrieved in several other (Ensembl-style)
|
|
29 coordinate systems. This is intended to be a replacement for the old
|
|
30 Bio::EnsEMBL::DB::ExternalFeatureFactoryI interface.
|
|
31
|
|
32 =head1 SYNOPSIS
|
|
33
|
|
34 $database_adaptor = new Bio::EnsEMBL::DBSQL::DBAdaptor(
|
|
35 -host => 'kaka.sanger.ac.uk',
|
|
36 -dbname => 'homo_sapiens_core_9_30',
|
|
37 -pass => 'anonymous'
|
|
38 );
|
|
39
|
|
40 $xf_adaptor = new ExternalFeatureAdaptorSubClass;
|
|
41
|
|
42 # Connect the Ensembl core database:
|
|
43 $xf_adaptor->db($database_adaptor);
|
|
44
|
|
45 # get some features in vontig coords
|
|
46 @feats =
|
|
47 @{ $xf_adaptor->fetch_all_by_contig_name('AC000087.2.1.42071') };
|
|
48
|
|
49 # get some features in assembly coords
|
|
50 @feats =
|
|
51 @{ $xf_adaptor->fetch_all_by_chr_start_end( 'X', 100000, 200000 ) };
|
|
52
|
|
53 # get some features in clone coords
|
|
54 @feats = @{ $xf_adaptor->fetch_all_by_clone_accession('AC000087') };
|
|
55
|
|
56 # Add the adaptor to the ensembl core dbadaptor (implicitly sets db
|
|
57 # attribute)
|
|
58 $database_adaptor->add_ExternalFeatureAdaptor($xf_adaptor);
|
|
59
|
|
60 # get some features in Slice coords
|
|
61 $slice_adaptor = $database_adaptor->get_SliceAdaptor;
|
|
62 $slice =
|
|
63 $slice_adaptor->fetch_all_by_chr_start_end( 1, 100000, 200000 );
|
|
64 @feats = @{ $xf_adaptor->fetch_all_by_Slice($slice) };
|
|
65
|
|
66 # now features can be retrieved directly from Slice
|
|
67 @feats = @{ $slice->get_all_ExternalFeatures };
|
|
68
|
|
69 =head1 DESCRIPTION
|
|
70
|
|
71 This class is intended to be used as a method of getting external
|
|
72 features into EnsEMBL. To work, this class must be extended and must
|
|
73 implement the the coordinate_systems method. As well, the subclass
|
|
74 is required to implement a single fetch method so that the external
|
|
75 features may be retrieved. By implementing a single fetch_method in a
|
|
76 single coordinate system all of the other ExternalFeatureAdaptor fetch
|
|
77 methods become available for retrieving the data in several different
|
|
78 coordinate systems.
|
|
79
|
|
80 The coordinate_systems method should return a list of strings indicating
|
|
81 which coordinate system(s) have been implemented. If a given string is
|
|
82 returned from the coordinate_systems method then the corresponding fetch
|
|
83 method must be implemented. The reverse is also true: if a fetch method
|
|
84 is implemented then coordinate_systems must return the appropriate
|
|
85 string in its list of return values. The following are the valid
|
|
86 coordinate system values and the corresponding fetch methods that must
|
|
87 be implemented:
|
|
88
|
|
89 COORD SYSTEM STRING FETCH_METHOD
|
|
90 ------------------- ------------
|
|
91 'ASSEMBLY' fetch_all_by_chr_start_end
|
|
92 'CLONE' fetch_all_by_clone_accession
|
|
93 'CONTIG' fetch_all_by_contig_name
|
|
94 'SUPERCONTIG' fetch_all_by_supercontig_name
|
|
95 'SLICE' fetch_all_by_Slice
|
|
96
|
|
97 The objects returned by the fetch methods should be EnsEMBL or BioPerl
|
|
98 style Feature objects. These objects MUST have start, end and strand
|
|
99 methods.
|
|
100
|
|
101 Before the non-overridden ExternalFeatureAdaptor fetch methods may
|
|
102 be called an EnsEMBL core database adaptor must be attached to the
|
|
103 ExternalFeatureAdaptor . This database adaptor is required to perform
|
|
104 the remappings between various coordinate system. This may be done
|
|
105 implicitly by adding the ExternalFeatureAdaptor to the database adaptor
|
|
106 through a call to the DBAdaptor add_ExternalFeatureAdaptor method or
|
|
107 explicitly by calling the ExternalFeatureAdaptor ensembl_db method.
|
|
108
|
|
109 =head1 METHODS
|
|
110
|
|
111 =cut
|
|
112
|
|
113 package Bio::EnsEMBL::External::ExternalFeatureAdaptor;
|
|
114
|
|
115 use strict;
|
|
116
|
|
117 use Bio::EnsEMBL::Utils::Exception qw(warning throw);
|
|
118
|
|
119
|
|
120 =head2 new
|
|
121
|
|
122 Arg [1] : none
|
|
123 Example : $xfa = new Bio::EnsEMBL::External::ExternalFeatureAdaptor;
|
|
124 Description: Creates a new ExternalFeatureAdaptor object. You may wish to
|
|
125 extend this constructor and provide your own set of paremeters.
|
|
126 Returntype : Bio::EnsEMBL::External::ExternalFeatureAdaptor
|
|
127 Exceptions : none
|
|
128 Caller : general
|
|
129
|
|
130 =cut
|
|
131
|
|
132 sub new {
|
|
133 my $class = shift;
|
|
134
|
|
135 if(ref $class) {
|
|
136 return bless {}, ref $class;
|
|
137 }
|
|
138
|
|
139 return bless {}, $class;
|
|
140 }
|
|
141
|
|
142
|
|
143
|
|
144 =head2 ensembl_db
|
|
145
|
|
146 Arg [1] : (optional) Bio::EnsEMBL::DBSQL::DBAdaptor
|
|
147 Example : $external_feature_adaptor->ensembl_db($new_val);
|
|
148 Description: none
|
|
149 Returntype : Bio::EnsEMBL::DBSQL::DBAdaptor
|
|
150 Exceptions : none
|
|
151 Caller : internal
|
|
152
|
|
153 =cut
|
|
154
|
|
155 sub ensembl_db {
|
|
156 my ($self, $value) = @_;
|
|
157
|
|
158 if($value) {
|
|
159 $self->{'ensembl_db'} = $value;
|
|
160 }
|
|
161
|
|
162 return $self->{'ensembl_db'};
|
|
163 }
|
|
164
|
|
165
|
|
166
|
|
167 =head2 coordinate_systems
|
|
168
|
|
169 Arg [1] : none
|
|
170 Example : @implemented_coord_systems = $ext_adaptor->coordinate_systems;
|
|
171 Description: ABSTRACT method. Must be implemented by all
|
|
172 ExternalFeatureAdaptor subclasses. This method returns a list
|
|
173 of coordinate systems which are implemented by the subclass.
|
|
174 A minimum of on valid coordinate system must be implemented.
|
|
175 Valid coordinate systems are: 'SLICE', 'ASSEMBLY', 'CONTIG',
|
|
176 and 'CLONE'.
|
|
177 Returntype : list of strings
|
|
178 Exceptions : none
|
|
179 Caller : internal
|
|
180
|
|
181 =cut
|
|
182
|
|
183 sub coordinate_systems {
|
|
184 my $self = shift;
|
|
185
|
|
186 throw("abstract method coordinate_systems not implemented\n");
|
|
187
|
|
188 return '';
|
|
189 }
|
|
190
|
|
191
|
|
192 =head2 track_name
|
|
193
|
|
194 Arg [1] : none
|
|
195 Example : $track_name = $xf_adaptor->track_name;
|
|
196 Description: Currently this is not really used. In the future it may be
|
|
197 possible to have ExternalFeatures automatically displayed by
|
|
198 the EnsEMBL web code. By default this method returns
|
|
199 'External features' but you are encouraged to override this
|
|
200 method and provide your own meaningful name for the features
|
|
201 your adaptor provides. This also allows you to distinguish the
|
|
202 type of features retrieved from Slices. See
|
|
203 the PODs for Bio::EnsEMBL::Slice::get_all_ExternalFeatures and
|
|
204 Bio::EnsEMBL::DBSQL::DBAdaptor::add_ExternalFeatureAdaptor
|
|
205 methods.
|
|
206 Returntype : string
|
|
207 Exceptions : none
|
|
208 Caller : Bio::EnsEMBL::DBSQL::DBAdaptor::add_ExternalFeatureAdaptor
|
|
209
|
|
210 =cut
|
|
211
|
|
212 sub track_name {
|
|
213 my $self = shift;
|
|
214
|
|
215 return 'External features';
|
|
216 }
|
|
217
|
|
218
|
|
219
|
|
220 =head2 feature_type
|
|
221
|
|
222 Arg [1] : none
|
|
223 Example : $feature_type = $xf_adaptor->track_name
|
|
224 Description: Currently this is not used. In the future it may be possible
|
|
225 to have ExternalFeatures automatically displayed by the EnsEMBL
|
|
226 web code. This method would then be used do determine the
|
|
227 type of glyphs used to draw the features which are returned
|
|
228 from this external adaptor.
|
|
229 Returntype : string
|
|
230 Exceptions : none
|
|
231 Caller : none
|
|
232
|
|
233 =cut
|
|
234
|
|
235 sub feature_type {
|
|
236 my $self = shift;
|
|
237
|
|
238 return qw(SIMPLE);
|
|
239 }
|
|
240
|
|
241
|
|
242
|
|
243 =head2 fetch_all_by_Slice
|
|
244
|
|
245 Arg [1] : Bio::EnsEMBL::Slice $slice
|
|
246 Example : @features = @{$ext_adaptor->fetch_all_by_Slice($slice)};
|
|
247 Description: Retrieves all features which lie in the region defined
|
|
248 by $slice in slice coordinates.
|
|
249
|
|
250 If this method is overridden then the coordinate_systems method
|
|
251 must return 'SLICE' as one of its values.
|
|
252
|
|
253 This method will work as is (i.e. without overriding it)
|
|
254 providing at least one of the other fetch methods is overridden.
|
|
255 Returntype : reference to a list of Bio::SeqFeature objects in the Slice
|
|
256 coordinate system
|
|
257 Exceptions : Thrown on incorrect input arguments
|
|
258 Caller : general, fetch_all_by_chr_start_end
|
|
259
|
|
260 =cut
|
|
261
|
|
262 sub fetch_all_by_Slice {
|
|
263 my ($self, $slice) = @_;
|
|
264
|
|
265 unless($slice && ref $slice && $slice->isa('Bio::EnsEMBL::Slice')) {
|
|
266 throw("[$slice] is not a Bio::EnsEMBL::Slice");
|
|
267 }
|
|
268
|
|
269 my $out = [];
|
|
270
|
|
271 my $csa = $self->ensembl_db->get_CoordSystemAdaptor();
|
|
272
|
|
273 my $slice_start = $slice->start;
|
|
274 my $slice_end = $slice->end;
|
|
275 my $slice_strand = $slice->strand;
|
|
276 my $slice_seq_region = $slice->seq_region_name;
|
|
277 my $slice_seq_region_id = $slice->get_seq_region_id;
|
|
278 my $coord_system = $slice->coord_system;
|
|
279
|
|
280 if($self->_supported('SLICE')) {
|
|
281 throw("ExternalFeatureAdaptor supports SLICE coordinate system" .
|
|
282 " but fetch_all_by_Slice not implemented");
|
|
283 }
|
|
284
|
|
285 my %features;
|
|
286 my $from_coord_system;
|
|
287
|
|
288 my $fetch_method;
|
|
289
|
|
290 #
|
|
291 # Get all of the features from whatever coord system they are computed in
|
|
292 #
|
|
293 if($self->_supported('CLONE')) {
|
|
294 $fetch_method = sub {
|
|
295 my $self = shift;
|
|
296 my $name = shift;
|
|
297 my ($acc, $ver) = split(/\./, $name);
|
|
298 $self->fetch_all_by_clone_accession($acc,$ver,@_);
|
|
299 };
|
|
300 $from_coord_system = $csa->fetch_by_name('clone');
|
|
301 } elsif($self->_supported('ASSEMBLY')) {
|
|
302 $from_coord_system = $csa->fetch_by_name('chromosome');
|
|
303 $fetch_method = $self->can('fetch_all_by_chr_start_end');
|
|
304 } elsif($self->_supported('CONTIG')) {
|
|
305 $from_coord_system = $csa->fetch_by_name('contig');
|
|
306 $fetch_method = $self->can('fetch_all_by_contig_name');
|
|
307 } elsif($self->_supported('SUPERCONTIG')) {
|
|
308 $from_coord_system = $csa->fetch_by_name('supercontig');
|
|
309 $fetch_method = $self->can('fetch_all_by_supercontig_name');
|
|
310 } else {
|
|
311 $self->_no_valid_coord_systems();
|
|
312 }
|
|
313
|
|
314 if($from_coord_system->equals($coord_system)) {
|
|
315 $features{$slice_seq_region} = &$fetch_method($self, $slice_seq_region,
|
|
316 $slice_start,$slice_end);
|
|
317 } else {
|
|
318 foreach my $segment (@{$slice->project($from_coord_system->name,
|
|
319 $from_coord_system->version)}) {
|
|
320 my ($start,$end,$pslice) = @$segment;
|
|
321 $features{$pslice->seq_region_name } ||= [];
|
|
322 push @{$features{$pslice->seq_region_name }},
|
|
323 @{&$fetch_method($self, $pslice->seq_region_name,
|
|
324 $pslice->start(),
|
|
325 $pslice->end())};
|
|
326 }
|
|
327 }
|
|
328
|
|
329 my @out;
|
|
330
|
|
331 if(!$coord_system->equals($from_coord_system)) {
|
|
332 my $asma = $self->ensembl_db->get_AssemblyMapperAdaptor();
|
|
333 my $mapper = $asma->fetch_by_CoordSystems($from_coord_system,
|
|
334 $coord_system);
|
|
335 my %slice_cache;
|
|
336 my $slice_adaptor = $self->ensembl_db->get_SliceAdaptor();
|
|
337 my $slice_setter;
|
|
338
|
|
339 #convert the coordinates of each of the features retrieved
|
|
340 foreach my $fseq_region (keys %features) {
|
|
341 my $feats = $features{$fseq_region};
|
|
342 next if(!$feats);
|
|
343 $slice_setter = _guess_slice_setter($feats) if(!$slice_setter);
|
|
344
|
|
345 foreach my $f (@$feats) {
|
|
346 my($sr_id, $start, $end, $strand) =
|
|
347 $mapper->fastmap($fseq_region,$f->start,$f->end,$f->strand,
|
|
348 $from_coord_system);
|
|
349
|
|
350 #maps to gap
|
|
351 next if(!defined($sr_id));
|
|
352
|
|
353 #maps to unexpected seq region, probably error in the externally
|
|
354 if($sr_id ne $slice_seq_region_id) {
|
|
355 warning("Externally created Feature mapped to [$sr_id] " .
|
|
356 "which is not on requested seq_region_id [$slice_seq_region_id]");
|
|
357 next;
|
|
358 }
|
|
359
|
|
360 #update the coordinates of the feature
|
|
361 &$slice_setter($f,$slice);
|
|
362 $f->start($start);
|
|
363 $f->end($end);
|
|
364 $f->strand($strand);
|
|
365 push @out, $f;
|
|
366 }
|
|
367 }
|
|
368 } else {
|
|
369 #we already know the seqregion the featues are on, we just have
|
|
370 #to put them on the slice
|
|
371 @out = @{$features{$slice_seq_region}};
|
|
372 my $slice_setter = _guess_slice_setter(\@out);
|
|
373
|
|
374 foreach my $f (@out) {
|
|
375 &$slice_setter($f,$slice);
|
|
376 }
|
|
377 }
|
|
378
|
|
379 #shift the feature coordinates again if
|
|
380 #the requested slice is not the full seqregion
|
|
381 if($slice->start != 1 || $slice->strand != 1) {
|
|
382 #convert from assembly coords to slice coords
|
|
383 my($f_start, $f_end, $f_strand);
|
|
384 foreach my $f (@out) {
|
|
385 if($slice_strand == 1) {
|
|
386 $f_start = $f->start - $slice_start + 1;
|
|
387 $f_end = $f->end - $slice_start + 1;
|
|
388 $f_strand = $f->strand;
|
|
389 } else {
|
|
390 $f_start = $slice_end - $f->end + 1;
|
|
391 $f_end = $slice_end - $f->start + 1;
|
|
392 $f_strand = $f->strand * -1;
|
|
393 }
|
|
394
|
|
395 $f->start($f_start);
|
|
396 $f->end($f_end);
|
|
397 $f->strand($f_strand);
|
|
398 }
|
|
399 }
|
|
400
|
|
401 return \@out;
|
|
402 }
|
|
403
|
|
404
|
|
405 sub _guess_slice_setter {
|
|
406 my $features = shift;
|
|
407
|
|
408 #we do not know what type of features these are. They might
|
|
409 #be bioperl features or old ensembl features, hopefully they are new
|
|
410 #style features. Try to come up with a setter method for the
|
|
411 #slice.
|
|
412
|
|
413 return undef if(!@$features);
|
|
414
|
|
415 my ($f) = @$features;
|
|
416
|
|
417 my $slice_setter;
|
|
418 foreach my $method (qw(slice contig attach_seq)) {
|
|
419 last if($slice_setter = $f->can($method));
|
|
420 }
|
|
421
|
|
422 if(!$slice_setter) {
|
|
423 if($f->can('seqname')) {
|
|
424 $slice_setter = sub { $_[0]->seqname($_[1]->seq_region_name()); };
|
|
425 } else {
|
|
426 $slice_setter = sub{} if(!$slice_setter);
|
|
427 }
|
|
428 }
|
|
429
|
|
430 return $slice_setter;
|
|
431 }
|
|
432
|
|
433
|
|
434 =head2 fetch_all_by_contig_name
|
|
435
|
|
436 Arg [1] : string $contig_name
|
|
437 Arg [2] : int $start (optional)
|
|
438 The start of the region on the contig to retrieve features on
|
|
439 if not specified the whole of the contig is used.
|
|
440 Arg [3] : int $end (optional)
|
|
441 The end of the region on the contig to retrieve features on
|
|
442 if not specified the whole of the contig is used.
|
|
443 Example : @fs = @{$self->fetch_all_by_contig_name('AB00879.1.1.39436')};
|
|
444 Description: Retrieves features on the contig defined by the name
|
|
445 $contig_name in contig coordinates.
|
|
446
|
|
447 If this method is overridden then the coordinate_systems
|
|
448 method must return 'CONTIG' as one of its values.
|
|
449
|
|
450 This method will work as is (i.e. without being overridden)
|
|
451 providing at least one other fetch method has
|
|
452 been overridden.
|
|
453 Returntype : reference to a list of Bio::SeqFeature objects in the contig
|
|
454 coordinate system.
|
|
455 Exceptions : thrown if the input argument is incorrect
|
|
456 thrown if the coordinate_systems method returns the value
|
|
457 'CONTIG' and this method has not been overridden.
|
|
458 Caller : general, fetch_all_by_Slice
|
|
459
|
|
460 =cut
|
|
461
|
|
462 sub fetch_all_by_contig_name {
|
|
463 my ($self, $contig_name, $start, $end) = @_;
|
|
464
|
|
465 unless($contig_name) {
|
|
466 throw("contig_name argument not defined");
|
|
467 }
|
|
468
|
|
469 if($self->_supported('CONTIG')) {
|
|
470 throw("ExternalFeatureAdaptor supports CONTIG coordinate system" .
|
|
471 " but fetch_all_by_contig_name is not implemented");
|
|
472 }
|
|
473
|
|
474 unless($self->ensembl_db) {
|
|
475 throw('DB attribute not set. This value must be set for the ' .
|
|
476 'ExternalFeatureAdaptor to function correctly');
|
|
477 }
|
|
478
|
|
479 my $slice_adaptor = $self->ensembl_db->get_SliceAdaptor();
|
|
480 my $slice = $slice_adaptor->fetch_by_region('contig', $contig_name,
|
|
481 $start, $end);
|
|
482 return $self->fetch_all_by_Slice($slice);
|
|
483 }
|
|
484
|
|
485
|
|
486
|
|
487 =head2 fetch_all_by_supercontig_name
|
|
488
|
|
489 Arg [1] : string $supercontig_name
|
|
490 Arg [2] : int $start (optional)
|
|
491 The start of the region on the contig to retrieve features on
|
|
492 if not specified the whole of the contig is used.
|
|
493 Arg [3] : int $end (optional)
|
|
494 The end of the region on the contig to retrieve features on
|
|
495 if not specified the whole of the contig is used.
|
|
496 Example : @fs = @{$self->fetch_all_by_contig_name('NT_004321')};
|
|
497 Description: Retrieves features on the contig defined by the name
|
|
498 $supercontigname in supercontig coordinates.
|
|
499
|
|
500 If this method is overridden then the coordinate_systems
|
|
501 method must return 'SUPERCONTIG' as one of its values.
|
|
502
|
|
503 This method will work as is (i.e. without being overridden)
|
|
504 providing at least one other fetch method has
|
|
505 been overridden.
|
|
506 Returntype : reference to a list of Bio::SeqFeature objects in the contig
|
|
507 coordinate system.
|
|
508 Exceptions : thrown if the input argument is incorrect
|
|
509 thrown if the coordinate_systems method returns the value
|
|
510 'SUPERCONTIG' and this method has not been overridden.
|
|
511 Caller : general, fetch_all_by_Slice
|
|
512
|
|
513 =cut
|
|
514
|
|
515
|
|
516 sub fetch_all_by_supercontig_name {
|
|
517 my ($self, $supercontig_name, $start, $end) = @_;
|
|
518
|
|
519 unless($supercontig_name) {
|
|
520 throw("supercontig_name argument not defined");
|
|
521 }
|
|
522
|
|
523 if($self->_supported('SUPERCONTIG')) {
|
|
524 throw("ExternalFeatureAdaptor supports SUPERCONTIG coordinate system" .
|
|
525 " but fetch_all_by_supercontig_name is not implemented");
|
|
526 }
|
|
527
|
|
528 unless($self->ensembl_db) {
|
|
529 throw('DB attribute not set. This value must be set for the ' .
|
|
530 'ExternalFeatureAdaptor to function correctly');
|
|
531 }
|
|
532
|
|
533 my $slice_adaptor = $self->ensembl_db->get_SliceAdaptor();
|
|
534 my $slice = $slice_adaptor->fetch_by_region('supercontig', $supercontig_name,
|
|
535 $start, $end);
|
|
536 return $self->fetch_all_by_Slice($slice);
|
|
537 }
|
|
538
|
|
539
|
|
540 =head2 fetch_all_by_clone_accession
|
|
541
|
|
542 Arg [1] : string $acc
|
|
543 The EMBL accession number of the clone to fetch features from.
|
|
544 Arg [2] : (optional) string $ver
|
|
545 Arg [3] : (optional) int $start
|
|
546 Arg [4] : (optional) int $end
|
|
547
|
|
548 Example : @fs = @{$self->fetch_all_by_clone_accession('AC000093')};
|
|
549 Description: Retrieves features on the clone defined by the $acc arg in
|
|
550 Clone coordinates.
|
|
551
|
|
552 If this method is overridden then the coordinate_systems method
|
|
553 must return 'CLONE' as one of its values. The arguments
|
|
554 start, end, version are passed if this method is overridden and
|
|
555 can optionally be used to reduce the scope of the query and
|
|
556 improve performance.
|
|
557
|
|
558 This method will work as is - providing at least one other
|
|
559 fetch method has been overridden.
|
|
560 Returntype : reference to a list of Bio::SeqFeature objects in the Clone
|
|
561 coordinate system
|
|
562 Exceptions : thrown if the input argument is incorrect
|
|
563 thrown if the coordinate system method returns the value 'CLONE'
|
|
564 and this method is not overridden.
|
|
565 thrown if the coordinate systems method does not return any
|
|
566 valid values.
|
|
567 Caller : general, fetch_all_by_clone_accession
|
|
568
|
|
569 =cut
|
|
570
|
|
571 sub fetch_all_by_clone_accession {
|
|
572 my ($self, $acc, $version, $start, $end) = @_;
|
|
573
|
|
574 unless($acc) {
|
|
575 throw("clone accession argument not defined");
|
|
576 }
|
|
577
|
|
578 if($self->_supported('CLONE')) {
|
|
579 throw('ExternalFeatureAdaptor supports CLONE coordinate system ' .
|
|
580 'but does not implement fetch_all_by_clone_accession');
|
|
581 }
|
|
582
|
|
583 unless($self->ensembl_db) {
|
|
584 throw('DB attribute not set. This value must be set for the ' .
|
|
585 'ExternalFeatureAdaptor to function correctly');
|
|
586 }
|
|
587
|
|
588 if(defined($version)) {
|
|
589 $acc = "$acc.$version";
|
|
590 } elsif(!$acc =~ /\./) {
|
|
591 $acc = "$acc.1";
|
|
592 }
|
|
593
|
|
594 my $slice_adaptor = $self->ensembl_db->get_SliceAdaptor;
|
|
595
|
|
596 my $slice = $slice_adaptor->fetch_by_region('clone', $acc, $start, $end);
|
|
597
|
|
598 return $self->fetch_all_by_Slice($slice);
|
|
599 }
|
|
600
|
|
601
|
|
602
|
|
603 =head2 fetch_all_by_chr_start_end
|
|
604
|
|
605 Arg [1] : string $chr_name
|
|
606 The name of the chromosome to retrieve features from
|
|
607 Arg [2] : int $start
|
|
608 The start coordinate of the chromosomal region to retrieve
|
|
609 features from.
|
|
610 Arg [3] : int $end
|
|
611 The end coordinate of the chromosomal region to retrieve
|
|
612 features from.
|
|
613 Example : @features
|
|
614 Description: Retrieves features on the region defined by the $chr_name,
|
|
615 $start, and $end args in assembly (chromosomal) coordinates.
|
|
616
|
|
617 If this method is overridden then the coordinate_systems method
|
|
618 must return 'ASSEMBLY' as one of its values.
|
|
619
|
|
620 This method will work as is (i.e. without overriding it)
|
|
621 providing at least one of the other fetch methods is overridden.
|
|
622 Returntype : reference to a list of Bio::SeqFeatures
|
|
623 Exceptions : Thrown if the coordinate_systems method returns ASSEMBLY as a
|
|
624 value and this method is not overridden.
|
|
625 Thrown if any of the input arguments are incorrect
|
|
626 Caller : general, fetch_all_by_Slice
|
|
627
|
|
628 =cut
|
|
629
|
|
630 sub fetch_all_by_chr_start_end {
|
|
631 my ($self, $chr_name, $start, $end) = @_;
|
|
632
|
|
633 unless($chr_name && defined $start && defined $end && $start < $end) {
|
|
634 throw("Incorrect start [$start] end [$end] or chr [$chr_name] arg");
|
|
635 }
|
|
636
|
|
637 unless($self->ensembl_db) {
|
|
638 throw('DB attribute not set. This value must be set for the ' .
|
|
639 'ExternalFeatureAdaptor to function correctly');
|
|
640 }
|
|
641
|
|
642 my $slice_adaptor = $self->ensembl_db->get_SliceAdaptor();
|
|
643
|
|
644 my $slice = $slice_adaptor->fetch_by_region('toplevel', $chr_name, $start,
|
|
645 $end);
|
|
646
|
|
647 return $self->fetch_all_by_Slice($slice);
|
|
648 }
|
|
649
|
|
650
|
|
651 =head2 _no_valid_coord_system
|
|
652
|
|
653 Arg [1] : none
|
|
654 Example : none
|
|
655 Description: PRIVATE method - throws an error with a descriptive message
|
|
656 Returntype : none
|
|
657 Exceptions : always thrown
|
|
658 Caller : internal
|
|
659
|
|
660 =cut
|
|
661
|
|
662 sub _no_valid_coord_system {
|
|
663 my $self = shift;
|
|
664
|
|
665 throw("This ExternalFeatureAdaptor does not support a known " .
|
|
666 "coordinate system.\n Valid coordinate systems are: " .
|
|
667 "[SLICE,ASSEMBLY,SUPERCONTIG,CONTIG,CLONE].\n This External Adaptor " .
|
|
668 "supports: [" . join(', ', $self->coordinate_systems) . "]");
|
|
669 }
|
|
670
|
|
671
|
|
672
|
|
673
|
|
674 =head2 _supported
|
|
675
|
|
676 Arg [1] : string $system
|
|
677 Example : print "CONTIG system supported" if($self->_supported('CONTIG'));
|
|
678 Description: PRIVATE method. Tests if the coordinate system defined by
|
|
679 the $system argument is implemented.
|
|
680 Returntype : boolean
|
|
681 Exceptions : none
|
|
682 Caller : internal
|
|
683
|
|
684 =cut
|
|
685
|
|
686 sub _supported {
|
|
687 my ($self, $system) = @_;
|
|
688
|
|
689 #construct the hash of supported features if it has not been already
|
|
690 unless(exists $self->{_supported}) {
|
|
691 $self->{_supported} = {};
|
|
692 foreach my $coord_system ($self->coordinate_systems) {
|
|
693 $self->{_supported}->{$coord_system} = 1;
|
|
694 }
|
|
695 }
|
|
696
|
|
697 return $self->{_supported}->{$system};
|
|
698 }
|
|
699
|
|
700
|
|
701
|
|
702 1;
|