EnsEMBL/DBSQL/SeqRegionSynonymAdaptor.pm untested

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