167
170
defined($version) && $self->version( $version );
168
171
defined($is_obsolete) && $self->is_obsolete( $is_obsolete );
169
172
defined($comment) && $self->comment( $comment );
173
defined($dbxrefs) && $self->add_dbxref(-dbxrefs => $dbxrefs);
174
# deprecated methods, allow to pass on to get the dep. notification
170
175
ref($dblinks) && $self->add_dblink(@$dblinks);
171
176
ref($references) && $self->add_reference(@$references);
427
426
Returns : A list of dblinks [array of [scalars]].
428
427
Args : A scalar indicating the context (optional).
429
428
If omitted, all dblinks will be returned.
429
Note : deprecated method due to past use of mixed data types; use
430
get_dbxrefs() instead, which handles both strings and DBLink
433
435
sub get_dblinks {
437
if (defined($context)) {
438
return @{$self->{_dblinks}->{$context}}
439
if exists($self->{_dblinks}->{$context});
441
return map { @$_ } values %{$self->{_dblinks}};
436
my ($self, $context) = @_;
437
$self->deprecated("Use of get_dblinks is deprecated. Note that prior use\n".
438
"of this method could return either simple scalar values\n".
439
"or Bio::Annotation::DBLink instances; only \n".
440
"Bio::Annotation::DBLink is now supported.\n ".
441
"Use get_dbxrefs() instead");
442
$self->get_dbxrefs($context);
447
Title : get_dbxrefs()
448
Usage : @ds = $term->get_dbxrefs();
449
Function: Returns a list of each link for this term.
451
If an implementor of this interface permits modification of
452
this array property, the class should define at least
453
methods add_dbxref() and remove_dbxrefs(), with obvious
456
Returns : A list of L<Bio::Annotation::DBLink> instances
457
Args : [optional] string which specifies context (default : returns all dbxrefs)
462
my ($self, $context) = shift;
464
if (defined($context)) {
465
if (exists($self->{_dblinks}->{$context})) {
466
@dbxrefs = @{$self->{_dblinks}->{$context}};
469
@dbxrefs = map { @$_ } values %{$self->{_dblinks}} ;
447
474
=head2 get_dblink_context
451
478
Function: Return all context existing in Term
452
479
Returns : a list of scalar
481
Note : deprecated method due to past use of mixed data types; use
482
get_dbxref_context() instead
457
486
sub get_dblink_context {
488
$self->deprecated("Use of get_dblink_context() is deprecated; use get_dbxref_context() instead");
489
return $self->get_dbxref_context(@_);
492
=head2 get_dbxref_context
494
Title : get_dbxref_context
495
Usage : @context = $term->get_dbxref_context;
496
Function: Return all context strings existing in Term
497
Returns : a list of scalars
502
sub get_dbxref_context {
459
504
return keys %{$self->{_dblinks}};
467
512
$term->add_dblink( $dbl );
468
513
Function: Pushes one or more dblinks onto the list of dblinks.
470
Args : One dblink [scalar] or a list of
471
dblinks [array of [scalars]].
515
Args : One or more L<Bio::Annotation::DBLink> instances
516
Note : deprecated method due to past use of mixed data types; use
517
add_dbxref() instead, which handles both strings and
476
523
my $self = shift;
477
$self->add_dblink_context($_,'_default') foreach @_;
524
$self->deprecated("Use of simple strings and add_dblink() is deprecated; use\n".
525
"Bio::Annotation::DBLink instances and add_dbxref() instead");
526
# here we're assuming the data is in a simple DB:ID format
528
for my $string (@_) {
529
my ($db, $id) = split(':',$string);
530
push @dbxrefs, Bio::Annotation::DBLink->new(-database => $db, -primary_id => $id);
532
return $self->add_dbxref(-dbxrefs => \@dbxrefs, -context => '_default');
538
Usage : $term->add_dbxref( @dbls );
540
$term->add_dbxref( $dbl );
541
Function: Pushes one or more dblinks onto the list of dblinks.
543
Args : -dbxrefs : array ref of Bio::Annotation::DBLink instances
544
-context : string designating the context for the DBLink
545
(default : '_default' - contextless)
551
my ($links, $context) = $self->_rearrange([qw(DBXREFS CONTEXT)],@_);
552
return unless defined $links;
553
$context ||= '_default';
554
$self->throw("DBLinks must be passed as an array reference") if ref $links ne 'ARRAY';
555
foreach my $dbxref (@{$links}) {
556
$self->throw("$dbxref is not a DBLink") unless ref $dbxref &&
557
$dbxref->isa('Bio::Annotation::DBLink');
558
$self->throw("'all' is a reserved word for context.") if $context eq 'all';
559
if (! exists($self->{_dblinks}->{$context})) {
560
$self->{_dblinks}->{$context} = [];
562
my $linktext = ref $dbxref ? $dbxref->display_text : $dbxref;
563
if (grep {$_->display_text eq $linktext}
564
@{$self->{_dblinks}->{$context}})
566
$self->warn("DBLink exists in the dblink of $context");
568
push @{$self->{_dblinks}->{$context}}, $dbxref;
481
572
=head2 has_dblink
485
576
Function: Checks if a DBXref is already existing in the OBOterm object
486
577
Return : TRUE/FALSE
487
578
Args : [arg1] A DBxref identifier
579
Note : deprecated method due to past use of mixed data types; use
580
has_dbxref() instead, which handles both strings and
492
586
my ( $self, $value ) = @_;
587
$self->deprecated("use of has_dblink() is deprecated; use has_dbxref() instead");
588
return $self->has_dbxref($value);
594
Usage : $term->has_dbxref($dbxref);
595
Function: Checks if a dbxref string is already existing in the OBOterm object
597
Args : [arg1] A DBxref identifier (string).
598
Bio::Annotation::DBLink::display_text() is used for comparison
604
my ( $self, $value ) = @_;
493
605
return unless defined $value;
494
606
my $context = "_default";
495
607
$self->throw("'all' is a reserved word for context.") if $context eq 'all';
496
608
$context ||= '_default';
497
if ( ( $self->{_dblinks}->{$context} ) && grep { $_ eq $value }
609
if ( ( $self->{_dblinks}->{$context} ) &&
610
grep { $_->display_text eq $value }
498
611
@{ $self->{_dblinks}->{$context} } )
508
620
=head2 add_dblink_context
510
622
Title : add_dblink_context
511
623
Usage : $term->add_dblink_context($db, $context);
512
624
Function: add a dblink with its context
514
Args : [arg1] an object of Bio::Annotation::DBLink
626
Args : [arg1] a Bio::Annotation::DBLink instance
515
627
[arg2] a string for context; if omitted, the
516
628
default/context-less one will be used.
629
Note : deprecated method due to past use of mixed data types; use
520
634
sub add_dblink_context {
521
my ($self, $value, $context)=@_;
522
return unless defined $value;
523
$self->throw("'all' is a reserved word for context.") if $context eq 'all';
524
$context ||= '_default';
525
if (! exists($self->{_dblinks}->{$context})) {
526
$self->{_dblinks}->{$context} = [];
528
if (grep {$_ eq $value} @{$self->{_dblinks}->{$context}}) {
529
$self->warn("$value exists in the dblink of $context");
531
push @{$self->{_dblinks}->{$context}}, $value;
635
my ($self, $value, $context) = @_;
636
$self->deprecated("Use of simple strings and add_dblink_context() is deprecated; use\n
637
Bio::Annotation::DBLink instances and add_dbxref() instead");
638
return $self->add_dbxref([$value],$context);
534
641
=head2 remove_dblinks
539
646
Returns : A list of definition references [array of [scalars]].
540
647
Args : Context. If omitted or equal to 'all', all dblinks
649
Note : deprecated method due to past use of mixed data types; use
650
remove_dblinks() instead, which handles both strings and
545
655
sub remove_dblinks {
546
656
my ($self, $context) = @_;
657
$self->deprecated("use of remove_dblinks() is deprecated; use remove_dbxrefs() instead");
658
return $self->remove_dbxrefs(@_);
661
=head2 remove_dbxrefs
663
Title : remove_dbxrefs()
664
Usage : $term->remove_dbxrefs();
665
Function: Deletes (and returns) the definition references of this GO term.
666
Returns : A list of definition references [array of [scalars]].
667
Args : Context. If omitted or equal to 'all', all dblinks
673
my ($self, $context) = @_;
547
674
$context = undef if $context && ($context eq "all");
548
my @old = $self->get_dblinks($context);
675
my @old = $self->get_dbxrefs($context);
549
676
if (defined($context)) {
550
677
$self->{_dblinks}->{$context}=[];
552
679
$self->{_dblinks} = {};
558
684
=head2 get_references
586
712
return unless @values;
587
713
# avoid duplicates and undefs
588
714
foreach my $reference (@values){
589
next unless $reference;
715
$self->throw("Passed data not an Bio::Annotation::Reference") unless ref $reference &&
716
$reference->isa('Bio::AnnotationI');
717
next unless defined $reference;
590
718
next if grep{$_ eq $reference} @{$self->{_references}};
591
719
push @{$self->{_references}}, $reference;
949
sub each_dblink {shift->throw("use of each_dblink() is deprecated; use get_dbxrefs() instead")}
950
sub add_dblinks {shift->throw("use of add_dblinks() is deprecated; use add_dbxref() instead")}
821
951
*each_synonym = \&get_synonyms;
822
952
*add_synonyms = \&add_synonym;
823
*each_dblink = \&get_dblinks;
824
*add_dblinks = \&add_dblink;