comparison variant_effect_predictor/Bio/EnsEMBL/DBEntry.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::DBEntry -
24 Object representing an external reference (xref)
25
26 =head1 DESCRIPTION
27
28 This object holds information about external references (xrefs) to
29 Ensembl objects.
30
31 =head1 METHODS
32
33 =cut
34
35 package Bio::EnsEMBL::DBEntry;
36
37 use strict;
38 use warnings;
39 no warnings qw(uninitialized);
40
41 use Bio::EnsEMBL::Storable;
42 use Bio::Annotation::DBLink;
43
44 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
45 use Bio::EnsEMBL::Utils::Exception qw(deprecate);
46 use Scalar::Util qw(weaken isweak);
47
48 our @ISA = qw(Bio::EnsEMBL::Storable Bio::Annotation::DBLink);
49
50
51 =head2 new_fast
52
53 Arg [1] : Hashref $hashref - hash reference to bless as new DBEntry object
54 Description: A very quick constructor that requires internal knowledge of
55 the class. This is used in speed critical sections of the code
56 where many objects need to be created quickly.
57 Returntype : Bio::EnsEMBL::DBEntry
58 Exceptions : none
59 Caller : general
60 Status : Stable
61
62 =cut
63
64 sub new_fast {
65 my $class = shift;
66 my $hashref = shift;
67 my $self = bless $hashref, $class;
68 weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
69 return $self;
70 }
71
72
73 =head2 new
74
75 Args [...] : list of named parameters
76 Example : my $dbentry = new Bio::EnsEMBL::DBEntry(
77 -adaptor => $adaptor,
78 -primary_id => $pid,
79 -version => $version,
80 -dbname => $dbname,
81 -release => $release,
82 -display_id => $did,
83 -description => $description,
84 -priority => $priority,
85 -db_display_name => $db_display_name,
86 -info_type => $info_type,
87 -info_text => $info_text,
88 -type => $type,
89 -secondary_db_name => $secondary_db_name,
90 -secondary_db_table => $secondary_db_table
91 -linkage_annotation => $object_xref_text);
92 Description: Creates a new DBEntry object
93 Returntype : Bio::EnsEMBL::DBEntry
94 Exceptions : none
95 Caller : Bio::EnsEMBL::DBEntryAdaptor
96 Status : At Risk
97 Due to 'PRIORITY',
98 'INFO_TYPE', 'INFO_TEXT', ''DB_DISPLAY_NAME', 'TYPE',
99 'SECONDARY_DB_NAME', 'SECONDARY_DB_TABLE'
100 being under development - if you don't use any of these the
101 method can be considered Stable
102
103 =cut
104
105 sub new {
106 my ($class, @args) = @_;
107
108 my $self = bless {},$class;
109
110 my ( $adaptor, $dbID, $primary_id, $version,
111 $dbname, $release, $display_id, $description,
112 $priority,
113 $db_display_name, $info_type, $info_text, $type,
114 $secondary_db_name, $secondary_db_table, $link_annotation, $analysis) =
115 rearrange ( ['ADAPTOR','DBID','PRIMARY_ID','VERSION',
116 'DBNAME','RELEASE','DISPLAY_ID','DESCRIPTION',
117 'PRIORITY',
118 'DB_DISPLAY_NAME', 'INFO_TYPE', 'INFO_TEXT', 'TYPE',
119 'SECONDARY_DB_NAME', 'SECONDARY_DB_TABLE', 'LINKAGE_ANNOTATION', 'ANALYSIS'], @args );
120
121 $self->adaptor($adaptor);
122 $self->{'dbID'} = $dbID;
123
124 if( defined $primary_id ) { $self->primary_id( $primary_id ) }
125 if( defined $version ) { $self->version( $version ) } else
126 { $self->version( 0 ); }
127 if( defined $dbname ) { $self->dbname( $dbname ) }
128 if( defined $release) { $self->release( $release ) }
129 if( defined $display_id) { $self->display_id( $display_id ) }
130 if( defined $description) { $self->description($description) }
131 if( defined $priority) { $self->priority($priority) }
132 if( defined $db_display_name) { $self->db_display_name($db_display_name) }
133 if( defined $info_type) { $self->info_type($info_type) }
134 if( defined $info_text) { $self->info_text($info_text) }
135 if( defined $type) { $self->type($type) }
136 if( defined $secondary_db_name) { $self->secondary_db_name($secondary_db_name) }
137 if( defined $secondary_db_table) { $self->secondary_db_table($secondary_db_table) }
138
139 $self->linkage_annotation($link_annotation) if defined $link_annotation;
140 $self->analysis($analysis) if defined $analysis;
141
142
143 return $self;
144 }
145
146
147 =head2 primary_id
148
149 Arg [1] : (optional) String $arg - value to set
150 Example : none
151 Description: Getter/setter for attribute 'primary_id'.
152 This is the object's primary id in the external database.
153 Returntype : String
154 Exceptions : none
155 Caller : general
156 Status : Stable
157
158 =cut
159
160 sub primary_id {
161 my ( $self, $arg ) = @_;
162 if( defined $arg ) {
163 $self->{primary_id} = $arg;
164 }
165 return $self->{primary_id};
166 }
167
168
169 =head2 display_id
170
171 Arg [1] : (optional) String $arg - value to set
172 Example : none
173 Description: Getter/setter for attribute 'display_id'.
174 The object's preferred display name. This can be the same
175 as primary_id or ensembl-specific.
176 Returntype : String
177 Exceptions : none
178 Caller : general
179 Status : Stable
180
181 =cut
182
183 sub display_id{
184 my ( $self, $arg ) = @_;
185 if( defined $arg ) {
186 $self->{display_id} = $arg;
187 }
188 return $self->{display_id};
189 }
190
191
192 =head2 optional_id
193
194 Args : none
195 Example : none
196 Description: Additional getter for attribute 'display_id'.
197 The object's preferred display name.
198 Only include for BioPerl interface compliance, please use
199 $self->display_id().
200 Returntype : String
201 Exceptions : none
202 Caller : general
203 Status : Stable
204
205 =cut
206
207 sub optional_id {
208 my $self = shift;
209 return $self->display_id;
210 }
211
212
213 =head2 dbname
214
215 Arg [1] : (optional) String $arg - value to set
216 Example : none
217 Description: Getter/setter for attribute 'dbname'.
218 The name of the external database.
219 Returntype : String
220 Exceptions : none
221 Caller : general
222 Status : Stable
223
224 =cut
225
226 sub dbname {
227 my ( $self, $arg ) = @_;
228 if( defined $arg ) {
229 $self->{dbname} = $arg;
230 }
231 return $self->{dbname};
232 }
233
234
235 =head2 database
236
237 Args : none
238 Example : none
239 Description: Additional getter for attribute 'dbname'.
240 The name of the external database.
241 Only include for BioPerl interface compliance, please use
242 $self->dbname().
243 Returntype : String
244 Exceptions : none
245 Caller : general
246 Status : Stable
247
248 =cut
249
250 sub database {
251 my $self = shift;
252 return $self->dbname();
253 }
254
255
256 =head2 release
257
258 Arg [1] : (optional) String $arg - value to set
259 Example : none
260 Description: Getter/setter for attribute 'release'.
261 The external database release name.
262 Returntype : String
263 Exceptions : none
264 Caller : general
265 Status : Stable
266
267 =cut
268
269 sub release {
270 my ( $self, $arg ) = @_;
271 if( defined $arg ) {
272 $self->{release} = $arg;
273 }
274 return $self->{release};
275 }
276
277
278 =head2 version
279
280 Arg [1] : (optional) String $arg - value to set
281 Example : none
282 Description: Getter/setter for attribute 'version'.
283 The object's version in the external database.
284 Returntype : String
285 Exceptions : none
286 Caller : general
287 Status : Stable
288
289 =cut
290
291 sub version {
292 my ( $self, $arg ) = @_;
293 if( defined $arg ) {
294 $self->{version} = $arg;
295 }
296 return $self->{version};
297 }
298
299
300 =head2 description
301
302 Arg [1] : (optional) String $arg - value to set
303 Example : none
304 Description: Getter/setter for attribute 'description'.
305 The object's description, from the xref table
306 Returntype : String
307 Exceptions : none
308 Caller : general
309 Status : Stable
310
311 =cut
312
313 sub description {
314 my ( $self, $arg ) = @_;
315
316 if ( defined($arg) ) { $self->{'description'} = $arg }
317
318 return $self->{description};
319 }
320
321 =head2 analysis
322
323 Arg [1] : Bio::EnsEMBL::Analysis $analysis
324 Example : none
325 Description: get/set for attribute analysis
326 Returntype : Bio::EnsEMBL::Analysis
327 Exceptions : none
328 Caller : general
329 Status : Stable
330
331 =cut
332
333 sub analysis {
334 my $self = shift;
335 $self->{analysis} = shift if( @_ );
336 return $self->{analysis};
337 }
338
339 =head2 comment
340
341 Args : none
342 Example : none
343 Description: Additional getter for attribute 'description'.
344 The object's description.
345 Only include for BioPerl interface compliance, please use
346 $self->description().
347 Returntype : String
348 Exceptions : none
349 Caller : general
350 Status : Stable
351
352 =cut
353
354 sub comment {
355 my $self = shift;
356 return $self->description();
357 }
358
359
360 =head2 priority
361
362 Arg [1] : int $priority
363 Example : none
364 Priority : Getter/setter for attribute 'priority'. Note this
365 is the priority from the external_db table.
366 Returntype : String
367 Exceptions : none
368 Caller : general
369 Status : At Risk
370 : due to it being under development
371
372 =cut
373
374 sub priority {
375 my ( $self, $arg ) = @_;
376 if( defined $arg ) {
377 $self->{priority} = $arg;
378 }
379 return $self->{priority};
380 }
381
382
383 =head2 db_display_name
384
385 Arg [1] : String $db_display_name
386 Example : none
387 Description: Getter/setter for attribute 'db_display_name'.
388 The preferred display name for the external database. Has
389 "Projected " prepended if info_type='PROJECTION'.
390 Returntype : String
391 Exceptions : none
392 Caller : general
393
394 =cut
395
396 sub db_display_name {
397 my ( $self, $arg ) = @_;
398 if( defined $arg ) {
399 $self->{db_display_name} = $arg;
400 }
401
402 my $name;
403 if ($self->{info_type} && $self->{info_type} eq "PROJECTION") {
404 $name = "Projected " . $self->{db_display_name};
405 } else {
406 $name = $self->{db_display_name};
407 }
408
409 return $name;
410 }
411
412
413 =head2 info_type
414
415 Arg [1] : String $info_type
416 Example : none
417 Description: Getter/setter for attribute 'info_type'.
418 Returntype : String
419 Exceptions : none
420 Caller : general
421
422 =cut
423
424 sub info_type {
425 my ( $self, $arg ) = @_;
426 if( defined $arg ) {
427 $self->{info_type} = $arg;
428 }
429 return $self->{info_type};
430 }
431
432
433 =head2 info_text
434
435 Arg [1] : String $info_text
436 Example : none
437 Description: Getter/setter for attribute 'info_text'.
438 Returntype : String
439 Exceptions : none
440 Caller : general
441
442 =cut
443
444 sub info_text {
445 my ( $self, $arg ) = @_;
446 if( defined $arg ) {
447 $self->{info_text} = $arg;
448 }
449 return $self->{info_text};
450 }
451
452 =head2 linkage_annotation
453
454 Arg [1] : String $object_xref_text
455 Example : none
456 Description: Getter/setter for attribute 'linkage_annotation'.
457 Returntype : String
458 Exceptions : none
459 Caller : general
460
461 =cut
462
463 sub linkage_annotation {
464 my ( $self, $arg ) = @_;
465
466 $self->{linkage_annotation} = $arg if defined $arg;
467
468 return $self->{linkage_annotation};
469 }
470
471
472 =head2 type
473
474 Arg [1] : String $type
475 Example : none
476 Description: Getter/setter for attribute 'type'.
477 Returntype : String
478 Exceptions : none
479 Caller : general
480
481 =cut
482
483 sub type {
484 my ( $self, $arg ) = @_;
485 if( defined $arg ) {
486 $self->{type} = $arg;
487 }
488 return $self->{type};
489 }
490
491 =head2 secondary_db_name
492
493 Arg [1] : String $secondary_db_name
494 Description: Getter/setter for attribute 'secondary_db_name'.
495 Returntype : String
496 Exceptions : none
497 Caller : general
498
499 =cut
500
501 sub secondary_db_name {
502 my ( $self, $arg ) = @_;
503 if( defined $arg ) {
504 $self->{secondary_db_name} = $arg;
505 }
506 return $self->{secondary_db_name};
507 }
508
509
510 =head2 secondary_db_table
511
512 Arg [1] : String $secondary_db_table
513 Description: Getter/setter for attribute 'secondary_db_table'.
514 Returns : String
515 Exceptions : none
516 Caller : general
517
518 =cut
519
520 sub secondary_db_table {
521 my ( $self, $arg ) = @_;
522 if( defined $arg ) {
523 $self->{secondary_db_table} = $arg;
524 }
525 return $self->{secondary_db_table};
526 }
527
528
529 =head2 add_synonym
530
531 Arg [1] : String $arg - synonym to add
532 Description: Add a synonym for the external object.
533 Returntype : none
534 Exceptions : none
535 Caller : general
536 Status : Stable
537
538 =cut
539
540
541 sub add_synonym {
542 my ( $self, $arg ) = @_;
543 if( defined $arg ) {
544 push( @{$self->{synonyms}}, $arg );
545 }
546 }
547
548
549 =head2 get_all_synonyms
550
551 Args : none
552 Example : my @synonyms = @{ $db_entry->get_all_synonyms };
553 Description: Get a list of synonyms known for this object.
554 Synonyms are lazy-loaded if required.
555 Returntype : listref of strings. May be empty.
556 Exceptions : none
557 Caller : general
558 Status : Stable
559
560 =cut
561
562 sub get_all_synonyms {
563
564 my $self = shift;
565
566 # lazy-load synonyms if required
567 if (!$self->{synonyms} && $self->adaptor()) {
568 $self->{synonyms} = $self->adaptor()->fetch_all_synonyms($self->dbID());
569 }
570
571 return $self->{synonyms};
572 }
573
574
575 =head2 get_all_dependents
576
577 Args[1] : (optional) Bio::EnsEMBL::Gene, Transcript or Translation object
578 Example : my @dependents = @{ $db_entry->get_all_dependents };
579 Description: Get a list of DBEntrys that are depenednet on the DBEntry.
580 if an ensembl gene transcript or translation is given then only
581 the ones on that object will be given
582 Returntype : listref of DBEntrys. May be empty.
583 Exceptions : none
584 Caller : general
585 Status : UnStable
586
587 =cut
588
589 sub get_all_dependents {
590 my $self = shift;
591 my $ensembl_object = shift;
592
593 return $self->adaptor()->get_all_dependents($self->dbID(), $ensembl_object);
594 }
595
596 =head2 get_all_masters
597
598 Args[1] : (optional) Bio::EnsEMBL::Gene, Transcript or Translation object
599 Example : my @masters = @{ $db_entry->get_all_masters };
600 Description: Get a list of DBEntrys that are the masters of the DBEntry.
601 if an ensembl gene transcript or translation is given then only
602 the ones on that object will be given.
603 Returntype : listref of DBEntrys. May be empty.
604 Exceptions : none
605 Caller : general
606 Status : UnStable
607
608 =cut
609
610 sub get_all_masters {
611 my $self = shift;
612 my $ensembl_object = shift;
613
614 return $self->adaptor()->get_all_masters($self->dbID(), $ensembl_object);
615 }
616
617
618 =head2 flush_synonyms
619
620 Args : none
621 Description: Remove all synonyms from this object.
622 Returntype : none
623 Exceptions : none
624 Caller : general
625 Status : Stable
626
627 =cut
628
629 sub flush_synonyms {
630 my $self = shift;
631 $self->{synonyms} = [];
632 }
633
634
635 =head2 status
636
637 Arg [1] : (optional) String $arg - value to set
638 Description: Getter/setter for attribute 'status'.
639 Returntype : String
640 Exceptions : none
641 Caller : general
642 Status : Stable
643
644 =cut
645
646
647 sub status{
648 my ( $self, $arg ) = @_;
649 if( defined $arg ) {
650 $self->{status} = $arg;
651 }
652 return $self->{status};
653 }
654
655 =head2 ensembl_object_type
656
657 Arg [1] : (optional) String $arg - value to set
658 Description: Getter/setter for attribute ensembl_object_type.
659 Returntype : String
660 Exceptions : none
661 Caller : general
662 Status : Stable
663
664 =cut
665
666
667 sub ensembl_object_type{
668 my ( $self, $arg ) = @_;
669 if( defined $arg ) {
670 $self->{ensembl_object_type} = $arg;
671 }
672 return $self->{ensembl_object_type};
673 }
674
675 =head2 ensembl_id
676
677 Arg [1] : (optional) String $arg - value to set
678 Description: Getter/setter for attribute ensembl_id.
679 Returntype : String
680 Exceptions : none
681 Caller : general
682 Status : Stable
683
684 =cut
685
686
687 sub ensembl_id{
688 my ( $self, $arg ) = @_;
689 if( defined $arg ) {
690 $self->{ensembl_id} = $arg;
691 }
692 return $self->{ensembl_id};
693 }
694
695
696
697 =head1 DEPRECATED METHODS
698
699 =cut
700
701 =head2 get_synonyms
702
703 DEPRECATED use get_all_synonyms instead
704
705 =cut
706
707 sub get_synonyms {
708 my $self = shift;
709
710 deprecate("get_synonyms has been renamed get_all_synonyms.");
711 return $self->get_all_synonyms;
712 }
713
714 1;
715