EnsEMBL/DB/ExternalFeatureFactoryI.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 69 CC 3 SCAR 15.0
CC
3
Cov
0%
fetch_all_by_contig_name
12.0
coordinate_systems
2.0
get_Ensembl_SeqFeatures_contig
2.0
CRAP 4.5
1 =head1 LICENSE
2  
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5  
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9  
10 http://www.apache.org/licenses/LICENSE-2.0
11  
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17  
18 =cut
19  
20  
21 =head1 CONTACT
22  
23 Please email comments or questions to the public Ensembl
24 developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25  
26 Questions may also be sent to the Ensembl help desk at
27 <http://www.ensembl.org/Help/Contact>.
28  
29 =cut
30  
31 =head1 NAME
32  
33 Bio::EnsEMBL::DB::ExternalFeatureFactoryI -
34 Legacy Abstract interface for External Feature
35 Factories. Bio::EnsEMBL::External::ExternalFeatureAdaptor should be used
36 instead if possible.
37  
38 =head1 SYNOPSIS
39  
40 $external_ff = new ImplementingExternalFeatureFactoryClass;
41  
42 $database_adaptor = new Bio::EnsEMBL::DBSQL::DBAdaptor(
43 -host => 'blah',
44 -dbname => 'other',
45 -pass => 'pass'
46 );
47  
48 # alternatively, you can add external databases to an obj once made
49 $database_adaptor->add_ExternalFeatureFactory($external_ff);
50  
51 # now the ExternalFeatureFactory has been added, Ensembl RawContigs
52 # and Slices will now have ExternalFeatures on them
53 $contig =
54 $db_adaptor->get_RawContigAdaptor->fetch_by_name('AC00056.00001');
55 @external = @{ $contig->get_all_ExternalFeatures() };
56  
57 # this works on Slices as well
58 $slice =
59 $db_adaptor->get_SliceAdaptor->fetch_by_chr_start_end( '12', 10000,
60 30000 );
61 @external = @{ $slice->get_all_ExternalFeatures() };
62  
63 =head1 DESCRIPTION
64  
65 This is a legacy class. It is included only for backwards
66 compatibility with ExternalFeatureFactories which are presumably
67 still used to place data into ensembl. It is recommended that if
68 you wish to create EnsEMBL features externally that you use the
69 Bio::EnsEMBL::External::ExternalFeatureAdaptor instead.
70  
71 This object defines the abstract interface for External Database access
72 inside Ensembl. The aim is that one can attach an External Database
73 which will generate Sequence Features and these Sequence Features will
74 be accessible along side all the internal Ensembl sequence features, for
75 drawing, EMBL dumping etc. In particular, the external database does not
76 have to worry about the transformation of the Sequence Feature objects
77 into VirtualContigs.
78  
79 Sequence Features have to be defined in one of two coordinate systems:
80 Original EMBL/GenBank coordinates of a particular sequnence version or
81 the Ensembl contig coordinates. This means you have to calculate your
82 sequence features in one these two coordinate systems
83  
84 The methods that have to be implemented are:
85  
86 get_External_SeqFeatures_contig( $ensembl_contig_identifier,
87 $sequence_version, $start, $end );
88  
89 get_External_SeqFeatures_clone( $embl_accession_number,
90 $sequence_version, $start, $end );
91  
92 The semantics of this method is as follows:
93  
94 $ensembl_contig_identifier - the ensembl contig id (external id).
95 $sequence_version - embl/genbank sequence version
96 $embl_accession_number - the embl/genbank accession number
97  
98 The $start/$end can be ignored, but methods can take advantage of it.
99 This is so that ensembl can ask for features only on a region of DNA,
100 and if desired, the external database can respond with features only in
101 this region, rather than the entire sequence.
102  
103 The hope is that the second method could potentially have a very complex
104 set of mappings of other embl_accession numbers to one embl_accession
105 number and provide the complex mapping.
106  
107 The methods should return Sequence Features with the following spec:
108  
109 a) must implement the Bio::SeqFeatureI interface.
110  
111 b) must accept "set" calls on
112  
113 start,end,strand
114  
115 to provide coordinate transformation of the feature.
116  
117 c) must be unique in-memory objects, ie, the implementation is not
118 allowed to cache the sequence feature in its entirity. Two separate
119 calls to get_External_SeqFeatures_contig must be able to separately
120 set start,end,strand information without clobbering each other. The
121 other information, if so wished, can be cached by each SeqFeature
122 holding onto another object, but this is left to the implementor to
123 decide on the correct strategy.
124  
125 d) must return an unique identifier when called with method id.
126  
127 You must implement both functions. In most cases, one function will
128 always return an empty list, whereas the other function will actually
129 query the external database.
130  
131 The second way of accessing the External Database from Ensembl is using
132 unique internal identifiers in that database. The method is:
133  
134 get_SeqFeature_by_id($id);
135  
136 It should return exactly one Sequence Feature object of the same type as
137 above.
138  
139 =head1 METHODS
140  
141 =cut
142  
143 package Bio::EnsEMBL::DB::ExternalFeatureFactoryI;
144 $Bio::EnsEMBL::DB::ExternalFeatureFactoryI::VERSION = '114.0.0_50'; # TRIAL
145 $Bio::EnsEMBL::DB::ExternalFeatureFactoryI::VERSION = '114.0.050';
146 use strict;
147 use warnings;
148  
149 use Bio::EnsEMBL::External::ExternalFeatureAdaptor;
150 use vars qw(@ISA);
151  
152 @ISA = ( 'Bio::EnsEMBL::External::ExternalFeatureAdaptor' );
153  
154  
155 =head2 coordinate_systems
156  
157 Arg [1] : none
158 Example : none
159 Description: This method is present to make the ExternalFeatureFactory
160 interface behave as an ExternalFeatureAdaptor. It is for
161 backwards compatibility.
162 Returntype : none
163 Exceptions : none
164 Caller : internal
165  
166 =cut
167  
168 sub coordinate_systems {
169 my $self = shift;
170 return qw(CONTIG);
171 }
172  
173  
174 =head2 fetch_all_by_contig_name
175  
176 Arg [1] : none
177 Example : none
178 Description: This method is present to make the ExternalFeatureFactory
179 interface behave as an ExternalFeatureAdaptor. It is for
180 backwards compatibility.
181 Returntype : none
182 Exceptions : none
183 Caller : internal
184  
185 =cut
186  
187 sub fetch_all_by_contig_name {
188 my ($self, $contig_name) = @_;
189  
190 unless($self->db) {
191 $self->throw('DB attribute not set. This value must be set for the ' .
192 'ExternalFeatureFactory to function correctly');
193 }
194  
195 my @features = ();
196  
197 my $ctg = $self->db->get_RawContigAdaptor->fetch_by_name($contig_name);
198 my $clone = $ctg->clone;
199 my $version = $clone->version;
200 my $ctg_length = $ctg->length;
201
202 #get contig features
203 push @features, $self->get_Ensembl_SeqFeatures_contig($ctg->name,
204 $version,
205 1,
206 $ctg_length);
207  
208 #get clone features
209 my $clone_start = $ctg->embl_offset;
210 my $clone_end = $clone_start + $ctg_length - 1;
211 my @clone_features = $self->get_Ensembl_SeqFeatures_clone($clone->id,
212 $version,
213 $clone_start,
214 $clone_end);
215  
216 #change clone coordinates to contig coordinates
217 my ($start, $end);
218 foreach my $f (@clone_features) {
219 $start = $f->start - $clone_start + 1;
220 $end = $f->end - $clone_start + 1;
221  
222 #skip features outside the contig
223 next if($end < 1 || $start > $ctg_length);
224  
225 $f->start($start);
226 $f->end($end);
227  
228 push @features, $f;
229 }
230  
231 return \@features;
232 }
233  
234 =head2 get_Ensembl_SeqFeatures_contig
235  
236 Title : get_Ensembl_SeqFeatures_contig (Abstract)
237 Usage :
238 Function:
239 Example :
240 Returns :
241 Args :
242  
243  
244 =cut
245  
246 sub get_Ensembl_SeqFeatures_contig{
247 my ($self) = @_;
248  
249 $self->warn("Abstract method get_External_SeqFeatures_contig " .
250 "encountered in base class. Implementation failed to complete it");
251  
252 }
253  
254 =head2 get_Ensembl_SeqFeatures_clone
255  
256 Title : get_Ensembl_SeqFeatures_clone (Abstract)
257 Usage :
258 Function:
259 Example :
260 Returns :
261 Args :
262  
263  
264 =cut
265  
266 sub get_Ensembl_SeqFeatures_clone{
267 my ($self) = @_;
268
269 $self->warn("Abstract method get_Ensembl_SeqFeatures_clone " .
270 "encountered in base class. Implementation failed to complete it");
271  
272 }
273  
274 =head2 get_Ensembl_Genes_clone
275  
276 Title : get_Ensembl_Genes_clone
277 Function: returns Gene objects in clone coordinates from a gene id
278 Returns : An array of Gene objects
279 Args : clone id
280  
281 =cut
282  
283 sub get_Ensembl_Genes_clone {
284 my $self = @_;
285  
286 return;
287 }
288  
289 =head2 get_SeqFeature_by_id
290  
291 Title : get_SeqFeature_by_id (Abstract)
292 Usage :
293 Function: Return SeqFeature object for any valid unique id
294 Example :
295 Returns :
296 Args : id as determined by the External Database
297  
298  
299 =cut
300  
301
302 sub get_SeqFeature_by_id {
303 my ($self) = @_;
304 $self->warn("Abstract method get_SeqFeature_by_id encountered " .
305 "in base class. Implementation failed to complete it");
306 }
307  
308  
309 1;
310  
311  
312  
313  
314  
315  
316