EnsEMBL/DBSQL/SeqRegionSynonymAdaptor.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 72 CC 3 SCAR 14.2
CC
3
Cov
0%
store
12.0
get_synonyms
2.0
_tables
2.0
CRAP 4.1
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 INTO
29 =cut
30  
31 package Bio::EnsEMBL::DBSQL::SeqRegionSynonymAdaptor;
32 $Bio::EnsEMBL::DBSQL::SeqRegionSynonymAdaptor::VERSION = '114.0.0';
33 use vars qw(@ISA);
34 use strict;
35  
36  
37 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
38 use Bio::EnsEMBL::Utils::Exception qw(throw);
39 use Bio::EnsEMBL::SeqRegionSynonym;
40  
41 @ISA = ('Bio::EnsEMBL::DBSQL::BaseAdaptor');
42  
43  
44 sub get_synonyms {
45 my ($self, $seq_id) = @_;
46 $self->bind_param_generic_fetch($seq_id, SQL_INTEGER);
47 return $self->generic_fetch(qq{srs.seq_region_id = ?});
48 }
49  
50 sub store {
51 my $self = shift;
52 my $syn = shift;
53  
54 return if($syn->is_stored($self->db));
55  
56 if(!defined($syn->seq_region_id)){
57 throw("seq_region_id is needed to store a seq_region_synoym");
58 }
59  
60 my $insert_ignore = $self->insert_ignore_clause();
61 my $sth = $self->prepare("${insert_ignore} INTO seq_region_synonym (seq_region_id, synonym, external_db_id) VALUES (?, ?, ?)");
62 $sth->bind_param(1, $syn->seq_region_id, SQL_INTEGER);
63 $sth->bind_param(2, $syn->name , SQL_VARCHAR);
64 $sth->bind_param(3, $syn->external_db_id, SQL_INTEGER);
65 $sth->execute;
66 $syn->{'dbID'} = $self->last_insert_id('seq_region_synonym_id', undef, 'seq_region_synonym');
67 $sth->finish;
68 }
69  
70 sub _tables {
71 return (['seq_region_synonym', 'srs'], ['external_db','exdb']);
72 }
73  
74 sub _columns {
75 return qw(srs.seq_region_synonym_id srs.seq_region_id srs.synonym srs.external_db_id exdb.db_name exdb.db_display_name);
76 }
77  
78 sub _left_join{
79 return (['external_db',"exdb.external_db_id = srs.external_db_id"]);
80 }
81  
82 sub _objs_from_sth {
83 my ($self, $sth) = @_;
84  
85 my @results;
86 my ($seq_id, $dbid, $alt_name, $ex_db, $dbname, $db_display_name);
87 $sth->bind_columns(\$dbid, \$seq_id, \$alt_name, \$ex_db, \$dbname, \$db_display_name);
88  
89 push @results, Bio::EnsEMBL::SeqRegionSynonym->new(
90 -adaptor => $self,
91 -synonym => $alt_name,
92 -dbID => $dbid,
93 -external_db_id => $ex_db,
94 -seq_region_id => $seq_id,
95 -dbname => $dbname,
96 -db_display_name => $db_display_name,
97 ) while $sth->fetch();
98  
99 $sth->finish;
100  
101 return \@results;
102 }
103  
104 sub _final_clause {
105 return ' ORDER BY srs.seq_region_synonym_id'
106 }
107  
108 1;