EnsEMBL/DBEntry.pm untested

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