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