3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
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
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.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
34 Legacy Abstract
interface for External
Feature
40 $external_ff = new ImplementingExternalFeatureFactoryClass;
48 # alternatively, you can add external databases to an obj once made
49 $database_adaptor->add_ExternalFeatureFactory($external_ff);
51 # now the ExternalFeatureFactory has been added, Ensembl RawContigs
52 # and Slices will now have ExternalFeatures on them
54 $db_adaptor->get_RawContigAdaptor->fetch_by_name('AC00056.00001');
55 @external = @{ $contig->get_all_ExternalFeatures() };
57 # this works on Slices as well
59 $db_adaptor->get_SliceAdaptor->fetch_by_chr_start_end(
'12', 10000,
61 @external = @{ $slice->get_all_ExternalFeatures() };
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
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
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
84 The methods that have to be implemented are:
86 get_External_SeqFeatures_contig( $ensembl_contig_identifier,
87 $sequence_version, $start, $end );
89 get_External_SeqFeatures_clone( $embl_accession_number,
90 $sequence_version, $start, $end );
92 The semantics of this method is as follows:
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
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.
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.
107 The methods should return Sequence Features with the following spec:
109 a) must implement the Bio::SeqFeatureI interface.
111 b) must accept "set" calls on
115 to provide coordinate transformation of the feature.
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.
125 d) must return an unique identifier when called with method id.
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.
131 The second way of accessing the External Database from Ensembl is using
132 unique internal identifiers in that database. The method is:
134 get_SeqFeature_by_id($id);
136 It should return exactly one Sequence
Feature object of the same type as
151 @ISA = (
'Bio::EnsEMBL::External::ExternalFeatureAdaptor' );
154 =head2 coordinate_systems
158 Description: This method is present to make the ExternalFeatureFactory
159 interface behave as an ExternalFeatureAdaptor. It is for
160 backwards compatibility.
167 sub coordinate_systems {
173 =head2 fetch_all_by_contig_name
177 Description: This method is present to make the ExternalFeatureFactory
178 interface behave as an ExternalFeatureAdaptor. It is for
179 backwards compatibility.
186 sub fetch_all_by_contig_name {
187 my ($self, $contig_name) = @_;
190 $self->throw(
'DB attribute not set. This value must be set for the ' .
191 'ExternalFeatureFactory to function correctly');
196 my $ctg = $self->db->get_RawContigAdaptor->fetch_by_name($contig_name);
197 my $clone = $ctg->clone;
198 my $version = $clone->version;
199 my $ctg_length = $ctg->length;
202 push @features, $self->get_Ensembl_SeqFeatures_contig($ctg->name,
208 my $clone_start = $ctg->embl_offset;
209 my $clone_end = $clone_start + $ctg_length - 1;
210 my @clone_features = $self->get_Ensembl_SeqFeatures_clone($clone->id,
215 #change clone coordinates to contig coordinates
217 foreach my $f (@clone_features) {
218 $start = $f->start - $clone_start + 1;
219 $end = $f->end - $clone_start + 1;
221 #skip features outside the contig
222 next
if($end < 1 || $start > $ctg_length);
233 =head2 get_Ensembl_SeqFeatures_contig
245 sub get_Ensembl_SeqFeatures_contig{
248 $self->warn(
"Abstract method get_External_SeqFeatures_contig " .
249 "encountered in base class. Implementation failed to complete it");
253 =head2 get_Ensembl_SeqFeatures_clone
265 sub get_Ensembl_SeqFeatures_clone{
268 $self->warn(
"Abstract method get_Ensembl_SeqFeatures_clone " .
269 "encountered in base class. Implementation failed to complete it");
273 =head2 get_Ensembl_Genes_clone
275 Title : get_Ensembl_Genes_clone
276 Function: returns
Gene objects in clone coordinates from a gene
id
277 Returns : An array of
Gene objects
282 sub get_Ensembl_Genes_clone {
288 =head2 get_SeqFeature_by_id
292 Function: Return
SeqFeature object for any valid unique
id
295 Args :
id as determined by the External Database
301 sub get_SeqFeature_by_id {
303 $self->warn(
"Abstract method get_SeqFeature_by_id encountered " .
304 "in base class. Implementation failed to complete it");