EnsEMBL/DBSQL/BaseAlignFeatureAdaptor.pm untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 18 Conditioncond n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 91 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_50'; # TRIAL
52 $Bio::EnsEMBL::DBSQL::BaseAlignFeatureAdaptor::VERSION = '114.0.050';
53 use vars qw(@ISA @EXPORT);
54 use strict;
55  
56 use Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor;
57  
58 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor);
59  
60 @EXPORT = (@{$DBI::EXPORT_TAGS{'sql_types'}});
61  
62 =head2 fetch_all_by_Slice_and_hcoverage
63  
64 Arg [1] : Bio::EnsEMBL::Slice $slice
65 The slice from which to obtain align features.
66 Arg [2] : (optional) float $hcoverage
67 A lower bound for the hcoverage of feats to obtain.
68 Arg [3] : (optional) string $logic_name
69 The logic name of the type of features to obtain.
70 Example : @feats = @{
71 $adaptor->fetch_all_by_Slice_and_hcoverage( $slice,
72 50.0 ) };
73 Description: Returns a listref of features created from the
74 database which are on the Slice $slice and with a
75 hcoverage greater than $hcoverage. If logic name
76 is defined, only features with an analysis of type
77 $logic_name will be returned.
78 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
79 in Slice coordinates
80 Exceptions : none
81 Caller : general
82 Status : At Risk
83  
84 =cut
85  
86 sub fetch_all_by_Slice_and_hcoverage {
87 my ( $self, $slice, $hcoverage, $logic_name ) = @_;
88  
89 my $constraint;
90 if ( defined($hcoverage) ) {
91 $constraint = "hcoverage > $hcoverage";
92 }
93  
94 return
95 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
96 $logic_name );
97 }
98  
99 =head2 fetch_all_by_Slice_and_external_db
100  
101 Arg [1] : Bio::EnsEMBL::Slice $slice
102 The slice from which to obtain align features.
103 Arg [2] : String $external_db_name
104 Name of the external DB to which the align features
105 should be restricted.
106 Arg [3] : (optional) string $logic_name
107 The logic name of the type of features to obtain.
108 Example : @feats = @{
109 $adaptor->fetch_all_by_Slice_and_external_db( $slice,
110 'EMBL' ) };
111 Description: Returns a listref of features created from the
112 database which are on the Slice $slice and associated
113 with external DB $external_db_name. If logic name
114 is defined, only features with an analysis of type
115 $logic_name will be returned.
116 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
117 in Slice coordinates
118 Exceptions : thrown if $external_db_name is not defined or if
119 the subclass does not return a table alias for the
120 external_db table from _tables()
121 Caller : general
122 Status : At Risk
123  
124 =cut
125  
126 sub fetch_all_by_Slice_and_external_db {
127 my ( $self, $slice, $external_db_name, $logic_name ) = @_;
128  
129 if ( !defined($external_db_name) ) {
130 throw("Need name of external DB to restrict to");
131 }
132  
133 my @join_tables = $self->_tables();
134  
135 my $edb_alias;
136 foreach my $join_table (@join_tables) {
137 my ( $table, $table_alias ) = @{$join_table};
138 if ( $table eq 'external_db' ) {
139 $edb_alias = $table_alias;
140 last;
141 }
142 }
143  
144 if ( !defined($edb_alias) ) {
145 throw("Can not find alias for external_db table");
146 }
147  
148 my $constraint = sprintf( "%s.db_name = %s",
149 $edb_alias,
150 $self->dbc()->db_handle()
151 ->quote( $external_db_name, SQL_VARCHAR )
152 );
153  
154 return
155 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
156 $logic_name );
157 } ## end sub fetch_all_by_Slice_and_external_db
158  
159 =head2 fetch_all_by_Slice_and_pid
160  
161 Arg [1] : Bio::EnsEMBL::Slice $slice
162 The slice from which to obtain align features.
163 Arg [2] : (optional) float $pid
164 A lower bound for the percentage identity of features
165 to obtain.
166 Arg [3] : (optional) string $logic_name
167 The logic name of the type of features to obtain.
168 Example : @feats =
169 @{ $adaptor->fetch_all_by_Slice_and_pid( $slice, 50.0 ) };
170 Description: Returns a listref of features created from the
171 database which are on the Slice $slice and with a
172 percentage identity greater than $pid. If logic name
173 is defined, only features with an analysis of type
174 $logic_name will be returned.
175 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
176 in Slice coordinates
177 Exceptions : none
178 Caller : general
179 Status : Stable
180  
181 =cut
182  
183 sub fetch_all_by_Slice_and_pid {
184 my ( $self, $slice, $pid, $logic_name ) = @_;
185  
186 # #get the primary table alias
187 # my @tabs = $self->_tables;
188 # my $alias = $tabs[0]->[1];
189  
190 # if(defined $pid) {
191 # $constraint = "${alias}.perc_ident > $pid";
192 # }
193  
194 my $constraint;
195 if ( defined($pid) ) {
196 $constraint = sprintf( "perc_ident > %s",
197 $self->dbc()->db_handle()
198 ->quote( $pid, SQL_FLOAT ) );
199 }
200  
201 return
202 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
203 $logic_name );
204 }
205  
206  
207 =head2 fetch_all_by_hit_name
208  
209 Arg [1] : string $hit_name
210 The hit_name of the features to obtain
211 Arg [2] : (optional) string $logic_name
212 The analysis logic name of the type of features to
213 obtain.
214 Example : @feats =
215 @{ $adaptor->fetch_all_by_hit_name( 'AK078491.1',
216 'vertrna' ); }
217 Description: Returns a listref of features created from the
218 database which correspond to the given hit_name. If
219 logic name is defined, only features with an analysis
220 of type $logic_name will be returned.
221 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
222 Exceptions : thrown if hit_name is not defined
223 Caller : general
224 Status : Stable
225  
226 =cut
227  
228 sub fetch_all_by_hit_name {
229 my ( $self, $hit_name, $logic_name ) = @_;
230  
231 if ( !defined($hit_name) ) {
232 throw("hit_name argument is required");
233 }
234  
235 # Construct a constraint like 't1.hit_name = "123"'
236 my @tabs = $self->_tables();
237 my ( $name, $syn ) = @{ $tabs[0] };
238  
239 my $constraint = sprintf( "%s.hit_name = %s",
240 $syn,
241 $self->dbc()->db_handle()->quote( $hit_name, SQL_VARCHAR ) );
242  
243 if ( defined($logic_name) ) {
244 # Add the $logic_name constraint
245 $constraint =
246 $self->_logic_name_to_constraint( $constraint, $logic_name );
247 }
248  
249 return $self->generic_fetch($constraint);
250 }
251  
252  
253 =head2 fetch_all_by_hit_name_unversioned
254  
255 Arg [1] : string $hit_name
256 The beginning of the hit_name of the features to
257 obtain, e.g. AA768786 would retrieve AA768786.1,
258 AA768786.2 etc.
259 Arg [2] : (optional) string $logic_name
260 The analysis logic name of the type of features to
261 obtain.
262 Example : @feats =
263 @{ $adaptor->fetch_all_by_hit_name( $name,
264 $logic_name ) };
265 Description: Returns a listref of features created from the
266 database which start with the given hit_name. If
267 logic name is defined, only features with an analysis
268 of type $logic_name will be returned.
269 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
270 Exceptions : thrown if hit_name is not defined
271 Caller : general
272 Status : At risk
273  
274 =cut
275  
276 sub fetch_all_by_hit_name_unversioned {
277 my ( $self, $hit_name, $logic_name ) = @_;
278  
279 if ( !defined($hit_name) ) {
280 throw("hit_name argument is required");
281 }
282 $hit_name =~ s/_/\\_/;
283  
284 #construct a constraint like 't1.hit_name = "123"'
285 my @tabs = $self->_tables;
286 my ( $name, $syn ) = @{ $tabs[0] };
287  
288 my $constraint = sprintf( "%s.hit_name LIKE %s",
289 $syn,
290 $self->dbc()->db_handle()->quote( $hit_name . '.%', SQL_VARCHAR ) );
291  
292 if ( defined($logic_name) ) {
293 # Add the $logic_name constraint
294 $constraint =
295 $self->_logic_name_to_constraint( $constraint, $logic_name );
296 }
297  
298 return $self->generic_fetch($constraint);
299 }
300  
301  
302 ##implemented by subclasses:
303 # store
304 # _tables
305 # _columns
306 # _obj_from_hashref
307  
308  
309  
310 1;