Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Ontology/Term.pm @ 0:1f6dce3d34e0
Uploaded
| author | mahtabm |
|---|---|
| date | Thu, 11 Apr 2013 02:01:53 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1f6dce3d34e0 |
|---|---|
| 1 # $Id: Term.pm,v 1.8.2.3 2003/05/27 22:00:52 lapp Exp $ | |
| 2 # | |
| 3 # BioPerl module for Bio::Ontology::Term | |
| 4 # | |
| 5 # Cared for by Christian M. Zmasek <czmasek@gnf.org> or <cmzmasek@yahoo.com> | |
| 6 # | |
| 7 # (c) Christian M. Zmasek, czmasek@gnf.org, 2002. | |
| 8 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002. | |
| 9 # | |
| 10 # You may distribute this module under the same terms as perl itself. | |
| 11 # Refer to the Perl Artistic License (see the license accompanying this | |
| 12 # software package, or see http://www.perl.com/language/misc/Artistic.html) | |
| 13 # for the terms under which you may use, modify, and redistribute this module. | |
| 14 # | |
| 15 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | |
| 16 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | |
| 17 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
| 18 # | |
| 19 # You may distribute this module under the same terms as perl itself | |
| 20 | |
| 21 # POD documentation - main docs before the code | |
| 22 | |
| 23 | |
| 24 =head1 NAME | |
| 25 | |
| 26 Term - interface for ontology terms | |
| 27 | |
| 28 =head1 SYNOPSIS | |
| 29 | |
| 30 #get Bio::Ontology::TermI somehow. | |
| 31 | |
| 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"; | |
| 37 | |
| 38 foreach my $synonym ( $term->each_synonym() ) { | |
| 39 print $synonym, "\n"; | |
| 40 } | |
| 41 | |
| 42 =head1 DESCRIPTION | |
| 43 | |
| 44 This is "dumb" interface for ontology terms providing basic methods | |
| 45 (it provides no functionality related to graphs). It implements the | |
| 46 L<Bio::Ontology::TermI> interface. | |
| 47 | |
| 48 This class also implements L<Bio::IdentifiableI> and | |
| 49 L<Bio::DescribableI>. | |
| 50 | |
| 51 =head1 FEEDBACK | |
| 52 | |
| 53 =head2 Mailing Lists | |
| 54 | |
| 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. | |
| 58 | |
| 59 bioperl-l@bioperl.org - General discussion | |
| 60 http://bio.perl.org/MailList.html - About the mailing lists | |
| 61 | |
| 62 =head2 Reporting Bugs | |
| 63 | |
| 64 Report bugs to the Bioperl bug tracking system to help us keep track | |
| 65 the bugs and their resolution. Bug reports can be submitted via email | |
| 66 or the web: | |
| 67 | |
| 68 bioperl-bugs@bio.perl.org | |
| 69 http://bugzilla.bioperl.org/ | |
| 70 | |
| 71 =head1 AUTHOR | |
| 72 | |
| 73 Christian M. Zmasek | |
| 74 | |
| 75 Email: czmasek@gnf.org or cmzmasek@yahoo.com | |
| 76 | |
| 77 WWW: http://www.genetics.wustl.edu/eddy/people/zmasek/ | |
| 78 | |
| 79 Address: | |
| 80 | |
| 81 Genomics Institute of the Novartis Research Foundation | |
| 82 10675 John Jay Hopkins Drive | |
| 83 San Diego, CA 92121 | |
| 84 | |
| 85 =head1 APPENDIX | |
| 86 | |
| 87 The rest of the documentation details each of the object | |
| 88 methods. | |
| 89 | |
| 90 =cut | |
| 91 | |
| 92 | |
| 93 # Let the code begin... | |
| 94 | |
| 95 package Bio::Ontology::Term; | |
| 96 use vars qw( @ISA ); | |
| 97 use strict; | |
| 98 use Bio::Root::Object; | |
| 99 use Bio::Ontology::TermI; | |
| 100 use Bio::Ontology::Ontology; | |
| 101 use Bio::Ontology::OntologyStore; | |
| 102 use Bio::IdentifiableI; | |
| 103 use Bio::DescribableI; | |
| 104 | |
| 105 use constant TRUE => 1; | |
| 106 use constant FALSE => 0; | |
| 107 | |
| 108 @ISA = qw( Bio::Root::Root | |
| 109 Bio::Ontology::TermI | |
| 110 Bio::IdentifiableI | |
| 111 Bio::DescribableI | |
| 112 ); | |
| 113 | |
| 114 | |
| 115 | |
| 116 =head2 new | |
| 117 | |
| 118 Title : new | |
| 119 Usage : $term = Bio::Ontology::Term->new( -identifier => "16847", | |
| 120 -name => "1-aminocyclopropane-1-carboxylate synthase", | |
| 121 -definition => "Catalysis of ...", | |
| 122 -is_obsolete => 0, | |
| 123 -comment => "" ); | |
| 124 Function: Creates a new Bio::Ontology::Term. | |
| 125 Returns : A new Bio::Ontology::Term object. | |
| 126 Args : -identifier => the identifier of this term [scalar] | |
| 127 -name => the name of this term [scalar] | |
| 128 -definition => the definition of this term [scalar] | |
| 129 -ontology => the ontology this term lives in | |
| 130 (a L<Bio::Ontology::OntologyI> object) | |
| 131 -version => version information [scalar] | |
| 132 -is_obsolete => the obsoleteness of this term [0 or 1] | |
| 133 -comment => a comment [scalar] | |
| 134 | |
| 135 =cut | |
| 136 | |
| 137 sub new { | |
| 138 | |
| 139 my( $class,@args ) = @_; | |
| 140 | |
| 141 my $self = $class->SUPER::new( @args ); | |
| 142 | |
| 143 my ( $identifier, | |
| 144 $name, | |
| 145 $definition, | |
| 146 $category, | |
| 147 $ont, | |
| 148 $version, | |
| 149 $is_obsolete, | |
| 150 $comment, | |
| 151 $dblinks) | |
| 152 = $self->_rearrange( [ qw( IDENTIFIER | |
| 153 NAME | |
| 154 DEFINITION | |
| 155 CATEGORY | |
| 156 ONTOLOGY | |
| 157 VERSION | |
| 158 IS_OBSOLETE | |
| 159 COMMENT | |
| 160 DBLINKS | |
| 161 ) ], @args ); | |
| 162 | |
| 163 $self->init(); | |
| 164 | |
| 165 $identifier && $self->identifier( $identifier ); | |
| 166 $name && $self->name( $name ); | |
| 167 $definition && $self->definition( $definition ); | |
| 168 $category && $self->category( $category ); | |
| 169 $ont && $self->ontology( $ont ); | |
| 170 defined($version) && $self->version( $version ); | |
| 171 defined($is_obsolete) && $self->is_obsolete( $is_obsolete ); | |
| 172 $comment && $self->comment( $comment ); | |
| 173 ref($dblinks) && $self->add_dblink(@$dblinks); | |
| 174 | |
| 175 return $self; | |
| 176 | |
| 177 } # new | |
| 178 | |
| 179 | |
| 180 | |
| 181 sub init { | |
| 182 | |
| 183 my $self = shift; | |
| 184 | |
| 185 $self->identifier(undef); | |
| 186 $self->name(undef); | |
| 187 $self->comment(undef); | |
| 188 $self->definition(undef); | |
| 189 $self->ontology(undef); | |
| 190 $self->is_obsolete(0); | |
| 191 $self->remove_synonyms(); | |
| 192 $self->remove_dblinks(); | |
| 193 $self->remove_secondary_ids(); | |
| 194 | |
| 195 } # init | |
| 196 | |
| 197 | |
| 198 | |
| 199 =head2 identifier | |
| 200 | |
| 201 Title : identifier | |
| 202 Usage : $term->identifier( "0003947" ); | |
| 203 or | |
| 204 print $term->identifier(); | |
| 205 Function: Set/get for the identifier of this Term. | |
| 206 Returns : The identifier [scalar]. | |
| 207 Args : The identifier [scalar] (optional). | |
| 208 | |
| 209 =cut | |
| 210 | |
| 211 sub identifier { | |
| 212 my $self = shift; | |
| 213 | |
| 214 return $self->{'identifier'} = shift if @_; | |
| 215 return $self->{'identifier'}; | |
| 216 } # identifier | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 =head2 name | |
| 222 | |
| 223 Title : name | |
| 224 Usage : $term->name( "N-acetylgalactosaminyltransferase" ); | |
| 225 or | |
| 226 print $term->name(); | |
| 227 Function: Set/get for the name of this Term. | |
| 228 Returns : The name [scalar]. | |
| 229 Args : The name [scalar] (optional). | |
| 230 | |
| 231 =cut | |
| 232 | |
| 233 sub name { | |
| 234 my $self = shift; | |
| 235 | |
| 236 return $self->{'name'} = shift if @_; | |
| 237 return $self->{'name'}; | |
| 238 } # name | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 =head2 definition | |
| 245 | |
| 246 Title : definition | |
| 247 Usage : $term->definition( "Catalysis of ..." ); | |
| 248 or | |
| 249 print $term->definition(); | |
| 250 Function: Set/get for the definition of this Term. | |
| 251 Returns : The definition [scalar]. | |
| 252 Args : The definition [scalar] (optional). | |
| 253 | |
| 254 =cut | |
| 255 | |
| 256 sub definition { | |
| 257 my $self = shift; | |
| 258 | |
| 259 return $self->{'definition'} = shift if @_; | |
| 260 return $self->{'definition'}; | |
| 261 } # definition | |
| 262 | |
| 263 | |
| 264 =head2 ontology | |
| 265 | |
| 266 Title : ontology | |
| 267 Usage : $ont = $term->ontology(); | |
| 268 or | |
| 269 $term->ontology( $ont ); | |
| 270 Function: Get the ontology this term is in. | |
| 271 | |
| 272 Note that with the ontology in hand you can query for all | |
| 273 related terms etc. See L<Bio::Ontology::OntologyI>. | |
| 274 | |
| 275 Returns : The ontology of this Term as a L<Bio::Ontology::OntologyI> | |
| 276 implementing object. | |
| 277 Args : On set, the ontology of this Term as a L<Bio::Ontology::OntologyI> | |
| 278 implementing object or a string representing its name. | |
| 279 | |
| 280 =cut | |
| 281 | |
| 282 sub ontology { | |
| 283 my $self = shift; | |
| 284 my $ont; | |
| 285 | |
| 286 if(@_) { | |
| 287 $ont = shift; | |
| 288 if($ont) { | |
| 289 $ont = Bio::Ontology::Ontology->new(-name => $ont) if ! ref($ont); | |
| 290 if(! $ont->isa("Bio::Ontology::OntologyI")) { | |
| 291 $self->throw(ref($ont)." does not implement ". | |
| 292 "Bio::Ontology::OntologyI. Bummer."); | |
| 293 } | |
| 294 } | |
| 295 return $self->{"_ontology"} = $ont; | |
| 296 } | |
| 297 return $self->{"_ontology"}; | |
| 298 } # ontology | |
| 299 | |
| 300 | |
| 301 =head2 version | |
| 302 | |
| 303 Title : version | |
| 304 Usage : $term->version( "1.00" ); | |
| 305 or | |
| 306 print $term->version(); | |
| 307 Function: Set/get for version information. | |
| 308 Returns : The version [scalar]. | |
| 309 Args : The version [scalar] (optional). | |
| 310 | |
| 311 =cut | |
| 312 | |
| 313 sub version { | |
| 314 my $self = shift; | |
| 315 | |
| 316 return $self->{'version'} = shift if @_; | |
| 317 return $self->{'version'}; | |
| 318 } # version | |
| 319 | |
| 320 | |
| 321 | |
| 322 =head2 is_obsolete | |
| 323 | |
| 324 Title : is_obsolete | |
| 325 Usage : $term->is_obsolete( 1 ); | |
| 326 or | |
| 327 if ( $term->is_obsolete() ) | |
| 328 Function: Set/get for the obsoleteness of this Term. | |
| 329 Returns : the obsoleteness [0 or 1]. | |
| 330 Args : the obsoleteness [0 or 1] (optional). | |
| 331 | |
| 332 =cut | |
| 333 | |
| 334 sub is_obsolete{ | |
| 335 my $self = shift; | |
| 336 | |
| 337 return $self->{'is_obsolete'} = shift if @_; | |
| 338 return $self->{'is_obsolete'}; | |
| 339 } # is_obsolete | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 =head2 comment | |
| 346 | |
| 347 Title : comment | |
| 348 Usage : $term->comment( "Consider the term ..." ); | |
| 349 or | |
| 350 print $term->comment(); | |
| 351 Function: Set/get for an arbitrary comment about this Term. | |
| 352 Returns : A comment. | |
| 353 Args : A comment (optional). | |
| 354 | |
| 355 =cut | |
| 356 | |
| 357 sub comment{ | |
| 358 my $self = shift; | |
| 359 | |
| 360 return $self->{'comment'} = shift if @_; | |
| 361 return $self->{'comment'}; | |
| 362 } # comment | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 =head2 get_synonyms | |
| 368 | |
| 369 Title : get_synonyms | |
| 370 Usage : @aliases = $term->get_synonyms; | |
| 371 Function: Returns a list of aliases of this Term. | |
| 372 Returns : A list of aliases [array of [scalar]]. | |
| 373 Args : | |
| 374 | |
| 375 =cut | |
| 376 | |
| 377 sub get_synonyms { | |
| 378 my $self = shift; | |
| 379 | |
| 380 return @{ $self->{ "_synonyms" } } if exists($self->{ "_synonyms" }); | |
| 381 return (); | |
| 382 } # get_synonyms | |
| 383 | |
| 384 | |
| 385 =head2 add_synonym | |
| 386 | |
| 387 Title : add_synonym | |
| 388 Usage : $term->add_synonym( @asynonyms ); | |
| 389 or | |
| 390 $term->add_synonym( $synonym ); | |
| 391 Function: Pushes one or more synonyms into the list of synonyms. | |
| 392 Returns : | |
| 393 Args : One synonym [scalar] or a list of synonyms [array of [scalar]]. | |
| 394 | |
| 395 =cut | |
| 396 | |
| 397 sub add_synonym { | |
| 398 my ( $self, @values ) = @_; | |
| 399 | |
| 400 return unless( @values ); | |
| 401 | |
| 402 # avoid duplicates | |
| 403 foreach my $syn (@values) { | |
| 404 next if grep { $_ eq $syn; } @{$self->{ "_synonyms" }}; | |
| 405 push( @{ $self->{ "_synonyms" } }, $syn ); | |
| 406 } | |
| 407 | |
| 408 } # add_synonym | |
| 409 | |
| 410 | |
| 411 =head2 remove_synonyms | |
| 412 | |
| 413 Title : remove_synonyms() | |
| 414 Usage : $term->remove_synonyms(); | |
| 415 Function: Deletes (and returns) the synonyms of this Term. | |
| 416 Returns : A list of synonyms [array of [scalar]]. | |
| 417 Args : | |
| 418 | |
| 419 =cut | |
| 420 | |
| 421 sub remove_synonyms { | |
| 422 my ( $self ) = @_; | |
| 423 | |
| 424 my @a = $self->get_synonyms(); | |
| 425 $self->{ "_synonyms" } = []; | |
| 426 return @a; | |
| 427 | |
| 428 } # remove_synonyms | |
| 429 | |
| 430 =head2 get_dblinks | |
| 431 | |
| 432 Title : get_dblinks() | |
| 433 Usage : @ds = $term->get_dblinks(); | |
| 434 Function: Returns a list of each dblinks of this GO term. | |
| 435 Returns : A list of dblinks [array of [scalars]]. | |
| 436 Args : | |
| 437 | |
| 438 =cut | |
| 439 | |
| 440 sub get_dblinks { | |
| 441 my $self = shift; | |
| 442 | |
| 443 return @{$self->{ "_dblinks" }} if exists($self->{ "_dblinks" }); | |
| 444 return (); | |
| 445 } # get_dblinks | |
| 446 | |
| 447 | |
| 448 =head2 add_dblink | |
| 449 | |
| 450 Title : add_dblink | |
| 451 Usage : $term->add_dblink( @dbls ); | |
| 452 or | |
| 453 $term->add_dblink( $dbl ); | |
| 454 Function: Pushes one or more dblinks onto the list of dblinks. | |
| 455 Returns : | |
| 456 Args : One dblink [scalar] or a list of | |
| 457 dblinks [array of [scalars]]. | |
| 458 | |
| 459 =cut | |
| 460 | |
| 461 sub add_dblink { | |
| 462 my ( $self, @values ) = @_; | |
| 463 | |
| 464 return unless( @values ); | |
| 465 | |
| 466 # avoid duplicates | |
| 467 foreach my $dbl (@values) { | |
| 468 next if grep { $_ eq $dbl; } @{$self->{ "_dblinks" }}; | |
| 469 push( @{ $self->{ "_dblinks" } }, $dbl ); | |
| 470 } | |
| 471 | |
| 472 } # add_dblink | |
| 473 | |
| 474 | |
| 475 =head2 remove_dblinks | |
| 476 | |
| 477 Title : remove_dblinks() | |
| 478 Usage : $term->remove_dblinks(); | |
| 479 Function: Deletes (and returns) the definition references of this GO term. | |
| 480 Returns : A list of definition references [array of [scalars]]. | |
| 481 Args : | |
| 482 | |
| 483 =cut | |
| 484 | |
| 485 sub remove_dblinks { | |
| 486 my ( $self ) = @_; | |
| 487 | |
| 488 my @a = $self->get_dblinks(); | |
| 489 $self->{ "_dblinks" } = []; | |
| 490 return @a; | |
| 491 | |
| 492 } # remove_dblinks | |
| 493 | |
| 494 =head2 get_secondary_ids | |
| 495 | |
| 496 Title : get_secondary_ids | |
| 497 Usage : @ids = $term->get_secondary_ids(); | |
| 498 Function: Returns a list of secondary identifiers of this Term. | |
| 499 | |
| 500 Secondary identifiers mostly originate from merging terms, | |
| 501 or possibly also from splitting terms. | |
| 502 | |
| 503 Returns : A list of secondary identifiers [array of [scalar]] | |
| 504 Args : | |
| 505 | |
| 506 =cut | |
| 507 | |
| 508 sub get_secondary_ids { | |
| 509 my $self = shift; | |
| 510 | |
| 511 return @{$self->{"_secondary_ids"}} if exists($self->{"_secondary_ids"}); | |
| 512 return (); | |
| 513 } # get_secondary_ids | |
| 514 | |
| 515 | |
| 516 =head2 add_secondary_id | |
| 517 | |
| 518 Title : add_secondary_id | |
| 519 Usage : $term->add_secondary_id( @ids ); | |
| 520 or | |
| 521 $term->add_secondary_id( $id ); | |
| 522 Function: Adds one or more secondary identifiers to this term. | |
| 523 Returns : | |
| 524 Args : One or more secondary identifiers [scalars] | |
| 525 | |
| 526 =cut | |
| 527 | |
| 528 sub add_secondary_id { | |
| 529 my $self = shift; | |
| 530 | |
| 531 return unless @_; | |
| 532 | |
| 533 # avoid duplicates | |
| 534 foreach my $id (@_) { | |
| 535 next if grep { $_ eq $id; } @{$self->{ "_secondary_ids" }}; | |
| 536 push( @{ $self->{ "_secondary_ids" } }, $id ); | |
| 537 } | |
| 538 | |
| 539 } # add_secondary_id | |
| 540 | |
| 541 | |
| 542 =head2 remove_secondary_ids | |
| 543 | |
| 544 Title : remove_secondary_ids | |
| 545 Usage : $term->remove_secondary_ids(); | |
| 546 Function: Deletes (and returns) the secondary identifiers of this Term. | |
| 547 Returns : The previous list of secondary identifiers [array of [scalars]] | |
| 548 Args : | |
| 549 | |
| 550 =cut | |
| 551 | |
| 552 sub remove_secondary_ids { | |
| 553 my $self = shift; | |
| 554 | |
| 555 my @a = $self->get_secondary_ids(); | |
| 556 $self->{ "_secondary_ids" } = []; | |
| 557 return @a; | |
| 558 | |
| 559 } # remove_secondary_ids | |
| 560 | |
| 561 | |
| 562 # Title :_is_true_or_false | |
| 563 # Function: Checks whether the argument is TRUE or FALSE. | |
| 564 # Returns : | |
| 565 # Args : The value to be checked. | |
| 566 sub _is_true_or_false { | |
| 567 my ( $self, $value ) = @_; | |
| 568 unless ( $value !~ /\D/ && ( $value == TRUE || $value == FALSE ) ) { | |
| 569 $self->throw( "Found [" . $value | |
| 570 . "] where " . TRUE . " or " . FALSE . " expected" ); | |
| 571 } | |
| 572 } # _is_true_or_false | |
| 573 | |
| 574 =head1 Methods implementing L<Bio::IdentifiableI> and L<Bio::DescribableI> | |
| 575 | |
| 576 =cut | |
| 577 | |
| 578 =head2 object_id | |
| 579 | |
| 580 Title : object_id | |
| 581 Usage : $string = $obj->object_id() | |
| 582 Function: a string which represents the stable primary identifier | |
| 583 in this namespace of this object. | |
| 584 | |
| 585 This is a synonym for identifier(). | |
| 586 | |
| 587 Returns : A scalar | |
| 588 | |
| 589 =cut | |
| 590 | |
| 591 sub object_id { | |
| 592 return shift->identifier(@_); | |
| 593 } | |
| 594 | |
| 595 =head2 authority | |
| 596 | |
| 597 Title : authority | |
| 598 Usage : $authority = $obj->authority() | |
| 599 Function: a string which represents the organisation which | |
| 600 granted the namespace, written as the DNS name for | |
| 601 organisation (eg, wormbase.org) | |
| 602 | |
| 603 This forwards to ontology()->authority(). Note that you | |
| 604 cannot set the authority before having set the ontology or | |
| 605 the namespace (which will set the ontology). | |
| 606 | |
| 607 Returns : A scalar | |
| 608 Args : on set, the new value (a scalar) | |
| 609 | |
| 610 =cut | |
| 611 | |
| 612 sub authority { | |
| 613 my $self = shift; | |
| 614 my $ont = $self->ontology(); | |
| 615 | |
| 616 return $ont->authority(@_) if $ont; | |
| 617 $self->throw("cannot manipulate authority prior to ". | |
| 618 "setting the namespace or ontology") if @_; | |
| 619 return undef; | |
| 620 } | |
| 621 | |
| 622 | |
| 623 =head2 namespace | |
| 624 | |
| 625 Title : namespace | |
| 626 Usage : $string = $obj->namespace() | |
| 627 Function: A string representing the name space this identifier | |
| 628 is valid in, often the database name or the name | |
| 629 describing the collection. | |
| 630 | |
| 631 This forwards to ontology() (set mode) and | |
| 632 ontology()->name() (get mode). I.e., setting the namespace | |
| 633 will set the ontology to one matching that name in the | |
| 634 ontology store, or to one newly created. | |
| 635 | |
| 636 Returns : A scalar | |
| 637 Args : on set, the new value (a scalar) | |
| 638 | |
| 639 =cut | |
| 640 | |
| 641 sub namespace { | |
| 642 my $self = shift; | |
| 643 | |
| 644 $self->ontology(@_) if(@_); | |
| 645 my $ont = $self->ontology(); | |
| 646 return defined($ont) ? $ont->name() : undef; | |
| 647 } | |
| 648 | |
| 649 =head2 display_name | |
| 650 | |
| 651 Title : display_name | |
| 652 Usage : $string = $obj->display_name() | |
| 653 Function: A string which is what should be displayed to the user. | |
| 654 | |
| 655 The definition in L<Bio::DescribableI> states that the | |
| 656 string should not contain spaces. As this isn't very | |
| 657 sensible for ontology terms, we relax this here. The | |
| 658 implementation just forwards to name(). | |
| 659 | |
| 660 Returns : A scalar | |
| 661 Args : on set, the new value (a scalar) | |
| 662 | |
| 663 =cut | |
| 664 | |
| 665 sub display_name { | |
| 666 return shift->name(@_); | |
| 667 } | |
| 668 | |
| 669 | |
| 670 =head2 description | |
| 671 | |
| 672 Title : description | |
| 673 Usage : $string = $obj->description() | |
| 674 Function: A text string suitable for displaying to the user a | |
| 675 description. This string is likely to have spaces, but | |
| 676 should not have any newlines or formatting - just plain | |
| 677 text. | |
| 678 | |
| 679 This forwards to definition(). The caveat is that the text | |
| 680 will often be longer for ontology term definitions than the | |
| 681 255 characters stated in the definition in | |
| 682 L<Bio::DescribableI>. | |
| 683 | |
| 684 Returns : A scalar | |
| 685 Args : on set, the new value (a scalar) | |
| 686 | |
| 687 =cut | |
| 688 | |
| 689 sub description { | |
| 690 return shift->definition(@_); | |
| 691 } | |
| 692 | |
| 693 ################################################################# | |
| 694 # aliases or forwards to maintain backward compatibility | |
| 695 ################################################################# | |
| 696 | |
| 697 =head1 Deprecated methods | |
| 698 | |
| 699 Used for looking up the methods that supercedes them. | |
| 700 | |
| 701 =cut | |
| 702 | |
| 703 =head2 category | |
| 704 | |
| 705 Title : category | |
| 706 Usage : | |
| 707 Function: This method is deprecated. Use ontology() instead. | |
| 708 Example : | |
| 709 Returns : | |
| 710 Args : | |
| 711 | |
| 712 | |
| 713 =cut | |
| 714 | |
| 715 sub category { | |
| 716 my $self = shift; | |
| 717 | |
| 718 $self->warn("TermI::category is deprecated and being phased out. ". | |
| 719 "Use TermI::ontology instead."); | |
| 720 | |
| 721 # called in set mode? | |
| 722 if(@_) { | |
| 723 # yes; what is incompatible with ontology() is if we were given | |
| 724 # a TermI object | |
| 725 my $arg = shift; | |
| 726 $arg = $arg->name() if ref($arg) && $arg->isa("Bio::Ontology::TermI"); | |
| 727 return $self->ontology($arg,@_); | |
| 728 } else { | |
| 729 # No, called in get mode. This is always incompatible with ontology() | |
| 730 # since category is supposed to return a TermI. | |
| 731 my $ont = $self->ontology(); | |
| 732 my $term; | |
| 733 if(defined($ont)) { | |
| 734 $term = Bio::Ontology::Term->new(-name => $ont->name(), | |
| 735 -identifier =>$ont->identifier()); | |
| 736 } | |
| 737 return $term; | |
| 738 } | |
| 739 } # category | |
| 740 | |
| 741 *each_synonym = \&get_synonyms; | |
| 742 *add_synonyms = \&add_synonym; | |
| 743 *each_dblink = \&get_dblinks; | |
| 744 *add_dblinks = \&add_dblink; | |
| 745 | |
| 746 1; |
