comparison variant_effect_predictor/Bio/EnsEMBL/UnmappedObject.pm @ 0:2bc9b66ada89 draft default tip

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