Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/DBSQL/UnconventionalTranscriptAssociationAdaptor.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
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 | |
19 =cut | |
20 | |
21 =head1 NAME | |
22 | |
23 Bio::EnsEMBL::DBSQL::UnconventionalTranscriptAssociationAdaptor | |
24 | |
25 =head1 SYNOPSIS | |
26 | |
27 $utaa = $registry->get_adaptor( 'Human', 'Core', | |
28 'UnconventionalTranscriptAssociation' ); | |
29 | |
30 my $uta = $utaa->fetch_all_by_type('antisense'); | |
31 | |
32 =head1 DESCRIPTION | |
33 | |
34 This is an adaptor for the retrieval and storage of | |
35 UnconventionalTranscriptAssociation objects from the database. Most of | |
36 the implementation is in the superclass BaseFeatureAdaptor. | |
37 | |
38 =head1 METHODS | |
39 | |
40 =cut | |
41 | |
42 package Bio::EnsEMBL::DBSQL::UnconventionalTranscriptAssociationAdaptor; | |
43 | |
44 use strict; | |
45 use Bio::EnsEMBL::DBSQL::BaseAdaptor; | |
46 use Bio::EnsEMBL::UnconventionalTranscriptAssociation; | |
47 | |
48 use vars qw(@ISA); | |
49 | |
50 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor); | |
51 | |
52 | |
53 | |
54 | |
55 =head2 fetch_all_by_interaction_type | |
56 | |
57 Arg [1] : String type | |
58 the type of associations to obtain | |
59 Example : $utas = $utaa->fetch_all_by_type('antisense'); | |
60 Description: Obtains all unconventional transcript associations that | |
61 have a particular interaction type. | |
62 NOTE: In a multi-species database, this method will | |
63 return all the entries matching the search criteria, not | |
64 just the ones associated with the current species. | |
65 Returntype : listREF of Bio::EnsEMBL::UnconventionalTranscriptAssociations | |
66 Exceptions : none | |
67 Caller : general | |
68 Status : At Risk | |
69 : under development | |
70 | |
71 =cut | |
72 | |
73 sub fetch_all_by_interaction_type { | |
74 | |
75 my( $self, $type) = @_; | |
76 | |
77 my $sth = $self->prepare("SELECT transcript_id, gene_id, interaction_type " . | |
78 "FROM unconventional_transcript_association " . | |
79 "WHERE interaction_type = ?"); | |
80 | |
81 $sth->bind_param(1, $type, SQL_VARCHAR); | |
82 $sth->execute(); | |
83 | |
84 my $results = $self->_objs_from_sth($sth); | |
85 | |
86 $sth->finish(); | |
87 | |
88 return $results; | |
89 | |
90 } | |
91 | |
92 | |
93 =head2 fetch_all_by_gene | |
94 | |
95 Arg [1] : String gene the gene of associations to obtain | |
96 Arg [2] : (optional) An interaction type; if set, only associations of this type will be returned. | |
97 Example : $utas = $utaa->fetch_all_by_gene($gene, 'antisense'); | |
98 Description: Obtains all unconventional transcript associations that involve | |
99 a particular gene. | |
100 Returntype : listREF of Bio::EnsEMBL::UnconventionalTranscriptAssociations | |
101 Exceptions : none | |
102 Caller : general | |
103 Status : At Risk | |
104 : under development | |
105 | |
106 =cut | |
107 | |
108 sub fetch_all_by_gene { | |
109 | |
110 my( $self, $gene, $type) = @_; | |
111 | |
112 if(!ref($gene) || !$gene->isa('Bio::EnsEMBL::Gene')) { | |
113 throw('$gene must be a Bio::EnsEMBL::Gene'); | |
114 } | |
115 | |
116 my $sql = "SELECT transcript_id, gene_id, interaction_type FROM unconventional_transcript_association WHERE gene_id = ?"; | |
117 $sql .= " AND interaction_type = ?" if ($type); | |
118 | |
119 my $sth = $self->prepare($sql); | |
120 | |
121 $sth->bind_param(1, $gene->dbID(), SQL_INTEGER); | |
122 $sth->bind_param(2, $type, SQL_VARCHAR) if ($type); | |
123 | |
124 $sth->execute(); | |
125 | |
126 my $results = $self->_objs_from_sth($sth); | |
127 | |
128 $sth->finish(); | |
129 | |
130 return $results; | |
131 | |
132 } | |
133 | |
134 | |
135 =head2 fetch_all_by_transcript | |
136 | |
137 Arg [1] : String transcript the transcript of associations to obtain | |
138 Arg [2] : (optional) An interaction type; if set, only associations of this type will be returned. | |
139 Example : $utas = $utaa->fetch_all_by_transcript($transcript, 'antisense'); | |
140 Description: Obtains all unconventional transcript associations that involve | |
141 a particular transcript. | |
142 Returntype : listREF of Bio::EnsEMBL::UnconventionalTranscriptAssociations | |
143 Exceptions : none | |
144 Caller : general | |
145 Status : At Risk | |
146 : under development | |
147 | |
148 =cut | |
149 | |
150 sub fetch_all_by_transcript { | |
151 | |
152 my( $self, $transcript, $type) = @_; | |
153 | |
154 if(!ref($transcript) || !$transcript->isa('Bio::EnsEMBL::Transcript')) { | |
155 throw('$transcript must be a Bio::EnsEMBL::Transcript'); | |
156 } | |
157 | |
158 my $sql = "SELECT transcript_id, gene_id, interaction_type FROM unconventional_transcript_association WHERE transcript_id = ?"; | |
159 $sql .= " AND interaction_type = ?" if ($type); | |
160 | |
161 my $sth = $self->prepare($sql); | |
162 | |
163 $sth->bind_param(1, $transcript->dbID(), SQL_INTEGER); | |
164 $sth->bind_param(2, $type, SQL_VARCHAR) if ($type); | |
165 | |
166 $sth->execute(); | |
167 | |
168 my $results = $self->_objs_from_sth($sth); | |
169 | |
170 $sth->finish(); | |
171 | |
172 return $results; | |
173 | |
174 } | |
175 | |
176 | |
177 =head2 store | |
178 | |
179 Arg [1] : Bio::EnsEMBL::UnconventionalTranscriptAssociation | |
180 the unconventional transcript association to store in the database | |
181 Example : $utaa_adaptor->store($uta); | |
182 Description: stores unconventional transcript associations in the database | |
183 Returntype : none | |
184 Exceptions : | |
185 Caller : general | |
186 Status : At Risk | |
187 : under development | |
188 | |
189 =cut | |
190 | |
191 sub store { | |
192 | |
193 my( $self, $uta ) = @_; | |
194 | |
195 if(!ref($uta) || !$uta->isa('Bio::EnsEMBL::UnconventionalTranscriptAssociation')) { | |
196 throw('$uta must be a Bio::EnsEMBL::UnconventionalTranscriptAssociation'); | |
197 } | |
198 | |
199 my $sth = $self->prepare(qq {INSERT into unconventional_transcript_association | |
200 (transcript_id, gene_id, interaction_type) VALUES (?,?,?)}); | |
201 | |
202 $sth->bind_param(1, $uta->transcript()->dbID(), SQL_INTEGER); | |
203 $sth->bind_param(2, $uta->gene()->dbID, SQL_INTEGER); | |
204 $sth->bind_param(3, $uta->interaction_type(), SQL_VARCHAR); | |
205 | |
206 $sth->execute(); | |
207 | |
208 } | |
209 | |
210 | |
211 | |
212 sub _objs_from_sth { | |
213 | |
214 my ($self, $sth) = @_; | |
215 | |
216 my $transcript_adaptor = $self->db()->get_TranscriptAdaptor(); | |
217 my $gene_adaptor = $self->db()->get_GeneAdaptor(); | |
218 | |
219 my ($gene_id, $transcript_id, $type); | |
220 $sth->bind_columns(\$transcript_id, \$gene_id, \$type); | |
221 | |
222 my @results; | |
223 | |
224 while($sth->fetch()) { | |
225 | |
226 my $gene = $gene_adaptor->fetch_by_dbID($gene_id); | |
227 my $transcript = $transcript_adaptor->fetch_by_dbID($transcript_id); | |
228 | |
229 my $obj = Bio::EnsEMBL::UnconventionalTranscriptAssociation->new($transcript, $gene, $type); | |
230 push @results, $obj; | |
231 | |
232 } | |
233 | |
234 return \@results; | |
235 } | |
236 | |
237 1; | |
238 | |
239 |