0
|
1 =head1 LICENSE
|
|
2
|
|
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and
|
|
4 Genome Research Limited. All rights reserved.
|
|
5
|
|
6 This software is distributed under a modified Apache license.
|
|
7 For license details, please see
|
|
8
|
|
9 http://www.ensembl.org/info/about/code_licence.html
|
|
10
|
|
11 =head1 CONTACT
|
|
12
|
|
13 Please email comments or questions to the public Ensembl
|
|
14 developers list at <dev@ensembl.org>.
|
|
15
|
|
16 Questions may also be sent to the Ensembl help desk at
|
|
17 <helpdesk@ensembl.org>.
|
|
18
|
|
19 =cut
|
|
20
|
|
21 =head1 NAME
|
|
22
|
|
23 Bio::EnsEMBL::DBSQL::BaseAlignFeatureAdaptor - Abstract Base class for
|
|
24 AlignFeatureAdaptors
|
|
25
|
|
26 =head1 SYNOPSIS
|
|
27
|
|
28 Abstract class, should not be instantiated. Implementation of abstract
|
|
29 methods must be performed by subclasses.
|
|
30
|
|
31 =head1 DESCRIPTION
|
|
32
|
|
33 This is a base adaptor for the align feature adaptors
|
|
34 DnaAlignFeatureAdaptor and ProteinAlignFeatureAdaptor.
|
|
35
|
|
36 =head1 METHODS
|
|
37
|
|
38 =cut
|
|
39
|
|
40 package Bio::EnsEMBL::DBSQL::BaseAlignFeatureAdaptor;
|
|
41 use vars qw(@ISA @EXPORT);
|
|
42 use strict;
|
|
43
|
|
44 use Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor;
|
|
45
|
|
46 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor);
|
|
47
|
|
48 @EXPORT = (@{$DBI::EXPORT_TAGS{'sql_types'}});
|
|
49
|
|
50 =head2 fetch_all_by_Slice_and_hcoverage
|
|
51
|
|
52 Arg [1] : Bio::EnsEMBL::Slice $slice
|
|
53 The slice from which to obtain align features.
|
|
54 Arg [2] : (optional) float $hcoverage
|
|
55 A lower bound for the hcoverage of feats to obtain.
|
|
56 Arg [3] : (optional) string $logic_name
|
|
57 The logic name of the type of features to obtain.
|
|
58 Example : @feats = @{
|
|
59 $adaptor->fetch_all_by_Slice_and_hcoverage( $slice,
|
|
60 50.0 ) };
|
|
61 Description: Returns a listref of features created from the
|
|
62 database which are on the Slice $slice and with a
|
|
63 hcoverage greater than $hcoverage. If logic name
|
|
64 is defined, only features with an analysis of type
|
|
65 $logic_name will be returned.
|
|
66 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
|
|
67 in Slice coordinates
|
|
68 Exceptions : none
|
|
69 Caller : general
|
|
70 Status : At Risk
|
|
71
|
|
72 =cut
|
|
73
|
|
74 sub fetch_all_by_Slice_and_hcoverage {
|
|
75 my ( $self, $slice, $hcoverage, $logic_name ) = @_;
|
|
76
|
|
77 my $constraint;
|
|
78 if ( defined($hcoverage) ) {
|
|
79 $constraint = "hcoverage > $hcoverage";
|
|
80 }
|
|
81
|
|
82 return
|
|
83 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
|
|
84 $logic_name );
|
|
85 }
|
|
86
|
|
87 =head2 fetch_all_by_Slice_and_external_db
|
|
88
|
|
89 Arg [1] : Bio::EnsEMBL::Slice $slice
|
|
90 The slice from which to obtain align features.
|
|
91 Arg [2] : String $external_db_name
|
|
92 Name of the external DB to which the align features
|
|
93 should be restricted.
|
|
94 Arg [3] : (optional) string $logic_name
|
|
95 The logic name of the type of features to obtain.
|
|
96 Example : @feats = @{
|
|
97 $adaptor->fetch_all_by_Slice_and_external_db( $slice,
|
|
98 'EMBL' ) };
|
|
99 Description: Returns a listref of features created from the
|
|
100 database which are on the Slice $slice and associated
|
|
101 with external DB $external_db_name. If logic name
|
|
102 is defined, only features with an analysis of type
|
|
103 $logic_name will be returned.
|
|
104 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
|
|
105 in Slice coordinates
|
|
106 Exceptions : thrown if $external_db_name is not defined or if
|
|
107 the subclass does not return a table alias for the
|
|
108 external_db table from _tables()
|
|
109 Caller : general
|
|
110 Status : At Risk
|
|
111
|
|
112 =cut
|
|
113
|
|
114 sub fetch_all_by_Slice_and_external_db {
|
|
115 my ( $self, $slice, $external_db_name, $logic_name ) = @_;
|
|
116
|
|
117 if ( !defined($external_db_name) ) {
|
|
118 throw("Need name of external DB to restrict to");
|
|
119 }
|
|
120
|
|
121 my @join_tables = $self->_tables();
|
|
122
|
|
123 my $edb_alias;
|
|
124 foreach my $join_table (@join_tables) {
|
|
125 my ( $table, $table_alias ) = @{$join_table};
|
|
126 if ( $table eq 'external_db' ) {
|
|
127 $edb_alias = $table_alias;
|
|
128 last;
|
|
129 }
|
|
130 }
|
|
131
|
|
132 if ( !defined($edb_alias) ) {
|
|
133 throw("Can not find alias for external_db table");
|
|
134 }
|
|
135
|
|
136 my $constraint = sprintf( "%s.db_name = %s",
|
|
137 $edb_alias,
|
|
138 $self->dbc()->db_handle()
|
|
139 ->quote( $external_db_name, SQL_VARCHAR )
|
|
140 );
|
|
141
|
|
142 return
|
|
143 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
|
|
144 $logic_name );
|
|
145 } ## end sub fetch_all_by_Slice_and_external_db
|
|
146
|
|
147 =head2 fetch_all_by_Slice_and_pid
|
|
148
|
|
149 Arg [1] : Bio::EnsEMBL::Slice $slice
|
|
150 The slice from which to obtain align features.
|
|
151 Arg [2] : (optional) float $pid
|
|
152 A lower bound for the percentage identity of features
|
|
153 to obtain.
|
|
154 Arg [3] : (optional) string $logic_name
|
|
155 The logic name of the type of features to obtain.
|
|
156 Example : @feats =
|
|
157 @{ $adaptor->fetch_all_by_Slice_and_pid( $slice, 50.0 ) };
|
|
158 Description: Returns a listref of features created from the
|
|
159 database which are on the Slice $slice and with a
|
|
160 percentage identity greater than $pid. If logic name
|
|
161 is defined, only features with an analysis of type
|
|
162 $logic_name will be returned.
|
|
163 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
|
|
164 in Slice coordinates
|
|
165 Exceptions : none
|
|
166 Caller : general
|
|
167 Status : Stable
|
|
168
|
|
169 =cut
|
|
170
|
|
171 sub fetch_all_by_Slice_and_pid {
|
|
172 my ( $self, $slice, $pid, $logic_name ) = @_;
|
|
173
|
|
174 # #get the primary table alias
|
|
175 # my @tabs = $self->_tables;
|
|
176 # my $alias = $tabs[0]->[1];
|
|
177
|
|
178 # if(defined $pid) {
|
|
179 # $constraint = "${alias}.perc_ident > $pid";
|
|
180 # }
|
|
181
|
|
182 my $constraint;
|
|
183 if ( defined($pid) ) {
|
|
184 $constraint = sprintf( "perc_ident > %s",
|
|
185 $self->dbc()->db_handle()
|
|
186 ->quote( $pid, SQL_FLOAT ) );
|
|
187 }
|
|
188
|
|
189 return
|
|
190 $self->fetch_all_by_Slice_constraint( $slice, $constraint,
|
|
191 $logic_name );
|
|
192 }
|
|
193
|
|
194
|
|
195 =head2 fetch_all_by_hit_name
|
|
196
|
|
197 Arg [1] : string $hit_name
|
|
198 The hit_name of the features to obtain
|
|
199 Arg [2] : (optional) string $logic_name
|
|
200 The analysis logic name of the type of features to
|
|
201 obtain.
|
|
202 Example : @feats =
|
|
203 @{ $adaptor->fetch_all_by_hit_name( $name,
|
|
204 $logic_name ); }
|
|
205 Description: Returns a listref of features created from the
|
|
206 database which correspond to the given hit_name. If
|
|
207 logic name is defined, only features with an analysis
|
|
208 of type $logic_name will be returned.
|
|
209 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
|
|
210 Exceptions : thrown if hit_name is not defined
|
|
211 Caller : general
|
|
212 Status : Stable
|
|
213
|
|
214 =cut
|
|
215
|
|
216 sub fetch_all_by_hit_name {
|
|
217 my ( $self, $hit_name, $logic_name ) = @_;
|
|
218
|
|
219 if ( !defined($hit_name) ) {
|
|
220 throw("hit_name argument is required");
|
|
221 }
|
|
222
|
|
223 # Construct a constraint like 't1.hit_name = "123"'
|
|
224 my @tabs = $self->_tables();
|
|
225 my ( $name, $syn ) = @{ $tabs[0] };
|
|
226
|
|
227 my $constraint = sprintf( "%s.hit_name = %s",
|
|
228 $syn,
|
|
229 $self->dbc()->db_handle()->quote( $hit_name, SQL_VARCHAR ) );
|
|
230
|
|
231 if ( defined($logic_name) ) {
|
|
232 # Add the $logic_name constraint
|
|
233 $constraint =
|
|
234 $self->_logic_name_to_constraint( $constraint, $logic_name );
|
|
235 }
|
|
236
|
|
237 return $self->generic_fetch($constraint);
|
|
238 }
|
|
239
|
|
240
|
|
241 =head2 fetch_all_by_hit_name_unversioned
|
|
242
|
|
243 Arg [1] : string $hit_name
|
|
244 The beginning of the hit_name of the features to
|
|
245 obtain, e.g. AA768786 would retrieve AA768786.1,
|
|
246 AA768786.2 etc.
|
|
247 Arg [2] : (optional) string $logic_name
|
|
248 The analysis logic name of the type of features to
|
|
249 obtain.
|
|
250 Example : @feats =
|
|
251 @{ $adaptor->fetch_all_by_hit_name( $name,
|
|
252 $logic_name ) };
|
|
253 Description: Returns a listref of features created from the
|
|
254 database which start with the given hit_name. If
|
|
255 logic name is defined, only features with an analysis
|
|
256 of type $logic_name will be returned.
|
|
257 Returntype : listref of Bio::EnsEMBL::BaseAlignFeatures
|
|
258 Exceptions : thrown if hit_name is not defined
|
|
259 Caller : general
|
|
260 Status : At risk
|
|
261
|
|
262 =cut
|
|
263
|
|
264 sub fetch_all_by_hit_name_unversioned {
|
|
265 my ( $self, $hit_name, $logic_name ) = @_;
|
|
266
|
|
267 if ( !defined($hit_name) ) {
|
|
268 throw("hit_name argument is required");
|
|
269 }
|
|
270 $hit_name =~ s/_/\\_/;
|
|
271
|
|
272 #construct a constraint like 't1.hit_name = "123"'
|
|
273 my @tabs = $self->_tables;
|
|
274 my ( $name, $syn ) = @{ $tabs[0] };
|
|
275
|
|
276 my $constraint = sprintf( "%s.hit_name LIKE %s",
|
|
277 $syn,
|
|
278 $self->dbc()->db_handle()->quote( $hit_name . '.%', SQL_VARCHAR ) );
|
|
279
|
|
280 if ( defined($logic_name) ) {
|
|
281 # Add the $logic_name constraint
|
|
282 $constraint =
|
|
283 $self->_logic_name_to_constraint( $constraint, $logic_name );
|
|
284 }
|
|
285
|
|
286 return $self->generic_fetch($constraint);
|
|
287 }
|
|
288
|
|
289
|
|
290
|
|
291 =head2 fetch_all_by_RawContig_and_pid
|
|
292
|
|
293 Description: DEPRECATED use fetch_all_by_Slice_and_pid instead
|
|
294
|
|
295 =cut
|
|
296
|
|
297 sub fetch_all_by_RawContig_and_pid {
|
|
298 my($self, $contig, $pid, $logic_name) = @_;
|
|
299
|
|
300 my $constraint;
|
|
301
|
|
302 #get the primary table alias
|
|
303 my @tabs = $self->_tables;
|
|
304 my $alias = $tabs[0]->[1];
|
|
305
|
|
306 if(defined $pid) {
|
|
307 $constraint = "${alias}.perc_ident > $pid";
|
|
308 }
|
|
309
|
|
310 return $self->fetch_all_by_RawContig_constraint($contig,
|
|
311 $constraint,
|
|
312 $logic_name);
|
|
313 }
|
|
314
|
|
315
|
|
316
|
|
317
|
|
318 ##implemented by subclasses:
|
|
319 # store
|
|
320 # _tables
|
|
321 # _columns
|
|
322 # _obj_from_hashref
|
|
323
|
|
324
|
|
325
|
|
326 1;
|