EnsEMBL/UnmappedObject.pm untested

filter: Statementstmt 0.0% 0 / 125 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 27 Subroutinesub 0.0% 0 / 20 Podpod 0.0% 0 / 14 totaltotal 0.0% 0 / 236 CC 26 SCAR 38.3
CC
26
Cov
0%
new
156.0
analysis
12.0
description
6.0
CRAP 45.9
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  
29 =cut
30  
31 =head1 NAME
32  
33 Bio:EnsEMBL::UnmappedObject - A object representing why a particular entity
34 was NOT mapped to the ensembl.
35  
36 =head1 SYNOPSIS
37  
38 use Bio::EnsEMBL::UnmappedObject;
39  
40 my $uo = Bio::EnsEMBL::UnmappedObject->new(
41 -type => 'xref',
42 -analysis => $analysis,
43 -external_db_id => 4100,
44 -identifier => "Q12345",
45 -query_score => 45.5,
46 -target_score => 29.2,
47 -ensembl_id => 122346,
48 -ensembl_type => "Translation",
49 -summary => "match failed for exonerate",
50 -full_desc => "match failed for the xref exonerate run "
51 . "as match was below threshold of 90"
52 );
53  
54 =head1 DESCRIPTION
55  
56 UnmappedObjects represent entities NOT mapped to ensembl. Therefore this
57 should help users to find out why certain accessions etc can not be
58 found.
59  
60 =head1 METHODS
61  
62 =cut
63  
64  
65  
66 package Bio::EnsEMBL::UnmappedObject;
67 $Bio::EnsEMBL::UnmappedObject::VERSION = '114.0.0_50'; # TRIAL
68 $Bio::EnsEMBL::UnmappedObject::VERSION = '114.0.050';
69 use strict;
70 use warnings;
71  
72 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
73 use Bio::EnsEMBL::Utils::Exception qw(throw);
74 use Bio::EnsEMBL::Storable;
75  
76 use vars qw(@ISA);
77  
78 @ISA = qw(Bio::EnsEMBL::Storable);
79  
80  
81 =head2 new
82  
83 Arg [TYPE] : the type of mapping i.e. 'xref','cDNA'
84 Arg [ANALYSIS] : Analysis object.
85 Arg [EXTERNAL_DB_ID] : id for the external db id this identifier is from
86 Arg [IDENTIFIER] : name of the identifier i.e. accession
87 Arg [QUERY_SCORE] : (optional) The query score
88 Arg [TARGET_SCORE] : (optional) The target score
89 Arg [SUMMARY] : The summary reason for not mapping.
90 Arg [FULL_DESC] : The Full description of why it did not map.
91 Arg [ENSEMBL_ID] : (optional) internal ensembl id for the best match
92 Arg [ENSEMBL_OBJECT_TYPE] : (optional) the type of object for the best match
93 Example : see SYNOPSIS
94 Returntype : Bio::EnsEMBL::UnmappedObject
95 Exceptions : If any of the none optional args are missing
96 Caller : general
97 Status : At Risk
98  
99 =cut
100  
101 sub new {
102 my $caller = shift;
103  
104 #allow constructor to be called as class or object method
105 my $class = ref($caller) || $caller;
106  
107  
108  
109 my ($dbID, $unmapped_reason_id, $type, $analysis, $ex_db_id, $identifier,
110 $query_score, $target_score, $summary, $full_desc,
111 $ensembl_id, $ensembl_object_type, $adaptor ) =
112 rearrange([qw(UNMAPPED_OBJECT_ID UNMAPPED_REASON_ID TYPE ANALYSIS
113 EXTERNAL_DB_ID IDENTIFIER QUERY_SCORE TARGET_SCORE
114 SUMMARY FULL_DESC ENSEMBL_ID ENSEMBL_OBJECT_TYPE ADAPTOR)], @_);
115  
116 my $self = $class->SUPER::new(@_);
117 if(defined($analysis)) {
118 if(!ref($analysis) || !$analysis->isa('Bio::EnsEMBL::Analysis')) {
119 throw('-ANALYSIS argument must be a Bio::EnsEMBL::Analysis not '.
120 $analysis);
121 }
122 }
123 else{
124 throw('-ANALYSIS argument must be given');
125 }
126 $self->{'analysis'} = $analysis;
127 $self->{'dbID'} = $dbID if (defined($dbID));
128 $self->{'description'} = $full_desc || throw('FULL_DESC must be given');
129 $self->{'summary'} = $summary || throw('SUMMARY must be given');
130 $self->{'type'} = $type || throw('TYPE must be given');
131 $self->{'external_db_id'} = $ex_db_id;
132  
133 if (lc($type) eq "xref") {
134 throw('EXTERNAL_DB_ID must be given') if ! defined $ex_db_id;
135 }
136  
137 $self->{'identifier'} = $identifier || throw('IDENTIFIER must be given');
138 $self->{'query_score'} = $query_score if(defined($query_score));
139 $self->{'target_score'} = $target_score if(defined($target_score));
140 $self->{'ensembl_id'} = $ensembl_id if(defined($ensembl_id));
141 $self->{'ensembl_object_type'} = $ensembl_object_type
142 if(defined($ensembl_object_type));
143 $self->{'unmapped_reason_id'} = $unmapped_reason_id
144 if(defined($unmapped_reason_id));
145 $self->adaptor($adaptor) if(defined($adaptor));
146 return $self;
147 }
148  
149  
150 =head2 description
151  
152 Arg [1] : (optional) * to be set to
153 Example : print $unmappedObject->description."\n";
154 Description : Basic getter/setter for description
155 ReturnType : String
156 Exceptions : none
157 Caller : general
158 Status : At Risk
159  
160 =cut
161  
162 sub description{
163 my $self = shift;
164  
165 if(@_) {
166 my $des = shift;
167 $self->{'description'} = $des;
168 }
169  
170 return $self->{'description'};
171 }
172  
173 =head2 summary
174  
175 Arg [1] : (optional) summary to be set to
176 Example : print $unmappedObject->summary."\n";
177 Description : Basic getter/setter for summary
178 ReturnType : String
179 Exceptions : none
180 Caller : general
181 Status : At Risk
182  
183 =cut
184  
185 sub summary{
186 my $self = shift;
187  
188 if(@_) {
189 my $des = shift;
190 $self->{'summary'} = $des;
191 }
192  
193 return $self->{'summary'};
194 }
195  
196 =head2 type
197  
198 Arg [1] : (optional) type to be set to
199 Example : print $unmappedObject->type."\n";
200 Description : Basic getter/setter for type
201 ReturnType : String
202 Exceptions : none
203 Caller : general
204 Status : At Risk
205  
206 =cut
207  
208 sub type{
209 my $self = shift;
210  
211 if(@_) {
212 my $arg = shift;
213 $self->{'type'} = $arg;
214 }
215  
216 return $self->{'type'};
217 }
218  
219 =head2 ensembl_object_type
220  
221 Arg [1] : (optional) ensembl object type to be set to
222 Example : print $unmappedObject->ensembl_object_type."\n";
223 Description : Basic getter/setter for ensembl object type
224 ReturnType : String
225 Exceptions : none
226 Caller : general
227 Status : At Risk
228  
229 =cut
230  
231 sub ensembl_object_type{
232 my $self = shift;
233  
234 if(@_) {
235 my $arg = shift;
236 $self->{'ensembl_object_type'} = $arg;
237 }
238  
239 return $self->{'ensembl_object_type'};
240 }
241  
242 =head2 ensembl_id
243  
244 Arg [1] : (optional) ensembl id to be set to
245 Example : print $unmappedObject->ensembl_id."\n";
246 Description : Basic getter/setter for ensembl id
247 ReturnType : String
248 Exceptions : none
249 Caller : general
250 Status : At Risk
251  
252 =cut
253  
254 sub ensembl_id{
255 my $self = shift;
256  
257 if(@_) {
258 my $arg = shift;
259 $self->{'ensembl_id'} = $arg;
260 }
261  
262 return $self->{'ensembl_id'};
263 }
264  
265 =head2 external_db_id
266  
267 Arg [1] : (optional) external_db_id to be set to
268 Example : print $unmappedObject->external_db_id."\n";
269 Description : Basic getter/setter for external_db_id
270 ReturnType : int
271 Exceptions : none
272 Caller : general
273 Status : At Risk
274  
275 =cut
276  
277 sub external_db_id{
278 my $self = shift;
279  
280 if(@_) {
281 my $arg = shift;
282 $self->{'external_db_id'} = $arg;
283 }
284
285 return $self->{'external_db_id'};
286 }
287  
288 =head2 external_db_name
289  
290 Example : print $unmappedObject->external_db_name()."\n";
291 Description : Basic getter for external_db_name
292 ReturnType : int
293 Exceptions : none
294 Caller : general
295 Status : At Risk
296  
297 =cut
298  
299 sub external_db_name{
300 my $self = shift;
301  
302 my $handle = $self->adaptor;
303 if(defined($handle) and defined($self->{'external_db_id'})){
304 my $sth = $handle->prepare("select db_name from external_db where external_db_id = ".$self->{'external_db_id'});
305 $sth->execute();
306 my $name;
307 $sth->bind_columns(\$name);
308 $sth->fetch();
309 return $name;
310 }
311 return "";
312 }
313  
314  
315 sub stable_id{
316 my ($self) = shift;
317
318 my $handle = $self->adaptor;
319 if(defined($handle)){
320 my $sql = "select stable_id from ".lc($self->{'ensembl_object_type'})." where ".
321 lc($self->{'ensembl_object_type'})."_id = ".
322 $self->{'ensembl_id'};
323 my $sth = $handle->prepare($sql);
324 $sth->execute();
325 my $name;
326 $sth->bind_columns(\$name);
327 $sth->fetch();
328 return $name;
329 }
330 return "";
331 }
332
333 # my $adaptor;
334 # if($self->{'ensembl_object_type'} eq "Transcript"){
335 # $adaptor= $self->adaptor->db->get_TranscriptAdaptor();
336 # }
337 # elsif($self->{'ensembl_object_type'} eq "Translation"){
338 # $adaptor= $self->adaptor->db->get_TranslationAdaptor();
339 # }
340 # elsif($self->{'ensembl_object_type'} eq "Gene"){
341 # $adaptor= $self->adaptor->db->get_GeneAdaptor();
342 # }
343 # else{
344 # return undef;
345 # }
346 # my $object = $adaptor->fetch_by_dbID($self->{'ensembl_id'});
347 # if(defined($object)){
348 # return $object->stable_id;
349 # }
350 # else{
351 # return undef;
352 # }
353 #}
354  
355
356 =head2 identifier
357  
358 Arg [1] : (optional) identifier to be set to
359 Example : print $unmappedObject->identifier."\n";
360 Description : Basic getter/setter for identifier
361 ReturnType : String
362 Exceptions : none
363 Caller : general
364 Status : At Risk
365  
366 =cut
367  
368 sub identifier{
369 my $self = shift;
370  
371 if(@_) {
372 my $arg = shift;
373 $self->{'identifier'} = $arg;
374 }
375  
376 return $self->{'identifier'};
377 }
378  
379 =head2 query_score
380  
381 Arg [1] : (optional) query_score to be set to
382 Example : print $unmappedObject->query_score."\n";
383 Description : Basic getter/setter for query_score
384 ReturnType : float
385 Exceptions : none
386 Caller : general
387 Status : At Risk
388  
389 =cut
390  
391 sub query_score{
392 my $self = shift;
393  
394 if(@_) {
395 my $arg = shift;
396 $self->{'query_score'} = $arg;
397 }
398  
399 return $self->{'query_score'};
400 }
401  
402 =head2 target_score
403  
404 Arg [1] : (optional) target_score to be set to
405 Example : print $unmappedObject->target_score."\n";
406 Description : Basic getter/setter for target_score
407 ReturnType : float
408 Exceptions : none
409 Caller : general
410 Status : At Risk
411  
412 =cut
413  
414 sub target_score{
415 my $self = shift;
416  
417 if(@_) {
418 my $arg = shift;
419 $self->{'target_score'} = $arg;
420 }
421  
422 return $self->{'target_score'};
423 }
424  
425 =head2 unmapped_reason_id
426  
427 Arg [1] : (optional) unmapped_reason_id to be set to
428 Example : print $unmappedObject->unmapped_reason_id."\n";
429 Description : Basic getter/setter for unmapped_reason_id
430 ReturnType : int
431 Exceptions : none
432 Caller : general
433 Status : At Risk
434  
435 =cut
436  
437 sub unmapped_reason_id{
438 my $self = shift;
439  
440 if(@_) {
441 my $arg = shift;
442 $self->{'unmapped_reason_id'} = $arg;
443 }
444  
445 return $self->{'unmapped_reason_id'};
446 }
447  
448 =head2 analysis
449  
450 Arg [1] : (optional) analysis to be set to
451 Example : print $unmappedObject->analysis->logic_name."\n";
452 Description : Basic getter/setter for analysis
453 ReturnType : Bio::EnsEMBL::Analysis
454 Exceptions : none
455 Caller : general
456 Status : At Risk
457  
458 =cut
459  
460 sub analysis {
461 my $self = shift;
462  
463 if(@_) {
464 my $an = shift;
465 if(defined($an) && (!ref($an) || !$an->isa('Bio::EnsEMBL::Analysis'))) {
466 throw('analysis argument must be a Bio::EnsEMBL::Analysis');
467 }
468 $self->{'analysis'} = $an;
469 }
470  
471 return $self->{'analysis'};
472 }
473  
474 1;