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
37 $rca = $database_adaptor->get_RepeatConsensusAdaptor();
40 $repeat_consensus = $rca->fetch_by_name_class(
'AluSx',
'SINE/Alu' );
42 $rca->store( $rc1, $rc2, $rc3 );
53 package Bio::EnsEMBL::DBSQL::RepeatConsensusAdaptor;
63 =head2 fetch_all_repeat_types
65 Example : my $types = $rca->fetch_all_repeat_types();
66 Description : Returns the distinct repeat types available from a database
73 sub fetch_all_repeat_types {
75 return $self->dbc()->sql_helper()->execute_simple(
76 -SQL =>
'SELECT DISTINCT repeat_type FROM repeat_consensus');
84 Example : $repeat_consensus = $repeat_consensus_adaptor->fetch_by_dbID(4);
89 Caller : general, Bio::EnsEMBL::RepeatFeatureAdaptor
95 my( $self, $db_id ) = @_;
97 my ($rc) = @{$self->_generic_fetch(
"repeat_consensus_id = $db_id")};
106 Arg [1] :
string $name
107 the name of the repeat consensus to obtain
108 Example : $rc = $repeat_consensus_adaptor->fetch_by_name(
'AluSx');
109 Description: Obtains a repeat consensus from the database via its name
118 my( $self, $name ) = @_;
120 my ($rc) = @{$self->_generic_fetch(
"repeat_name = '$name'")};
126 =head2 fetch_by_name_class
128 Arg [1] :
string $name
129 the name of the repeat consensus to obtain
130 Arg [2] :
string $class
131 the
class of the repeat consensus to obtain
132 Example : $rc = $repeat_consensus_adaptor->
133 fetch_by_name_class('AluSx', 'SINE/Alu');
134 Description: Obtains a repeat consensus from the database
135 via its name and class
143 sub fetch_by_name_class {
144 my( $self, $name, $class ) = @_;
147 my ($rc) = @{$self->_generic_fetch(qq{
148 repeat_name =
'$name'
149 AND repeat_class =
'$class'
156 =head2 fetch_all_by_class_seq
158 Arg [1] :
string $class
159 the
class of the repeat consensus to obtain
160 Arg [2] : string $seq
161 the sequence of the repeat consensus to obtain
162 Example : $rc = $repeat_consensus_adaptor->
163 fetch_all_by_class_seq('trf', 'ATGGTGTCA');
164 Description: Obtains a repeat consensus from the database
165 via its class and sequence
173 sub fetch_all_by_class_seq {
174 my( $self, $class, $seq ) = @_;
176 return $self->_generic_fetch(qq{
177 repeat_class =
'$class'
178 AND repeat_consensus =
'$seq'
183 =head2 _generic_fetch
185 Arg [1] :
string $where_clause
197 my( $self, $where_clause ) = @_;
199 my( $repeat_consensus_id, $repeat_name, $repeat_class,$repeat_length,
200 $repeat_consensus, $repeat_type );
202 my $sth = $self->prepare(qq{
203 SELECT repeat_consensus_id
208 FROM repeat_consensus
209 WHERE }. $where_clause);
213 \$repeat_consensus_id,
222 while ($sth->fetch) {
223 if ($repeat_consensus =~ /^(\d+)\(N\)$/) {
226 $repeat_length = CORE::length($repeat_consensus);
230 (-DBID => $repeat_consensus_id,
231 -NAME => $repeat_name,
232 -REPEAT_CLASS => $repeat_class,
233 -REPEAT_TYPE => $repeat_type,
234 -LENGTH => $repeat_length,
236 -REPEAT_CONSENSUS => $repeat_consensus);
245 Example : $repeat_consensus_adaptor->store(@consensi);
255 my( $self, @consensi ) = @_;
257 my $sth = $self->prepare(q{
258 INSERT into repeat_consensus( repeat_consensus_id
263 VALUES (NULL, ?,?,?,?)
266 foreach my $rc (@consensi) {
268 or
throw(
"name not set");
269 my $class = $rc->repeat_class
270 or
throw(
"repeat_class not set");
271 my $type = $rc->repeat_type();
272 $type =
"" unless defined $type;
273 my $seq = $rc->repeat_consensus
274 or
throw(
"repeat_consensus not set");
276 $sth->bind_param(1,$name,SQL_VARCHAR);
277 $sth->bind_param(2,$class,SQL_VARCHAR);
278 $sth->bind_param(3,$type,SQL_VARCHAR);
279 $sth->bind_param(4,$seq,SQL_LONGVARCHAR);
283 my $db_id = $self->last_insert_id(
'repeat_consensus_id', undef,
'repeat_consensus')
284 or
throw(
"Didn't get an insertid from the INSERT statement");