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;
51 use vars qw(@ISA @EXPORT);
58 @EXPORT = (@{$DBI::EXPORT_TAGS{
'sql_types'}});
60 =head2 fetch_all_by_Slice_and_hcoverage
63 The slice from which to obtain align features.
64 Arg [2] : (optional)
float $hcoverage
65 A lower bound
for the hcoverage of feats to obtain.
66 Arg [3] : (optional)
string $logic_name
67 The logic name of the type of features to obtain.
69 $adaptor->fetch_all_by_Slice_and_hcoverage( $slice,
71 Description: Returns a listref of features created from the
72 database which are on the
Slice $slice and with a
73 hcoverage greater than $hcoverage. If logic name
74 is defined, only features with an analysis of type
75 $logic_name will be returned.
76 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
84 sub fetch_all_by_Slice_and_hcoverage {
85 my ( $self, $slice, $hcoverage, $logic_name ) = @_;
88 if ( defined($hcoverage) ) {
89 $constraint =
"hcoverage > $hcoverage";
93 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
97 =head2 fetch_all_by_Slice_and_external_db
100 The slice from which to obtain align features.
101 Arg [2] : String $external_db_name
102 Name of the external DB to which the align features
103 should be restricted.
104 Arg [3] : (optional)
string $logic_name
105 The logic name of the type of features to obtain.
106 Example : @feats = @{
107 $adaptor->fetch_all_by_Slice_and_external_db( $slice,
109 Description: Returns a listref of features created from the
110 database which are on the
Slice $slice and associated
111 with external DB $external_db_name. If logic name
112 is defined, only features with an analysis of type
113 $logic_name will be returned.
114 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
116 Exceptions : thrown
if $external_db_name is not defined or
if
117 the subclass does not
return a table alias
for the
118 external_db table from _tables()
124 sub fetch_all_by_Slice_and_external_db {
125 my ( $self, $slice, $external_db_name, $logic_name ) = @_;
127 if ( !defined($external_db_name) ) {
128 throw(
"Need name of external DB to restrict to");
131 my @join_tables = $self->_tables();
134 foreach my $join_table (@join_tables) {
135 my ( $table, $table_alias ) = @{$join_table};
136 if ( $table eq
'external_db' ) {
137 $edb_alias = $table_alias;
142 if ( !defined($edb_alias) ) {
143 throw(
"Can not find alias for external_db table");
146 my $constraint = sprintf(
"%s.db_name = %s",
148 $self->dbc()->db_handle()
149 ->quote( $external_db_name, SQL_VARCHAR )
153 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
155 } ## end sub fetch_all_by_Slice_and_external_db
157 =head2 fetch_all_by_Slice_and_pid
160 The slice from which to obtain align features.
161 Arg [2] : (optional)
float $pid
162 A lower bound
for the percentage identity of features
164 Arg [3] : (optional)
string $logic_name
165 The logic name of the type of features to obtain.
167 @{ $adaptor->fetch_all_by_Slice_and_pid( $slice, 50.0 ) };
168 Description: Returns a listref of features created from the
169 database which are on the Slice $slice and with a
170 percentage identity greater than $pid. If logic name
171 is defined, only features with an analysis of type
172 $logic_name will be returned.
173 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
181 sub fetch_all_by_Slice_and_pid {
182 my ( $self, $slice, $pid, $logic_name ) = @_;
184 # #get the primary table alias
185 # my @tabs = $self->_tables;
186 # my $alias = $tabs[0]->[1];
189 # $constraint = "${alias}.perc_ident > $pid";
193 if ( defined($pid) ) {
194 $constraint = sprintf(
"perc_ident > %s",
195 $self->dbc()->db_handle()
196 ->quote( $pid, SQL_FLOAT ) );
200 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
205 =head2 fetch_all_by_hit_name
207 Arg [1] :
string $hit_name
208 The hit_name of the features to obtain
209 Arg [2] : (optional)
string $logic_name
210 The analysis logic name of the type of features to
213 @{ $adaptor->fetch_all_by_hit_name(
'AK078491.1',
215 Description: Returns a listref of features created from the
216 database which correspond to the given hit_name. If
217 logic name is defined, only features with an analysis
218 of type $logic_name will be returned.
219 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
220 Exceptions : thrown
if hit_name is not defined
226 sub fetch_all_by_hit_name {
227 my ( $self, $hit_name, $logic_name ) = @_;
229 if ( !defined($hit_name) ) {
230 throw(
"hit_name argument is required");
233 # Construct a constraint like 't1.hit_name = "123"'
234 my @tabs = $self->_tables();
235 my ( $name, $syn ) = @{ $tabs[0] };
237 my $constraint = sprintf(
"%s.hit_name = %s",
239 $self->dbc()->db_handle()->quote( $hit_name, SQL_VARCHAR ) );
241 if ( defined($logic_name) ) {
242 # Add the $logic_name constraint
244 $self->_logic_name_to_constraint( $constraint, $logic_name );
247 return $self->generic_fetch($constraint);
251 =head2 fetch_all_by_hit_name_unversioned
253 Arg [1] :
string $hit_name
254 The beginning of the hit_name of the features to
255 obtain, e.g. AA768786 would retrieve AA768786.1,
257 Arg [2] : (optional)
string $logic_name
258 The analysis logic name of the type of features to
261 @{ $adaptor->fetch_all_by_hit_name( $name,
263 Description: Returns a listref of features created from the
264 database which start with the given hit_name. If
265 logic name is defined, only features with an analysis
266 of type $logic_name will be returned.
267 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
268 Exceptions : thrown
if hit_name is not defined
274 sub fetch_all_by_hit_name_unversioned {
275 my ( $self, $hit_name, $logic_name ) = @_;
277 if ( !defined($hit_name) ) {
278 throw(
"hit_name argument is required");
280 $hit_name =~ s/_/\\_/;
282 #construct a constraint like 't1.hit_name = "123"'
283 my @tabs = $self->_tables;
284 my ( $name, $syn ) = @{ $tabs[0] };
286 my $constraint = sprintf(
"%s.hit_name LIKE %s",
288 $self->dbc()->db_handle()->quote( $hit_name .
'.%', SQL_VARCHAR ) );
290 if ( defined($logic_name) ) {
291 # Add the $logic_name constraint
293 $self->_logic_name_to_constraint( $constraint, $logic_name );
296 return $self->generic_fetch($constraint);
300 ##implemented by subclasses: