EnsEMBL/DBSQL/BaseAlignFeatureAdaptor.pm untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 90 CC 10 SCAR 23.7
CC
10
Cov
0%
fetch_all_by_Slice_and_external_db
20.0
fetch_all_by_hit_name
12.0
fetch_all_by_hit_name_unversioned
12.0
CRAP 10.7
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::DBSQL::BaseAlignFeatureAdaptor - Abstract Base class for
34 AlignFeatureAdaptors
35  
36 =head1 SYNOPSIS
37  
38 Abstract class, should not be instantiated. Implementation of abstract
39 methods must be performed by subclasses.
40  
41 =head1 DESCRIPTION
42  
43 This is a base adaptor for the align feature adaptors
44 DnaAlignFeatureAdaptor and ProteinAlignFeatureAdaptor.
45  
46 =head1 METHODS
47  
48 =cut
49  
50 package Bio::EnsEMBL::DBSQL::BaseAlignFeatureAdaptor;
51 $Bio::EnsEMBL::DBSQL::BaseAlignFeatureAdaptor::VERSION = '114.0.0';
52 use vars qw(@ISA @EXPORT);
53 use strict;
54  
55 use Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor;
56  
57 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor);
58  
59 @EXPORT = (@{$DBI::EXPORT_TAGS{'sql_types'}});
60  
61 =head2 fetch_all_by_Slice_and_hcoverage
62  
63 Arg [1] : Bio::EnsEMBL::Slice $slice
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.
69 Example : @feats = @{
70 $adaptor->fetch_all_by_Slice_and_hcoverage( $slice,
71 50.0 ) };
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
78 in Slice coordinates
79 Exceptions : none
80 Caller : general
81 Status : At Risk
82  
83 =cut
84  
85 sub fetch_all_by_Slice_and_hcoverage {
86 my ( $self, $slice, $hcoverage, $logic_name ) = @_;
87  
88 my $constraint;
89 if ( defined($hcoverage) ) {
90 $constraint = "hcoverage > $hcoverage";
91 }
92  
93 return
94 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
95 $logic_name );
96 }
97  
98 =head2 fetch_all_by_Slice_and_external_db
99  
100 Arg [1] : Bio::EnsEMBL::Slice $slice
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,
109 'EMBL' ) };
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
116 in Slice coordinates
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()
120 Caller : general
121 Status : At Risk
122  
123 =cut
124  
125 sub fetch_all_by_Slice_and_external_db {
126 my ( $self, $slice, $external_db_name, $logic_name ) = @_;
127  
128 if ( !defined($external_db_name) ) {
129 throw("Need name of external DB to restrict to");
130 }
131  
132 my @join_tables = $self->_tables();
133  
134 my $edb_alias;
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;
139 last;
140 }
141 }
142  
143 if ( !defined($edb_alias) ) {
144 throw("Can not find alias for external_db table");
145 }
146  
147 my $constraint = sprintf( "%s.db_name = %s",
148 $edb_alias,
149 $self->dbc()->db_handle()
150 ->quote( $external_db_name, SQL_VARCHAR )
151 );
152  
153 return
154 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
155 $logic_name );
156 } ## end sub fetch_all_by_Slice_and_external_db
157  
158 =head2 fetch_all_by_Slice_and_pid
159  
160 Arg [1] : Bio::EnsEMBL::Slice $slice
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
164 to obtain.
165 Arg [3] : (optional) string $logic_name
166 The logic name of the type of features to obtain.
167 Example : @feats =
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
175 in Slice coordinates
176 Exceptions : none
177 Caller : general
178 Status : Stable
179  
180 =cut
181  
182 sub fetch_all_by_Slice_and_pid {
183 my ( $self, $slice, $pid, $logic_name ) = @_;
184  
185 # #get the primary table alias
186 # my @tabs = $self->_tables;
187 # my $alias = $tabs[0]->[1];
188  
189 # if(defined $pid) {
190 # $constraint = "${alias}.perc_ident > $pid";
191 # }
192  
193 my $constraint;
194 if ( defined($pid) ) {
195 $constraint = sprintf( "perc_ident > %s",
196 $self->dbc()->db_handle()
197 ->quote( $pid, SQL_FLOAT ) );
198 }
199  
200 return
201 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
202 $logic_name );
203 }
204  
205  
206 =head2 fetch_all_by_hit_name
207  
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
212 obtain.
213 Example : @feats =
214 @{ $adaptor->fetch_all_by_hit_name( 'AK078491.1',
215 'vertrna' ); }
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
222 Caller : general
223 Status : Stable
224  
225 =cut
226  
227 sub fetch_all_by_hit_name {
228 my ( $self, $hit_name, $logic_name ) = @_;
229  
230 if ( !defined($hit_name) ) {
231 throw("hit_name argument is required");
232 }
233  
234 # Construct a constraint like 't1.hit_name = "123"'
235 my @tabs = $self->_tables();
236 my ( $name, $syn ) = @{ $tabs[0] };
237  
238 my $constraint = sprintf( "%s.hit_name = %s",
239 $syn,
240 $self->dbc()->db_handle()->quote( $hit_name, SQL_VARCHAR ) );
241  
242 if ( defined($logic_name) ) {
243 # Add the $logic_name constraint
244 $constraint =
245 $self->_logic_name_to_constraint( $constraint, $logic_name );
246 }
247  
248 return $self->generic_fetch($constraint);
249 }
250  
251  
252 =head2 fetch_all_by_hit_name_unversioned
253  
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,
257 AA768786.2 etc.
258 Arg [2] : (optional) string $logic_name
259 The analysis logic name of the type of features to
260 obtain.
261 Example : @feats =
262 @{ $adaptor->fetch_all_by_hit_name( $name,
263 $logic_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
270 Caller : general
271 Status : At risk
272  
273 =cut
274  
275 sub fetch_all_by_hit_name_unversioned {
276 my ( $self, $hit_name, $logic_name ) = @_;
277  
278 if ( !defined($hit_name) ) {
279 throw("hit_name argument is required");
280 }
281 $hit_name =~ s/_/\\_/;
282  
283 #construct a constraint like 't1.hit_name = "123"'
284 my @tabs = $self->_tables;
285 my ( $name, $syn ) = @{ $tabs[0] };
286  
287 my $constraint = sprintf( "%s.hit_name LIKE %s",
288 $syn,
289 $self->dbc()->db_handle()->quote( $hit_name . '.%', SQL_VARCHAR ) );
290  
291 if ( defined($logic_name) ) {
292 # Add the $logic_name constraint
293 $constraint =
294 $self->_logic_name_to_constraint( $constraint, $logic_name );
295 }
296  
297 return $self->generic_fetch($constraint);
298 }
299  
300  
301 ##implemented by subclasses:
302 # store
303 # _tables
304 # _columns
305 # _obj_from_hashref
306  
307  
308  
309 1;