Bring base classes from BioPerl-run back to BioPerl.
[bioperl-live.git] / Bio / Ontology / Term.pm
blob21f5136da14a976a91de9b8b78c039f104c60174
2 # BioPerl module for Bio::Ontology::Term
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Christian M. Zmasek <czmasek-at-burnham.org> or <cmzmasek@yahoo.com>
8 # (c) Christian M. Zmasek, czmasek-at-burnham.org, 2002.
9 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
11 # You may distribute this module under the same terms as perl itself.
12 # Refer to the Perl Artistic License (see the license accompanying this
13 # software package, or see http://www.perl.com/language/misc/Artistic.html)
14 # for the terms under which you may use, modify, and redistribute this module.
16 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
17 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 # You may distribute this module under the same terms as perl itself
22 # POD documentation - main docs before the code
24 =head1 NAME
26 Bio::Ontology::Term - implementation of the interface for ontology terms
28 =head1 SYNOPSIS
30 #get Bio::Ontology::TermI somehow.
32 print $term->identifier(), "\n";
33 print $term->name(), "\n";
34 print $term->definition(), "\n";
35 print $term->is_obsolete(), "\n";
36 print $term->comment(), "\n";
38 foreach my $synonym ( $term->each_synonym() ) {
39 print $synonym, "\n";
42 =head1 DESCRIPTION
44 This is a simple implementation for ontology terms providing basic
45 methods (it provides no functionality related to graphs). It
46 implements the L<Bio::Ontology::TermI> interface.
48 This class also implements L<Bio::IdentifiableI> and
49 L<Bio::DescribableI>.
51 =head1 FEEDBACK
53 =head2 Mailing Lists
55 User feedback is an integral part of the evolution of this and other
56 Bioperl modules. Send your comments and suggestions preferably to one
57 of the Bioperl mailing lists. Your participation is much appreciated.
59 bioperl-l@bioperl.org - General discussion
60 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
62 =head2 Support
64 Please direct usage questions or support issues to the mailing list:
66 I<bioperl-l@bioperl.org>
68 rather than to the module maintainer directly. Many experienced and
69 reponsive experts will be able look at the problem and quickly
70 address it. Please include a thorough description of the problem
71 with code and data examples if at all possible.
73 =head2 Reporting Bugs
75 Report bugs to the Bioperl bug tracking system to help us keep track
76 the bugs and their resolution. Bug reports can be submitted via the web:
78 https://github.com/bioperl/bioperl-live/issues
80 =head1 AUTHOR
82 Christian M. Zmasek
84 Email: czmasek-at-burnham.org or cmzmasek@yahoo.com
86 WWW: http://monochrome-effect.net/
88 Address:
90 Genomics Institute of the Novartis Research Foundation
91 10675 John Jay Hopkins Drive
92 San Diego, CA 92121
94 =head1 APPENDIX
96 The rest of the documentation details each of the object
97 methods.
99 =cut
102 # Let the code begin...
104 package Bio::Ontology::Term;
105 use strict;
106 use Bio::Ontology::Ontology;
107 use Bio::Ontology::OntologyStore;
108 use Bio::Annotation::DBLink;
109 use Data::Dumper;
111 use constant TRUE => 1;
112 use constant FALSE => 0;
114 use base qw(Bio::Root::Root Bio::Ontology::TermI Bio::IdentifiableI Bio::DescribableI);
116 =head2 new
118 Title : new
119 Usage : $term = Bio::Ontology::Term->new(
120 -identifier => "16847",
121 -name => "1-aminocyclopropane-1-carboxylate synthase",
122 -definition => "Catalysis of ...",
123 -is_obsolete => 0,
124 -comment => "" );
125 Function: Creates a new Bio::Ontology::Term.
126 Returns : A new Bio::Ontology::Term object.
127 Args : -identifier => the identifier of this term [scalar]
128 -name => the name of this term [scalar]
129 -definition => the definition of this term [scalar]
130 -ontology => the ontology this term lives in
131 (a Bio::Ontology::OntologyI object)
132 -version => version information [scalar]
133 -is_obsolete => the obsoleteness of this term [0 or 1]
134 -comment => a comment [scalar]
135 -dblinks => Bio::Annotation::DBLink objects
136 [reference to array]
137 -references => Bio::Annotation::Reference objects
138 [reference to array]
140 See L<Bio::Ontology::OntologyI>, L<Bio::Annotation::Reference>,
141 L<Bio::Annotation::DBLink>.
143 =cut
145 sub new {
147 my( $class,@args ) = @_;
149 my $self = $class->SUPER::new( @args );
150 my ( $identifier, $name, $definition, $category, $ont, $version,
151 $is_obsolete, $comment, $dblinks, $dbxrefs, $references)
152 = $self->_rearrange( [
153 qw(IDENTIFIER NAME DEFINITION CATEGORY ONTOLOGY VERSION IS_OBSOLETE
154 COMMENT DBLINKS DBXREFS REFERENCES) ], @args );
156 $self->init();
158 defined($identifier) && $self->identifier( $identifier );
159 defined($name) && $self->name( $name );
160 defined($definition) && $self->definition( $definition );
161 defined($category) && $self->category( $category );
162 defined($ont) && $self->ontology( $ont );
163 defined($version) && $self->version( $version );
164 defined($is_obsolete) && $self->is_obsolete( $is_obsolete );
165 defined($comment) && $self->comment( $comment );
166 defined($dbxrefs) && $self->add_dbxref(-dbxrefs => $dbxrefs);
167 # deprecated methods, allow one to pass on to get the dep. notification
168 ref($dblinks) && $self->add_dblink(@$dblinks);
169 ref($references) && $self->add_reference(@$references);
171 return $self;
172 } # new
176 sub init {
178 my $self = shift;
180 $self->identifier(undef);
181 $self->name(undef);
182 $self->comment(undef);
183 $self->definition(undef);
184 $self->ontology(undef);
185 $self->is_obsolete(0);
186 $self->remove_synonyms();
187 $self->remove_dbxrefs();
188 $self->remove_references;
189 $self->remove_secondary_ids();
191 } # init
195 =head2 identifier
197 Title : identifier
198 Usage : $term->identifier( "GO:0003947" );
200 print $term->identifier();
201 Function: Set/get for the identifier of this Term.
202 Returns : The identifier [scalar].
203 Args : The identifier [scalar] (optional).
205 =cut
207 sub identifier {
208 my $self = shift;
210 return $self->{'identifier'} = shift if @_;
211 return $self->{'identifier'};
212 } # identifier
215 =head2 name
217 Title : name
218 Usage : $term->name( "N-acetylgalactosaminyltransferase" );
220 print $term->name();
221 Function: Set/get for the name of this Term.
222 Returns : The name [scalar].
223 Args : The name [scalar] (optional).
225 =cut
227 sub name {
228 my $self = shift;
230 return $self->{'name'} = shift if @_;
231 return $self->{'name'};
232 } # name
235 =head2 definition
237 Title : definition
238 Usage : $term->definition( "Catalysis of ..." );
240 print $term->definition();
241 Function: Set/get for the definition of this Term.
242 Returns : The definition [scalar].
243 Args : The definition [scalar] (optional).
245 =cut
247 sub definition {
248 my $self = shift;
250 return $self->{'definition'} = shift if @_;
251 return $self->{'definition'};
252 } # definition
255 =head2 ontology
257 Title : ontology
258 Usage : $ont = $term->ontology();
260 $term->ontology( $ont );
261 Function: Get the ontology this term is in.
263 Note that with the ontology in hand you can query for all
264 related terms etc.
266 Returns : The ontology of this Term as a Bio::Ontology::OntologyI
267 implementing object.
268 Args : On set, the ontology of this Term as a Bio::Ontology::OntologyI
269 implementing object or a string representing its name.
271 See L<Bio::Ontology::OntologyI>.
273 =cut
275 sub ontology {
276 my $self = shift;
277 my $ont;
279 if(@_) {
280 $ont = shift;
281 if($ont) {
282 $ont = Bio::Ontology::Ontology->new(-name => $ont) if ! ref($ont);
283 if(! $ont->isa("Bio::Ontology::OntologyI")) {
284 $self->throw(ref($ont)." does not implement ".
285 "Bio::Ontology::OntologyI. Bummer.");
288 return $self->{"_ontology"} = $ont;
290 return $self->{"_ontology"};
291 } # ontology
293 =head2 version
295 Title : version
296 Usage : $term->version( "1.00" );
298 print $term->version();
299 Function: Set/get for version information.
300 Returns : The version [scalar].
301 Args : The version [scalar] (optional).
303 =cut
305 sub version {
306 my $self = shift;
308 return $self->{'version'} = shift if @_;
309 return $self->{'version'};
310 } # version
312 =head2 is_obsolete
314 Title : is_obsolete
315 Usage : $term->is_obsolete( 1 );
317 if ( $term->is_obsolete() )
318 Function: Set/get for the obsoleteness of this Term.
319 Returns : the obsoleteness [0 or 1].
320 Args : the obsoleteness [0 or 1] (optional).
322 =cut
324 sub is_obsolete{
325 my $self = shift;
327 return $self->{'is_obsolete'} = shift if @_;
328 return $self->{'is_obsolete'};
329 } # is_obsolete
332 =head2 comment
334 Title : comment
335 Usage : $term->comment( "Consider the term ..." );
337 print $term->comment();
338 Function: Set/get for an arbitrary comment about this Term.
339 Returns : A comment.
340 Args : A comment (optional).
342 =cut
344 sub comment{
345 my $self = shift;
347 return $self->{'comment'} = shift if @_;
348 return $self->{'comment'};
349 } # comment
351 =head2 get_synonyms
353 Title : get_synonyms
354 Usage : @aliases = $term->get_synonyms;
355 Function: Returns a list of aliases of this Term.
356 Returns : A list of aliases [array of [scalar]].
357 Args :
359 =cut
361 sub get_synonyms {
362 my $self = shift;
364 return @{ $self->{ "_synonyms" } } if exists($self->{ "_synonyms" });
365 return ();
366 } # get_synonyms
369 =head2 add_synonym
371 Title : add_synonym
372 Usage : $term->add_synonym( @asynonyms );
374 $term->add_synonym( $synonym );
375 Function: Pushes one or more synonyms into the list of synonyms.
376 Returns :
377 Args : One synonym [scalar] or a list of synonyms [array of [scalar]].
379 =cut
381 sub add_synonym {
382 my ( $self, @values ) = @_;
384 return unless( @values );
386 # avoid duplicates
387 foreach my $syn (@values) {
388 next if grep { $_ eq $syn; } @{$self->{ "_synonyms" }};
389 push( @{ $self->{ "_synonyms" } }, $syn );
392 } # add_synonym
395 =head2 remove_synonyms
397 Title : remove_synonyms()
398 Usage : $term->remove_synonyms();
399 Function: Deletes (and returns) the synonyms of this Term.
400 Returns : A list of synonyms [array of [scalar]].
401 Args :
403 =cut
405 sub remove_synonyms {
406 my ( $self ) = @_;
408 my @a = $self->get_synonyms();
409 $self->{ "_synonyms" } = [];
410 return @a;
412 } # remove_synonyms
414 =head2 get_dblinks
416 Title : get_dblinks()
417 Usage : @ds = $term->get_dblinks();
418 Function: Returns a list of each dblinks of this GO term.
419 Returns : A list of dblinks [array of [scalars]].
420 Args : A scalar indicating the context (optional).
421 If omitted, all dblinks will be returned.
422 Note : deprecated method due to past use of mixed data types; use
423 get_dbxrefs() instead, which handles both strings and DBLink
424 instances
426 =cut
428 sub get_dblinks {
429 my ($self, $context) = @_;
430 $self->deprecated("Use of get_dblinks is deprecated. Note that prior use\n".
431 "of this method could return either simple scalar values\n".
432 "or Bio::Annotation::DBLink instances; only \n".
433 "Bio::Annotation::DBLink is now supported.\n ".
434 "Use get_dbxrefs() instead");
435 $self->get_dbxrefs($context);
436 } # get_dblinks
438 =head2 get_dbxrefs
440 Title : get_dbxrefs()
441 Usage : @ds = $term->get_dbxrefs();
442 Function: Returns a list of each link for this term.
444 If an implementor of this interface permits modification of
445 this array property, the class should define at least
446 methods add_dbxref() and remove_dbxrefs(), with obvious
447 functionality.
449 Returns : A list of L<Bio::Annotation::DBLink> instances
450 Args : [optional] string which specifies context (default : returns all dbxrefs)
452 =cut
454 sub get_dbxrefs {
455 my ($self, $context) = shift;
456 my @dbxrefs;
457 if (defined($context)) {
458 if (exists($self->{_dblinks}->{$context})) {
459 @dbxrefs = @{$self->{_dblinks}->{$context}};
461 } else {
462 @dbxrefs = map { @$_ } values %{$self->{_dblinks}} ;
464 return @dbxrefs;
465 } # get_dbxrefs
467 =head2 get_dblink_context
469 Title : get_dblink_context
470 Usage : @context = $term->get_dblink_context;
471 Function: Return all context existing in Term
472 Returns : a list of scalar
473 Args : [none]
474 Note : deprecated method due to past use of mixed data types; use
475 get_dbxref_context() instead
477 =cut
479 sub get_dblink_context {
480 my $self=shift;
481 $self->deprecated("Use of get_dblink_context() is deprecated; use get_dbxref_context() instead");
482 return $self->get_dbxref_context(@_);
485 =head2 get_dbxref_context
487 Title : get_dbxref_context
488 Usage : @context = $term->get_dbxref_context;
489 Function: Return all context strings existing in Term
490 Returns : a list of scalars
491 Args : [none]
493 =cut
495 sub get_dbxref_context {
496 my $self=shift;
497 return keys %{$self->{_dblinks}};
500 =head2 add_dblink
502 Title : add_dblink
503 Usage : $term->add_dblink( @dbls );
505 $term->add_dblink( $dbl );
506 Function: Pushes one or more dblinks onto the list of dblinks.
507 Returns :
508 Args : One or more L<Bio::Annotation::DBLink> instances
509 Note : deprecated method due to past use of mixed data types; use
510 add_dbxref() instead, which handles both strings and
511 DBLink instances
513 =cut
515 sub add_dblink {
516 my $self = shift;
517 $self->deprecated("Use of simple strings and add_dblink() is deprecated; use\n".
518 "Bio::Annotation::DBLink instances and add_dbxref() instead");
519 # here we're assuming the data is in a simple DB:ID format
520 my @dbxrefs;
521 for my $string (@_) {
522 my ($db, $id) = split(':',$string);
523 push @dbxrefs, Bio::Annotation::DBLink->new(-database => $db, -primary_id => $id);
525 return $self->add_dbxref(-dbxrefs => \@dbxrefs, -context => '_default');
526 } # add_dblink
528 =head2 add_dbxref
530 Title : add_dbxref
531 Usage : $term->add_dbxref( @dbls );
533 $term->add_dbxref( $dbl );
534 Function: Pushes one or more dblinks onto the list of dblinks.
535 Returns :
536 Args : -dbxrefs : array ref of Bio::Annotation::DBLink instances
537 -context : string designating the context for the DBLink
538 (default : '_default' - contextless)
540 =cut
542 sub add_dbxref {
543 my $self = shift;
544 my ($links, $context) = $self->_rearrange([qw(DBXREFS CONTEXT)],@_);
545 return unless defined $links;
546 $context ||= '_default';
547 $self->throw("DBLinks must be passed as an array reference") if ref $links ne 'ARRAY';
548 foreach my $dbxref (@{$links}) {
549 $self->throw("$dbxref is not a DBLink") unless ref $dbxref &&
550 $dbxref->isa('Bio::Annotation::DBLink');
551 $self->throw("'all' is a reserved word for context.") if $context eq 'all';
552 if (! exists($self->{_dblinks}->{$context})) {
553 $self->{_dblinks}->{$context} = [];
555 my $linktext = ref $dbxref ? $dbxref->display_text : $dbxref;
556 if (grep {$_->display_text eq $linktext}
557 @{$self->{_dblinks}->{$context}})
559 $self->warn("DBLink exists in the dblink of $context");
561 push @{$self->{_dblinks}->{$context}}, $dbxref;
563 } # add_dbxref
565 # alias, for consistency
566 *add_dbxrefs = \&add_dbxref;
568 =head2 has_dblink
570 Title : has_dblink
571 Usage : $term->has_dblink($dblink);
572 Function: Checks if a DBXref is already existing in the OBOterm object
573 Return : TRUE/FALSE
574 Args : [arg1] A DBxref identifier
575 Note : deprecated method due to past use of mixed data types; use
576 has_dbxref() instead, which handles both strings and
577 DBLink instances
579 =cut
581 sub has_dblink {
582 my ( $self, $value ) = @_;
583 $self->deprecated("use of has_dblink() is deprecated; use has_dbxref() instead");
584 return $self->has_dbxref($value);
587 =head2 has_dbxref
589 Title : has_dbxref
590 Usage : $term->has_dbxref($dbxref);
591 Function: Checks if a dbxref string is already existing in the OBOterm object
592 Return : TRUE/FALSE
593 Args : [arg1] A DBxref identifier (string).
594 Bio::Annotation::DBLink::display_text() is used for comparison
595 against the string.
597 =cut
599 sub has_dbxref {
600 my ( $self, $value ) = @_;
601 return unless defined $value;
602 my $context = "_default";
603 $self->throw("'all' is a reserved word for context.") if $context eq 'all';
604 $context ||= '_default';
605 if ( ( $self->{_dblinks}->{$context} ) &&
606 grep { $_->display_text eq $value }
607 @{ $self->{_dblinks}->{$context} } )
609 return TRUE;
611 else {
612 return FALSE;
616 =head2 add_dblink_context
618 Title : add_dblink_context
619 Usage : $term->add_dblink_context($db, $context);
620 Function: add a dblink with its context
621 Return : [none]
622 Args : [arg1] a Bio::Annotation::DBLink instance
623 [arg2] a string for context; if omitted, the
624 default/context-less one will be used.
625 Note : deprecated method due to past use of mixed data types; use
626 add_dbxref() instead
628 =cut
630 sub add_dblink_context {
631 my ($self, $value, $context) = @_;
632 $self->deprecated("Use of simple strings and add_dblink_context() is deprecated; use\n
633 Bio::Annotation::DBLink instances and add_dbxref() instead");
634 return $self->add_dbxref([$value],$context);
637 =head2 remove_dblinks
639 Title : remove_dblinks()
640 Usage : $term->remove_dblinks();
641 Function: Deletes (and returns) the definition references of this GO term.
642 Returns : A list of definition references [array of [scalars]].
643 Args : Context. If omitted or equal to 'all', all dblinks
644 will be removed.
645 Note : deprecated method due to past use of mixed data types; use
646 remove_dblinks() instead, which handles both strings and
647 DBLink instances
649 =cut
651 sub remove_dblinks {
652 my ($self, $context) = @_;
653 $self->deprecated("use of remove_dblinks() is deprecated; use remove_dbxrefs() instead");
654 return $self->remove_dbxrefs(@_);
655 } # remove_dblinks
657 =head2 remove_dbxrefs
659 Title : remove_dbxrefs()
660 Usage : $term->remove_dbxrefs();
661 Function: Deletes (and returns) the definition references of this GO term.
662 Returns : A list of definition references [array of [scalars]].
663 Args : Context. If omitted or equal to 'all', all dblinks
664 will be removed.
666 =cut
668 sub remove_dbxrefs {
669 my ($self, $context) = @_;
670 $context = undef if $context && ($context eq "all");
671 my @old = $self->get_dbxrefs($context);
672 if (defined($context)) {
673 $self->{_dblinks}->{$context}=[];
674 } else {
675 $self->{_dblinks} = {};
677 return @old;
678 } # remove_dbxrefs
680 =head2 get_references
682 Title : get_references
683 Usage : @references = $self->get_references
684 Fuctnion: Returns a list of references
685 Return : A list of objects
686 Args : [none]
688 =cut
690 sub get_references {
691 my $self=shift;
692 return @{$self->{_references}} if exists $self->{_references};
693 return ();
696 =head2 add_reference
698 Title : add_reference
699 Usage : $self->add_reference($reference);
700 $self->add_reference($reference1, $reference2);
701 Fuctnion: Add one or more references
702 Returns : [none]
704 =cut
706 sub add_reference {
707 my ($self, @values) =@_;
708 return unless @values;
709 # avoid duplicates and undefs
710 foreach my $reference (@values){
711 $self->throw("Passed data not an Bio::Annotation::Reference") unless ref $reference &&
712 $reference->isa('Bio::AnnotationI');
713 next unless defined $reference;
714 next if grep{$_ eq $reference} @{$self->{_references}};
715 push @{$self->{_references}}, $reference;
719 =head2 remove_references
721 Title : remove_references
722 Usage : $self->remove_references;
723 Function: Deletes (and returns) all references
724 Returns : A list of references
725 Args : [none]
727 =cut
729 sub remove_references {
730 my $self=shift;
731 my @references=$self->get_references;
732 $self->{_references}=[];
733 return @references;
736 =head2 get_secondary_ids
738 Title : get_secondary_ids
739 Usage : @ids = $term->get_secondary_ids();
740 Function: Returns a list of secondary identifiers of this Term.
742 Secondary identifiers mostly originate from merging terms,
743 or possibly also from splitting terms.
745 Returns : A list of secondary identifiers [array of [scalar]]
746 Args :
748 =cut
750 sub get_secondary_ids {
751 my $self = shift;
753 return @{$self->{"_secondary_ids"}} if exists($self->{"_secondary_ids"});
754 return ();
755 } # get_secondary_ids
758 =head2 add_secondary_id
760 Title : add_secondary_id
761 Usage : $term->add_secondary_id( @ids );
763 $term->add_secondary_id( $id );
764 Function: Adds one or more secondary identifiers to this term.
765 Returns :
766 Args : One or more secondary identifiers [scalars]
768 =cut
770 sub add_secondary_id {
771 my $self = shift;
773 return unless @_;
775 # avoid duplicates
776 foreach my $id (@_) {
777 next if grep { !$_ or $_ eq $id; } @{$self->{ "_secondary_ids" }};
778 push( @{ $self->{ "_secondary_ids" } }, $id );
781 } # add_secondary_id
784 =head2 remove_secondary_ids
786 Title : remove_secondary_ids
787 Usage : $term->remove_secondary_ids();
788 Function: Deletes (and returns) the secondary identifiers of this Term.
789 Returns : The previous list of secondary identifiers [array of [scalars]]
790 Args :
792 =cut
794 sub remove_secondary_ids {
795 my $self = shift;
797 my @a = $self->get_secondary_ids();
798 $self->{ "_secondary_ids" } = [];
799 return @a;
801 } # remove_secondary_ids
804 # Title :_is_true_or_false
805 # Function: Checks whether the argument is TRUE or FALSE.
806 # Returns :
807 # Args : The value to be checked.
808 sub _is_true_or_false {
809 my ( $self, $value ) = @_;
810 unless ( $value !~ /\D/ && ( $value == TRUE || $value == FALSE ) ) {
811 $self->throw( "Found [" . $value
812 . "] where " . TRUE . " or " . FALSE . " expected" );
814 } # _is_true_or_false
816 =head1 Methods implementing L<Bio::IdentifiableI> and L<Bio::DescribableI>
818 =cut
820 =head2 object_id
822 Title : object_id
823 Usage : $string = $obj->object_id()
824 Function: a string which represents the stable primary identifier
825 in this namespace of this object.
827 This is a synonym for identifier().
829 Returns : A scalar
831 =cut
833 sub object_id {
834 return shift->identifier(@_);
837 =head2 authority
839 Title : authority
840 Usage : $authority = $obj->authority()
841 Function: a string which represents the organisation which
842 granted the namespace, written as the DNS name for
843 organisation (eg, wormbase.org)
845 This forwards to ontology()->authority(). Note that you
846 cannot set the authority before having set the ontology or
847 the namespace (which will set the ontology).
849 Returns : A scalar
850 Args : on set, the new value (a scalar)
852 =cut
854 sub authority {
855 my $self = shift;
856 my $ont = $self->ontology();
858 return $ont->authority(@_) if $ont;
859 $self->throw("cannot manipulate authority prior to ".
860 "setting the namespace or ontology") if @_;
861 return;
865 =head2 namespace
867 Title : namespace
868 Usage : $string = $obj->namespace()
869 Function: A string representing the name space this identifier
870 is valid in, often the database name or the name
871 describing the collection.
873 This forwards to ontology() (set mode) and
874 ontology()->name() (get mode). I.e., setting the namespace
875 will set the ontology to one matching that name in the
876 ontology store, or to one newly created.
878 Returns : A scalar
879 Args : on set, the new value (a scalar)
881 =cut
883 sub namespace {
884 my $self = shift;
886 $self->ontology(@_) if(@_);
887 my $ont = $self->ontology();
888 return defined($ont) ? $ont->name() : undef;
891 =head2 display_name
893 Title : display_name
894 Usage : $string = $obj->display_name()
895 Function: A string which is what should be displayed to the user.
897 The definition in Bio::DescribableI states that the
898 string should not contain spaces. As this is not very
899 sensible for ontology terms, we relax this here. The
900 implementation just forwards to name().
902 Returns : A scalar
903 Args : on set, the new value (a scalar)
905 =cut
907 sub display_name {
908 return shift->name(@_);
912 =head2 description
914 Title : description
915 Usage : $string = $obj->description()
916 Function: A text string suitable for displaying to the user a
917 description. This string is likely to have spaces, but
918 should not have any newlines or formatting - just plain
919 text.
921 This forwards to definition(). The caveat is that the text
922 will often be longer for ontology term definitions than the
923 255 characters stated in the definition in
924 Bio::DescribableI.
926 Returns : A scalar
927 Args : on set, the new value (a scalar)
929 =cut
931 sub description {
932 return shift->definition(@_);
935 #################################################################
936 # aliases or forwards to maintain backward compatibility
937 #################################################################
939 =head1 Deprecated methods
941 Used for looking up the methods that supersedes them.
943 =cut
945 sub each_dblink {shift->throw("use of each_dblink() is deprecated; use get_dbxrefs() instead")}
946 sub add_dblinks {shift->throw("use of add_dblinks() is deprecated; use add_dbxref() instead")}
947 *each_synonym = \&get_synonyms;
948 *add_synonyms = \&add_synonym;