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
38 Abstract
class, should not be instantiated. Implementation of
abstract
39 methods must be performed by subclasses.
43 This is a base adaptor
for the align feature adaptors
50 package Bio::EnsEMBL::DBSQL::BaseAlignFeatureAdaptor;
52 use vars qw(@ISA @EXPORT);
59 @EXPORT = (@{$DBI::EXPORT_TAGS{
'sql_types'}});
61 =head2 fetch_all_by_Slice_and_hcoverage
64 The slice from which to obtain align features.
65 Arg [2] : (optional)
float $hcoverage
66 A lower bound
for the hcoverage of feats to obtain.
67 Arg [3] : (optional)
string $logic_name
68 The logic name of the type of features to obtain.
70 $adaptor->fetch_all_by_Slice_and_hcoverage( $slice,
72 Description: Returns a listref of features created from the
73 database which are on the
Slice $slice and with a
74 hcoverage greater than $hcoverage. If logic name
75 is defined, only features with an analysis of type
76 $logic_name will be returned.
77 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
85 sub fetch_all_by_Slice_and_hcoverage {
86 my ( $self, $slice, $hcoverage, $logic_name ) = @_;
89 if ( defined($hcoverage) ) {
90 $constraint =
"hcoverage > $hcoverage";
94 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
98 =head2 fetch_all_by_Slice_and_external_db
101 The slice from which to obtain align features.
102 Arg [2] : String $external_db_name
103 Name of the external DB to which the align features
104 should be restricted.
105 Arg [3] : (optional)
string $logic_name
106 The logic name of the type of features to obtain.
107 Example : @feats = @{
108 $adaptor->fetch_all_by_Slice_and_external_db( $slice,
110 Description: Returns a listref of features created from the
111 database which are on the
Slice $slice and associated
112 with external DB $external_db_name. If logic name
113 is defined, only features with an analysis of type
114 $logic_name will be returned.
115 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
117 Exceptions : thrown
if $external_db_name is not defined or
if
118 the subclass does not
return a table alias
for the
119 external_db table from _tables()
125 sub fetch_all_by_Slice_and_external_db {
126 my ( $self, $slice, $external_db_name, $logic_name ) = @_;
128 if ( !defined($external_db_name) ) {
129 throw(
"Need name of external DB to restrict to");
132 my @join_tables = $self->_tables();
135 foreach my $join_table (@join_tables) {
136 my ( $table, $table_alias ) = @{$join_table};
137 if ( $table eq
'external_db' ) {
138 $edb_alias = $table_alias;
143 if ( !defined($edb_alias) ) {
144 throw(
"Can not find alias for external_db table");
147 my $constraint = sprintf(
"%s.db_name = %s",
149 $self->dbc()->db_handle()
150 ->quote( $external_db_name, SQL_VARCHAR )
154 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
156 } ## end sub fetch_all_by_Slice_and_external_db
158 =head2 fetch_all_by_Slice_and_pid
161 The slice from which to obtain align features.
162 Arg [2] : (optional)
float $pid
163 A lower bound
for the percentage identity of features
165 Arg [3] : (optional)
string $logic_name
166 The logic name of the type of features to obtain.
168 @{ $adaptor->fetch_all_by_Slice_and_pid( $slice, 50.0 ) };
169 Description: Returns a listref of features created from the
170 database which are on the Slice $slice and with a
171 percentage identity greater than $pid. If logic name
172 is defined, only features with an analysis of type
173 $logic_name will be returned.
174 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
182 sub fetch_all_by_Slice_and_pid {
183 my ( $self, $slice, $pid, $logic_name ) = @_;
185 # #get the primary table alias
186 # my @tabs = $self->_tables;
187 # my $alias = $tabs[0]->[1];
190 # $constraint = "${alias}.perc_ident > $pid";
194 if ( defined($pid) ) {
195 $constraint = sprintf(
"perc_ident > %s",
196 $self->dbc()->db_handle()
197 ->quote( $pid, SQL_FLOAT ) );
201 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
206 =head2 fetch_all_by_hit_name
208 Arg [1] :
string $hit_name
209 The hit_name of the features to obtain
210 Arg [2] : (optional)
string $logic_name
211 The analysis logic name of the type of features to
214 @{ $adaptor->fetch_all_by_hit_name(
'AK078491.1',
216 Description: Returns a listref of features created from the
217 database which correspond to the given hit_name. If
218 logic name is defined, only features with an analysis
219 of type $logic_name will be returned.
220 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
221 Exceptions : thrown
if hit_name is not defined
227 sub fetch_all_by_hit_name {
228 my ( $self, $hit_name, $logic_name ) = @_;
230 if ( !defined($hit_name) ) {
231 throw(
"hit_name argument is required");
234 # Construct a constraint like 't1.hit_name = "123"'
235 my @tabs = $self->_tables();
236 my ( $name, $syn ) = @{ $tabs[0] };
238 my $constraint = sprintf(
"%s.hit_name = %s",
240 $self->dbc()->db_handle()->quote( $hit_name, SQL_VARCHAR ) );
242 if ( defined($logic_name) ) {
243 # Add the $logic_name constraint
245 $self->_logic_name_to_constraint( $constraint, $logic_name );
248 return $self->generic_fetch($constraint);
252 =head2 fetch_all_by_hit_name_unversioned
254 Arg [1] :
string $hit_name
255 The beginning of the hit_name of the features to
256 obtain, e.g. AA768786 would retrieve AA768786.1,
258 Arg [2] : (optional)
string $logic_name
259 The analysis logic name of the type of features to
262 @{ $adaptor->fetch_all_by_hit_name( $name,
264 Description: Returns a listref of features created from the
265 database which start with the given hit_name. If
266 logic name is defined, only features with an analysis
267 of type $logic_name will be returned.
268 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
269 Exceptions : thrown
if hit_name is not defined
275 sub fetch_all_by_hit_name_unversioned {
276 my ( $self, $hit_name, $logic_name ) = @_;
278 if ( !defined($hit_name) ) {
279 throw(
"hit_name argument is required");
281 $hit_name =~ s/_/\\_/;
283 #construct a constraint like 't1.hit_name = "123"'
284 my @tabs = $self->_tables;
285 my ( $name, $syn ) = @{ $tabs[0] };
287 my $constraint = sprintf(
"%s.hit_name LIKE %s",
289 $self->dbc()->db_handle()->quote( $hit_name .
'.%', SQL_VARCHAR ) );
291 if ( defined($logic_name) ) {
292 # Add the $logic_name constraint
294 $self->_logic_name_to_constraint( $constraint, $logic_name );
297 return $self->generic_fetch($constraint);
301 ##implemented by subclasses: