EnsEMBL/DBEntry.pm untested

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