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
34 interaction relating to the storage and retrieval of Biotypes
42 This adaptor provides a means to retrieve and store information related
43 to Biotypes. Primarily
this involves the retrieval or storage of
52 package Bio::EnsEMBL::DBSQL::BiotypeAdaptor;
66 Description: PROTECTED implementation of superclass
abstract method.
67 Returns the names, aliases of the tables to use
for queries.
68 Returntype : list of arrays of strings
76 return ([
'biotype',
'b']);
83 Description: PROTECTED implementation of superclass
abstract method.
84 Returns a list of columns to use
for queries.
85 Returntype : list of strings
93 return (
'b.biotype_id',
'b.name',
'b.object_type',
'b.db_type',
'b.attrib_type_id',
'b.description',
'b.biotype_group',
'b.so_acc',
'b.so_term');
100 Description: PROTECTED implementation of
abstract superclass method.
101 responsible
for the creation of ProteinFeatures
108 my ($self, $sth) = @_;
110 my ($dbID, $name, $object_type, $db_type, $attrib_type_id, $description, $biotype_group, $so_acc, $so_term);
112 $sth->bind_columns(\$dbID, \$name, \$object_type, \$db_type, \$attrib_type_id, \$description, \$biotype_group, \$so_acc, \$so_term);
116 while($sth->fetch()) {
121 'object_type' => $object_type,
122 'db_type' => $db_type,
123 'attrib_type_id' => $attrib_type_id,
124 'description' => $description,
125 'biotype_group' => $biotype_group,
127 'so_term' => $so_term,
136 =head2 fetch_by_name_object_type
138 Arg [1] : String $name
139 The name of the biotype to retrieve
140 Arg [2] : String $object_type
141 The
object type of the biotype to retrieve (gene or
transcript)
142 Example : $biotype = $biotype_adaptor->fetch_by_name_object_type(
'mRNA',
'gene');
143 Description: Retrieves a biotype
object from the database via its combined key (name, object_type).
144 If the
Biotype requested does not exist in the database, a
new Biotype object is
145 created with the provided name and object_type to be returned.
151 sub fetch_by_name_object_type {
152 my ($self, $name, $object_type) = @_;
156 # biotype table implemented on schema_version 93
157 if ($self->schema_version > 92) {
158 my $constraint =
"b.name = ? AND b.object_type = ?";
159 $self->bind_param_generic_fetch($name, SQL_VARCHAR);
160 $self->bind_param_generic_fetch($object_type, SQL_VARCHAR);
161 $biotype = shift @{$self->generic_fetch($constraint)};
164 # If request biotype does not exist in the table
165 # create a new biotype object containing name and object_type only
166 # this is required by genebuild in pipelines
167 if (!defined $biotype) {
170 -OBJECT_TYPE => $object_type,
177 =head2 fetch_all_by_object_type
179 Arg [1] : String $object_type
180 The object_type of the biotypes to retrieve (gene or
transcript).
181 Example : $biotypes = $biotype_adaptor->fetch_all_by_object_type(
'gene');
182 Description: Retrieves an array reference of biotype objects from the database.
184 Warning : If empty arrayref is to be returned
189 sub fetch_all_by_object_type {
190 my ($self, $object_type) = @_;
192 my $constraint =
"b.object_type = ?";
193 $self->bind_param_generic_fetch($object_type, SQL_VARCHAR);
194 my @biotypes = @{$self->generic_fetch($constraint)};
197 warning(
"No objects retrieved. Check if object_type '$object_type' is correct.")
203 =head2 fetch_all_by_name
205 Arg [1] : String $name
206 The name of the biotype to retrieve
207 Arg [2] : (optional) String $object_type
208 The object_type of the biotypes to retrieve (gene or
transcript).
209 Example : $biotypes = $biotype_adaptor->fetch_all_by_name(
'lincRNA');
210 Description: Retrieves an array reference of biotype objects from the database.
212 Warning : If empty arrayref is to be returned
217 sub fetch_all_by_name{
218 my ($self, $name, $object_type) = @_;
220 my $constraint =
"b.name = ?";
221 $self->bind_param_generic_fetch($name, SQL_VARCHAR);
222 if (defined $object_type) {
223 $constraint .=
"AND b.object_type = ?";
224 $self->bind_param_generic_fetch($object_type, SQL_VARCHAR);
226 my @biotypes = @{$self->generic_fetch($constraint)};
229 warning(
"No objects retrieved. Check if name '$name' is correct.")
235 =head2 fetch_all_by_group_object_db_type
237 Arg [1] : String $biotype_group
238 The group of the biotypes to retrieve
239 Arg [2] : String $object_type
240 The
object type of the biotypes to retrieve (gene or
transcript)
241 Arg [3] : (optional) String $db_type
242 The db_type of the biotypes to retrieve. If not provided defaults to
'core'.
243 Example : $biotype = $biotype_adaptor->fetch_all_by_group_object_db_type(
'coding',
'gene');
244 Description: Retrieves an array reference of biotype objects from the database of the provided
245 biotype_group and object_type and core db_type.
247 Warning : If empty arrayref is to be returned
252 sub fetch_all_by_group_object_db_type {
253 my ($self, $biotype_group, $object_type, $db_type) = @_;
256 $db_type =
'%' . $db_type .
'%';
258 my $constraint =
"b.biotype_group = ? AND b.db_type LIKE ? ";
259 $self->bind_param_generic_fetch($biotype_group, SQL_VARCHAR);
260 $self->bind_param_generic_fetch($db_type, SQL_VARCHAR);
261 if (defined $object_type) {
262 $constraint .=
" AND b.object_type = ?";
263 $self->bind_param_generic_fetch($object_type, SQL_VARCHAR);
265 my @biotypes = @{$self->generic_fetch($constraint)};
268 warning(
"No objects retrieved. Check if object_type '$object_type' is correct.")