Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Ontology/InterProTerm.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: InterProTerm.pm,v 1.4.2.2 2003/03/25 12:32:16 heikki Exp $ | |
| 2 # | |
| 3 # BioPerl module for Bio::Ontology::InterProTerm | |
| 4 # | |
| 5 # Cared for by Peter Dimitrov <dimitrov@gnf.org> | |
| 6 # | |
| 7 # Copyright Peter Dimitrov | |
| 8 # (c) Peter Dimitrov, dimitrov@gnf.org, 2002. | |
| 9 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002. | |
| 10 # | |
| 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. | |
| 15 # | |
| 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. | |
| 19 # | |
| 20 # POD documentation - main docs before the code | |
| 21 | |
| 22 =head1 NAME | |
| 23 | |
| 24 InterProTerm - Implementation of InterProI term interface | |
| 25 | |
| 26 =head1 SYNOPSIS | |
| 27 | |
| 28 my $term = Bio::Ontology::InterProTerm->new( -interpro_id => "IPR000001", | |
| 29 -name => "Kringle", | |
| 30 -definition => "Kringles are autonomous structural domains ...", | |
| 31 -ontology => "Domain" | |
| 32 ); | |
| 33 print $term->interpro_id(), "\n"; | |
| 34 print $term->name(), "\n"; | |
| 35 print $term->definition(), "\n"; | |
| 36 print $term->is_obsolete(), "\n"; | |
| 37 print $term->ontology->name(), "\n"; | |
| 38 | |
| 39 =head1 DESCRIPTION | |
| 40 | |
| 41 This is a simple extension of L<Bio::Ontology::Term> for InterPro terms. | |
| 42 | |
| 43 =head1 FEEDBACK | |
| 44 | |
| 45 =head2 Mailing Lists | |
| 46 | |
| 47 User feedback is an integral part of the evolution of this and other | |
| 48 Bioperl modules. Send your comments and suggestions preferably to | |
| 49 the Bioperl mailing list. Your participation is much appreciated. | |
| 50 | |
| 51 bioperl-l@bioperl.org - General discussion | |
| 52 http://bioperl.org/MailList.shtml - About the mailing lists | |
| 53 | |
| 54 =head2 Reporting Bugs | |
| 55 | |
| 56 Report bugs to the Bioperl bug tracking system to help us keep track | |
| 57 of the bugs and their resolution. Bug reports can be submitted via | |
| 58 email or the web: | |
| 59 | |
| 60 bioperl-bugs@bioperl.org | |
| 61 http://bugzilla.bioperl.org/ | |
| 62 | |
| 63 =head1 AUTHOR - Peter Dimitrov | |
| 64 | |
| 65 Email dimitrov@gnf.org | |
| 66 | |
| 67 =head1 CONTRIBUTORS | |
| 68 | |
| 69 Additional contributors names and emails here | |
| 70 | |
| 71 =head1 APPENDIX | |
| 72 | |
| 73 The rest of the documentation details each of the object methods. | |
| 74 Internal methods are usually preceded with a _ | |
| 75 | |
| 76 =cut | |
| 77 | |
| 78 | |
| 79 # Let the code begin... | |
| 80 | |
| 81 | |
| 82 package Bio::Ontology::InterProTerm; | |
| 83 use vars qw(@ISA); | |
| 84 use strict; | |
| 85 | |
| 86 use Bio::Ontology::Term; | |
| 87 use Bio::Annotation::Reference; | |
| 88 | |
| 89 use constant INTERPRO_ID_DEFAULT => "IPR000000"; | |
| 90 | |
| 91 @ISA = qw( Bio::Ontology::Term ); | |
| 92 | |
| 93 =head2 new | |
| 94 | |
| 95 Title : new | |
| 96 Usage : $term = Bio::Ontology::InterProTerm->new( -interpro_id => "IPR000002", | |
| 97 -name => "Cdc20/Fizzy", | |
| 98 -definition => "The Cdc20/Fizzy region is almost always ...", | |
| 99 -ontology => "Domain" | |
| 100 ); | |
| 101 | |
| 102 Function: Creates a new Bio::Ontology::InterProTerm. | |
| 103 Example : | |
| 104 Returns : A new Bio::Ontology::InterProTerm object. | |
| 105 Args : | |
| 106 -interpro_id => the InterPro ID of the term. Has the form IPRdddddd, where dddddd is a zero-padded six digit number | |
| 107 -name => the name of this InterPro term [scalar] | |
| 108 -definition => the definition/abstract of this InterPro term [scalar] | |
| 109 -ontology => ontology of InterPro terms [Bio::Ontology::OntologyI] | |
| 110 -comment => a comment [scalar] | |
| 111 | |
| 112 =cut | |
| 113 | |
| 114 sub new{ | |
| 115 my ($class, @args) = @_; | |
| 116 my $self = $class->SUPER::new(@args); | |
| 117 | |
| 118 my ( $interpro_id, | |
| 119 $short_name) | |
| 120 = $self->_rearrange( [qw( INTERPRO_ID | |
| 121 SHORT_NAME | |
| 122 ) | |
| 123 ], @args ); | |
| 124 | |
| 125 $interpro_id && $self->interpro_id( $interpro_id ); | |
| 126 $short_name && $self->short_name( $short_name ); | |
| 127 | |
| 128 return $self; | |
| 129 } | |
| 130 | |
| 131 =head2 init | |
| 132 | |
| 133 Title : init | |
| 134 Usage : $term->init(); | |
| 135 Function: Initializes this InterProTerm to all "" and empty lists. | |
| 136 Example : | |
| 137 Returns : | |
| 138 Args : | |
| 139 | |
| 140 | |
| 141 =cut | |
| 142 | |
| 143 sub init{ | |
| 144 my $self = shift; | |
| 145 | |
| 146 # first call the inherited version to properly chain up the hierarchy | |
| 147 $self->SUPER::init(@_); | |
| 148 | |
| 149 # then only initialize what we implement ourselves here | |
| 150 $self->interpro_id( INTERPRO_ID_DEFAULT ); | |
| 151 $self->short_name(""); | |
| 152 | |
| 153 } | |
| 154 | |
| 155 =head2 _check_interpro_id | |
| 156 | |
| 157 Title : _check_interpro_id | |
| 158 Usage : | |
| 159 Function: Performs simple check in order to validate that its argument has the form IPRdddddd, where dddddd is a zero-padded six digit number. | |
| 160 Example : | |
| 161 Returns : Returns its argument if valid, otherwise throws exception. | |
| 162 Args : String | |
| 163 | |
| 164 | |
| 165 =cut | |
| 166 | |
| 167 sub _check_interpro_id{ | |
| 168 my ($self, $value) = @_; | |
| 169 | |
| 170 $self->throw( "InterPro ID ".$value." is incorrect\n" ) | |
| 171 unless ( $value =~ /^IPR\d{6}$/ || | |
| 172 $value eq INTERPRO_ID_DEFAULT ); | |
| 173 | |
| 174 return $value; | |
| 175 } | |
| 176 | |
| 177 =head2 interpro_id | |
| 178 | |
| 179 Title : interpro_id | |
| 180 Usage : $obj->interpro_id($newval) | |
| 181 Function: Set/get for the interpro_id of this InterProTerm | |
| 182 Example : | |
| 183 Returns : value of interpro_id (a scalar) | |
| 184 Args : new value (a scalar, optional) | |
| 185 | |
| 186 | |
| 187 =cut | |
| 188 | |
| 189 sub interpro_id{ | |
| 190 my ($self, $value) = @_; | |
| 191 | |
| 192 if( defined $value) { | |
| 193 $value = $self->_check_interpro_id($value); | |
| 194 } | |
| 195 | |
| 196 return $self->identifier($value); | |
| 197 } | |
| 198 | |
| 199 =head2 short_name | |
| 200 | |
| 201 Title : short_name | |
| 202 Usage : $obj->short_name($newval) | |
| 203 Function: Set/get for the short name of this InterProTerm. | |
| 204 Example : | |
| 205 Returns : value of short_name (a scalar) | |
| 206 Args : new value (a scalar, optional) | |
| 207 | |
| 208 | |
| 209 =cut | |
| 210 | |
| 211 sub short_name{ | |
| 212 my ($self, $value) = @_; | |
| 213 | |
| 214 if( defined $value) { | |
| 215 $self->{'short_name'} = $value ? $value : undef; | |
| 216 } | |
| 217 | |
| 218 return $self->{'short_name'}; | |
| 219 } | |
| 220 | |
| 221 =head2 protein_count | |
| 222 | |
| 223 Title : protein_count | |
| 224 Usage : $obj->protein_count($newval) | |
| 225 Function: Set/get for the protein count of this InterProTerm. | |
| 226 Example : | |
| 227 Returns : value of protein_count (a scalar) | |
| 228 Args : new value (a scalar, optional) | |
| 229 | |
| 230 | |
| 231 =cut | |
| 232 | |
| 233 sub protein_count{ | |
| 234 my ($self,$value) = @_; | |
| 235 | |
| 236 if( defined $value) { | |
| 237 $self->{'protein_count'} = $value ? $value : undef; | |
| 238 } | |
| 239 | |
| 240 return $self->{'protein_count'}; | |
| 241 } | |
| 242 | |
| 243 =head2 get_references | |
| 244 | |
| 245 Title : get_references | |
| 246 Usage : | |
| 247 Function: Get the references for this InterPro term. | |
| 248 Example : | |
| 249 Returns : An array of L<Bio::Annotation::Reference> objects | |
| 250 Args : | |
| 251 | |
| 252 | |
| 253 =cut | |
| 254 | |
| 255 sub get_references{ | |
| 256 my $self = shift; | |
| 257 | |
| 258 return @{$self->{"_references"}} if exists($self->{"_references"}); | |
| 259 return (); | |
| 260 } | |
| 261 | |
| 262 =head2 add_reference | |
| 263 | |
| 264 Title : add_reference | |
| 265 Usage : | |
| 266 Function: Add one or more references to this InterPro term. | |
| 267 Example : | |
| 268 Returns : | |
| 269 Args : One or more L<Bio::Annotation::Reference> objects. | |
| 270 | |
| 271 | |
| 272 =cut | |
| 273 | |
| 274 sub add_reference{ | |
| 275 my $self = shift; | |
| 276 | |
| 277 $self->{"_references"} = [] unless exists($self->{"_references"}); | |
| 278 push(@{$self->{"_references"}}, @_); | |
| 279 } | |
| 280 | |
| 281 =head2 remove_references | |
| 282 | |
| 283 Title : remove_references | |
| 284 Usage : | |
| 285 Function: Remove all references for this InterPro term. | |
| 286 Example : | |
| 287 Returns : The list of previous references as an array of | |
| 288 L<Bio::Annotation::Reference> objects. | |
| 289 Args : | |
| 290 | |
| 291 | |
| 292 =cut | |
| 293 | |
| 294 sub remove_references{ | |
| 295 my $self = shift; | |
| 296 | |
| 297 my @arr = $self->get_references(); | |
| 298 $self->{"_references"} = []; | |
| 299 return @arr; | |
| 300 } | |
| 301 | |
| 302 =head2 get_members | |
| 303 | |
| 304 Title : get_members | |
| 305 Usage : @arr = get_members() | |
| 306 Function: Get the list of member(s) for this object. | |
| 307 Example : | |
| 308 Returns : An array of Bio::Annotation::DBLink objects | |
| 309 Args : | |
| 310 | |
| 311 | |
| 312 =cut | |
| 313 | |
| 314 sub get_members{ | |
| 315 my $self = shift; | |
| 316 | |
| 317 return @{$self->{'_members'}} if exists($self->{'_members'}); | |
| 318 return (); | |
| 319 } | |
| 320 | |
| 321 =head2 add_member | |
| 322 | |
| 323 Title : add_member | |
| 324 Usage : | |
| 325 Function: Add one or more member(s) to this object. | |
| 326 Example : | |
| 327 Returns : | |
| 328 Args : One or more Bio::Annotation::DBLink objects. | |
| 329 | |
| 330 | |
| 331 =cut | |
| 332 | |
| 333 sub add_member{ | |
| 334 my $self = shift; | |
| 335 | |
| 336 $self->{'_members'} = [] unless exists($self->{'_members'}); | |
| 337 push(@{$self->{'_members'}}, @_); | |
| 338 } | |
| 339 | |
| 340 =head2 remove_members | |
| 341 | |
| 342 Title : remove_members | |
| 343 Usage : | |
| 344 Function: Remove all members for this class. | |
| 345 Example : | |
| 346 Returns : The list of previous members as an array of | |
| 347 Bio::Annotation::DBLink objects. | |
| 348 Args : | |
| 349 | |
| 350 | |
| 351 =cut | |
| 352 | |
| 353 sub remove_members{ | |
| 354 my $self = shift; | |
| 355 | |
| 356 my @arr = $self->get_members(); | |
| 357 $self->{'_members'} = []; | |
| 358 return @arr; | |
| 359 } | |
| 360 | |
| 361 =head2 get_examples | |
| 362 | |
| 363 Title : get_examples | |
| 364 Usage : @arr = get_examples() | |
| 365 Function: Get the list of example(s) for this object. | |
| 366 | |
| 367 This is an element of the InterPro xml schema. | |
| 368 | |
| 369 Example : | |
| 370 Returns : An array of Bio::Annotation::DBLink objects | |
| 371 Args : | |
| 372 | |
| 373 | |
| 374 =cut | |
| 375 | |
| 376 sub get_examples{ | |
| 377 my $self = shift; | |
| 378 | |
| 379 return @{$self->{'_examples'}} if exists($self->{'_examples'}); | |
| 380 return (); | |
| 381 } | |
| 382 | |
| 383 =head2 add_example | |
| 384 | |
| 385 Title : add_example | |
| 386 Usage : | |
| 387 Function: Add one or more example(s) to this object. | |
| 388 | |
| 389 This is an element of the InterPro xml schema. | |
| 390 | |
| 391 Example : | |
| 392 Returns : | |
| 393 Args : One or more Bio::Annotation::DBLink objects. | |
| 394 | |
| 395 | |
| 396 =cut | |
| 397 | |
| 398 sub add_example{ | |
| 399 my $self = shift; | |
| 400 | |
| 401 $self->{'_examples'} = [] unless exists($self->{'_examples'}); | |
| 402 push(@{$self->{'_examples'}}, @_); | |
| 403 } | |
| 404 | |
| 405 =head2 remove_examples | |
| 406 | |
| 407 Title : remove_examples | |
| 408 Usage : | |
| 409 Function: Remove all examples for this class. | |
| 410 | |
| 411 This is an element of the InterPro xml schema. | |
| 412 | |
| 413 Example : | |
| 414 Returns : The list of previous examples as an array of | |
| 415 Bio::Annotation::DBLink objects. | |
| 416 Args : | |
| 417 | |
| 418 | |
| 419 =cut | |
| 420 | |
| 421 sub remove_examples{ | |
| 422 my $self = shift; | |
| 423 | |
| 424 my @arr = $self->get_examples(); | |
| 425 $self->{'_examples'} = []; | |
| 426 return @arr; | |
| 427 } | |
| 428 | |
| 429 =head2 get_external_documents | |
| 430 | |
| 431 Title : get_external_documents | |
| 432 Usage : @arr = get_external_documents() | |
| 433 Function: Get the list of external_document(s) for this object. | |
| 434 | |
| 435 This is an element of the InterPro xml schema. | |
| 436 | |
| 437 Example : | |
| 438 Returns : An array of Bio::Annotation::DBLink objects | |
| 439 Args : | |
| 440 | |
| 441 | |
| 442 =cut | |
| 443 | |
| 444 sub get_external_documents{ | |
| 445 my $self = shift; | |
| 446 | |
| 447 return @{$self->{'_external_documents'}} if exists($self->{'_external_documents'}); | |
| 448 return (); | |
| 449 } | |
| 450 | |
| 451 =head2 add_external_document | |
| 452 | |
| 453 Title : add_external_document | |
| 454 Usage : | |
| 455 Function: Add one or more external_document(s) to this object. | |
| 456 | |
| 457 This is an element of the InterPro xml schema. | |
| 458 | |
| 459 Example : | |
| 460 Returns : | |
| 461 Args : One or more Bio::Annotation::DBLink objects. | |
| 462 | |
| 463 | |
| 464 =cut | |
| 465 | |
| 466 sub add_external_document{ | |
| 467 my $self = shift; | |
| 468 | |
| 469 $self->{'_external_documents'} = [] unless exists($self->{'_external_documents'}); | |
| 470 push(@{$self->{'_external_documents'}}, @_); | |
| 471 } | |
| 472 | |
| 473 =head2 remove_external_documents | |
| 474 | |
| 475 Title : remove_external_documents | |
| 476 Usage : | |
| 477 Function: Remove all external_documents for this class. | |
| 478 | |
| 479 This is an element of the InterPro xml schema. | |
| 480 | |
| 481 Example : | |
| 482 Returns : The list of previous external_documents as an array of | |
| 483 Bio::Annotation::DBLink objects. | |
| 484 Args : | |
| 485 | |
| 486 | |
| 487 =cut | |
| 488 | |
| 489 sub remove_external_documents{ | |
| 490 my $self = shift; | |
| 491 | |
| 492 my @arr = $self->get_external_documents(); | |
| 493 $self->{'_external_documents'} = []; | |
| 494 return @arr; | |
| 495 } | |
| 496 | |
| 497 =head2 class_list | |
| 498 | |
| 499 Title : class_list | |
| 500 Usage : $obj->class_list($newval) | |
| 501 Function: Set/get for class list element of the InterPro xml schema | |
| 502 Example : | |
| 503 Returns : reference to an array of Bio::Annotation::DBLink objects | |
| 504 Args : reference to an array of Bio::Annotation::DBLink objects | |
| 505 | |
| 506 | |
| 507 =cut | |
| 508 | |
| 509 sub class_list{ | |
| 510 my ($self, $value) = @_; | |
| 511 | |
| 512 if( defined $value) { | |
| 513 $self->{'class_list'} = $value; | |
| 514 } | |
| 515 | |
| 516 return $self->{'class_list'}; | |
| 517 } | |
| 518 | |
| 519 =head2 to_string | |
| 520 | |
| 521 Title : to_string() | |
| 522 Usage : print $term->to_string(); | |
| 523 Function: to_string method for InterPro terms. | |
| 524 Returns : A string representation of this InterPro term. | |
| 525 Args : | |
| 526 | |
| 527 =cut | |
| 528 | |
| 529 sub to_string { | |
| 530 my($self) = @_; | |
| 531 my $s = ""; | |
| 532 | |
| 533 $s .= "-- InterPro id:\n"; | |
| 534 $s .= $self->interpro_id()."\n"; | |
| 535 if (defined $self->name) { | |
| 536 $s .= "-- Name:\n"; | |
| 537 $s .= $self->name()."\n"; | |
| 538 $s .= "-- Definition:\n"; | |
| 539 $s .= $self->definition()."\n"; | |
| 540 $s .= "-- Category:\n"; | |
| 541 if ( defined( $self->ontology() ) ) { | |
| 542 $s .= $self->ontology()->name()."\n"; | |
| 543 } else { | |
| 544 $s .= "\n"; | |
| 545 } | |
| 546 $s .= "-- Version:\n"; | |
| 547 $s .= $self->version()."\n"; | |
| 548 $s .= "-- Is obsolete:\n"; | |
| 549 $s .= $self->is_obsolete()."\n"; | |
| 550 $s .= "-- Comment:\n"; | |
| 551 $s .= $self->comment()."\n"; | |
| 552 if (defined $self->references) { | |
| 553 $s .= "-- References:\n"; | |
| 554 foreach my $ref ( @{$self->references} ) { | |
| 555 $s .= $ref->authors."\n".$ref->title."\n".$ref->location."\n\n"; | |
| 556 }; | |
| 557 $s .= "\n"; | |
| 558 } | |
| 559 if (defined $self->member_list) { | |
| 560 $s .= "-- Member List:\n"; | |
| 561 foreach my $ref ( @{$self->member_list} ) { | |
| 562 $s .= $ref->database."\t".$ref->primary_id."\n"; | |
| 563 }; | |
| 564 $s .= "\n"; | |
| 565 } | |
| 566 if (defined $self->external_doc_list) { | |
| 567 $s .= "-- External Document List:\n"; | |
| 568 foreach my $ref ( @{$self->external_doc_list} ) { | |
| 569 $s .= $ref->database."\t".$ref->primary_id."\n"; | |
| 570 }; | |
| 571 $s .= "\n"; | |
| 572 } | |
| 573 if (defined $self->examples) { | |
| 574 $s .= "-- Examples:\n"; | |
| 575 foreach my $ref ( @{$self->examples} ) { | |
| 576 $s .= $ref->database."\t".$ref->primary_id."\t".$ref->comment."\n"; | |
| 577 }; | |
| 578 $s .= "\n"; | |
| 579 } | |
| 580 if (defined $self->class_list) { | |
| 581 $s .= "-- Class List:\n"; | |
| 582 foreach my $ref ( @{$self->class_list} ) { | |
| 583 $s .= $ref->primary_id."\n"; | |
| 584 }; | |
| 585 $s .= "\n"; | |
| 586 } | |
| 587 if ($self->get_secondary_ids) { | |
| 588 $s .= "-- Secondary IDs:\n"; | |
| 589 foreach my $ref ( $self->get_secondary_ids() ) { | |
| 590 $s .= $ref."\n"; | |
| 591 }; | |
| 592 $s .= "\n"; | |
| 593 } | |
| 594 } | |
| 595 else { | |
| 596 $s .= "InterPro term not fully instantiated\n"; | |
| 597 } | |
| 598 return $s; | |
| 599 } | |
| 600 | |
| 601 =head1 Deprecated methods | |
| 602 | |
| 603 These are here for backwards compatibility. | |
| 604 | |
| 605 =cut | |
| 606 | |
| 607 =head2 secondary_ids | |
| 608 | |
| 609 Title : secondary_ids | |
| 610 Usage : $obj->secondary_ids($newval) | |
| 611 Function: This is deprecated. Use get_secondary_ids() or | |
| 612 add_secondary_id() instead. | |
| 613 Example : | |
| 614 Returns : reference to an array of strings | |
| 615 Args : reference to an array of strings | |
| 616 | |
| 617 | |
| 618 =cut | |
| 619 | |
| 620 sub secondary_ids{ | |
| 621 my $self = shift; | |
| 622 my @ids; | |
| 623 | |
| 624 $self->warn("secondary_ids is deprecated. Use ". | |
| 625 "get_secondary_ids/add_secondary_id instead."); | |
| 626 | |
| 627 # set mode? | |
| 628 if(@_) { | |
| 629 my $sids = shift; | |
| 630 if($sids) { | |
| 631 $self->add_secondary_id(@$sids); | |
| 632 @ids = @$sids; | |
| 633 } else { | |
| 634 # we interpret setting to undef as removing the array | |
| 635 $self->remove_secondary_ids(); | |
| 636 } | |
| 637 } else { | |
| 638 # no; get mode | |
| 639 @ids = $self->get_secondary_ids(); | |
| 640 } | |
| 641 return \@ids; | |
| 642 } | |
| 643 | |
| 644 1; |
