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 INTO
|
|
19 =cut
|
|
20
|
|
21 package Bio::EnsEMBL::DBSQL::SeqRegionSynonymAdaptor;
|
|
22 use vars qw(@ISA);
|
|
23 use strict;
|
|
24
|
|
25
|
|
26 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
|
|
27 use Bio::EnsEMBL::Utils::Exception qw(throw deprecate warning stack_trace_dump);
|
|
28 use Bio::EnsEMBL::SeqRegionSynonym;
|
|
29
|
|
30 @ISA = ('Bio::EnsEMBL::DBSQL::BaseAdaptor');
|
|
31
|
|
32
|
|
33 sub get_synonyms{
|
|
34 my $self = shift;
|
|
35 my $seq_id = shift;
|
|
36
|
|
37 my @results;
|
|
38
|
|
39 my $sth = $self->prepare("select seq_region_synonym_id, synonym, external_db_id from seq_region_synonym where seq_region_id = ?");
|
|
40 $sth->bind_param(1, $seq_id, SQL_INTEGER);
|
|
41 $sth->execute();
|
|
42 my $dbid;
|
|
43 my $alt_name;
|
|
44 my $ex_db;
|
|
45 $sth->bind_columns(\$dbid, \$alt_name, \$ex_db);
|
|
46 while($sth->fetch()){
|
|
47 push @results, Bio::EnsEMBL::SeqRegionSynonym->new(-adaptor => $self,
|
|
48 -synonym => $alt_name,
|
|
49 -dbID => $dbid,
|
|
50 -external_db_id => $ex_db,
|
|
51 -seq_region_id => $seq_id);
|
|
52 }
|
|
53 $sth->finish;
|
|
54
|
|
55 return \@results;
|
|
56 }
|
|
57
|
|
58 sub store {
|
|
59 my $self = shift;
|
|
60 my $syn = shift;
|
|
61
|
|
62 return if($syn->is_stored($self->db));
|
|
63
|
|
64 if(!defined($syn->seq_region_id)){
|
|
65 throw("seq_region_id is needed to store a seq_region_synoym");
|
|
66 }
|
|
67
|
|
68 my $sth = $self->prepare("INSERT IGNORE INTO seq_region_synonym (seq_region_id, synonym, external_db_id) VALUES (?, ?, ?)");
|
|
69 $sth->bind_param(1, $syn->seq_region_id, SQL_INTEGER);
|
|
70 $sth->bind_param(2, $syn->name , SQL_VARCHAR);
|
|
71 $sth->bind_param(3, $syn->external_db_id, SQL_INTEGER);
|
|
72 $sth->execute;
|
|
73 $syn->{'dbID'} = $sth->{'mysql_insertid'};
|
|
74 $sth->finish;
|
|
75 }
|
|
76
|
|
77
|
|
78
|
|
79 1;
|