2 # BioPerl module for Bio::Ontology::InterProTerm
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Peter Dimitrov <dimitrov@gnf.org>
8 # Copyright Peter Dimitrov
9 # (c) Peter Dimitrov, dimitrov@gnf.org, 2002.
10 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
12 # You may distribute this module under the same terms as perl itself.
13 # Refer to the Perl Artistic License (see the license accompanying this
14 # software package, or see http://www.perl.com/language/misc/Artistic.html)
15 # for the terms under which you may use, modify, and redistribute this module.
17 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
18 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 # POD documentation - main docs before the code
25 Bio::Ontology::InterProTerm - Implementation of InterProI term interface
29 my $term = Bio::Ontology::InterProTerm->new(
30 -interpro_id => "IPR000001",
32 -definition => "Kringles are autonomous structural domains ...",
35 print $term->interpro_id(), "\n";
36 print $term->name(), "\n";
37 print $term->definition(), "\n";
38 print $term->is_obsolete(), "\n";
39 print $term->ontology->name(), "\n";
43 This is a simple extension of L<Bio::Ontology::Term> for InterPro terms.
49 User feedback is an integral part of the evolution of this and other
50 Bioperl modules. Send your comments and suggestions preferably to
51 the Bioperl mailing list. Your participation is much appreciated.
53 bioperl-l@bioperl.org - General discussion
54 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
58 Please direct usage questions or support issues to the mailing list:
60 I<bioperl-l@bioperl.org>
62 rather than to the module maintainer directly. Many experienced and
63 reponsive experts will be able look at the problem and quickly
64 address it. Please include a thorough description of the problem
65 with code and data examples if at all possible.
69 Report bugs to the Bioperl bug tracking system to help us keep track
70 of the bugs and their resolution. Bug reports can be submitted via
73 https://github.com/bioperl/bioperl-live/issues
75 =head1 AUTHOR - Peter Dimitrov
77 Email dimitrov@gnf.org
81 The rest of the documentation details each of the object methods.
82 Internal methods are usually preceded with a _
87 # Let the code begin...
90 package Bio
::Ontology
::InterProTerm
;
93 use Bio
::Annotation
::Reference
;
95 use constant INTERPRO_ID_DEFAULT
=> "IPR000000";
97 use base
qw(Bio::Ontology::Term);
102 Usage : $term = Bio::Ontology::InterProTerm->new( -interpro_id => "IPR000002",
103 -name => "Cdc20/Fizzy",
104 -definition => "The Cdc20/Fizzy region is almost always ...",
105 -ontology => "Domain"
108 Function: Creates a new Bio::Ontology::InterProTerm.
110 Returns : A new Bio::Ontology::InterProTerm object.
112 -interpro_id => the InterPro ID of the term. Has the form IPRdddddd, where dddddd is a zero-padded six digit number
113 -name => the name of this InterPro term [scalar]
114 -definition => the definition/abstract of this InterPro term [scalar]
115 -ontology => ontology of InterPro terms [Bio::Ontology::OntologyI]
116 -comment => a comment [scalar]
121 my ($class, @args) = @_;
122 my $self = $class->SUPER::new
(@args);
126 = $self->_rearrange( [qw( INTERPRO_ID
131 $interpro_id && $self->interpro_id( $interpro_id );
132 $short_name && $self->short_name( $short_name );
140 Usage : $term->init();
141 Function: Initializes this InterProTerm to all "" and empty lists.
152 # first call the inherited version to properly chain up the hierarchy
153 $self->SUPER::init
(@_);
155 # then only initialize what we implement ourselves here
156 $self->interpro_id( INTERPRO_ID_DEFAULT
);
157 $self->short_name("");
161 =head2 _check_interpro_id
163 Title : _check_interpro_id
165 Function: Performs simple check in order to validate that its argument has the form IPRdddddd, where dddddd is a zero-padded six digit number.
167 Returns : Returns its argument if valid, otherwise throws exception.
173 sub _check_interpro_id
{
174 my ($self, $value) = @_;
176 $self->throw( "InterPro ID ".$value." is incorrect\n" )
177 unless ( $value =~ /^IPR\d{6}$/ ||
178 $value eq INTERPRO_ID_DEFAULT
);
186 Usage : $obj->interpro_id($newval)
187 Function: Set/get for the interpro_id of this InterProTerm
189 Returns : value of interpro_id (a scalar)
190 Args : new value (a scalar, optional)
196 my ($self, $value) = @_;
198 if( defined $value) {
199 $value = $self->_check_interpro_id($value);
200 return $self->identifier($value);
203 return $self->identifier();
209 Usage : $obj->short_name($newval)
210 Function: Set/get for the short name of this InterProTerm.
212 Returns : value of short_name (a scalar)
213 Args : new value (a scalar, optional)
219 my ($self, $value) = @_;
221 if( defined $value) {
222 $self->{'short_name'} = $value ?
$value : undef;
225 return $self->{'short_name'};
230 Title : protein_count
231 Usage : $obj->protein_count($newval)
232 Function: Set/get for the protein count of this InterProTerm.
234 Returns : value of protein_count (a scalar)
235 Args : new value (a scalar, optional)
241 my ($self,$value) = @_;
243 if( defined $value) {
244 $self->{'protein_count'} = $value ?
$value : undef;
247 return $self->{'protein_count'};
250 =head2 get_references
252 Title : get_references
254 Function: Get the references for this InterPro term.
256 Returns : An array of L<Bio::Annotation::Reference> objects
262 # Defined in parent class
267 # return @{$self->{"_references"}} if exists($self->{"_references"});
273 Title : add_reference
275 Function: Add one or more references to this InterPro term.
278 Args : One or more L<Bio::Annotation::Reference> objects.
283 # Defined in parent class
288 # $self->{"_references"} = [] unless exists($self->{"_references"});
289 # push(@{$self->{"_references"}}, @_);
292 =head2 remove_references
294 Title : remove_references
296 Function: Remove all references for this InterPro term.
298 Returns : The list of previous references as an array of
299 L<Bio::Annotation::Reference> objects.
305 # Defined in parent class
306 #sub remove_references{
309 # my @arr = $self->get_references();
310 # $self->{"_references"} = [];
317 Usage : @arr = get_members()
318 Function: Get the list of member(s) for this object.
320 Returns : An array of Bio::Annotation::DBLink objects
328 return $self->get_dbxrefs('member_list');
335 Function: Add one or more member(s) to this object.
338 Args : One or more Bio::Annotation::DBLink objects.
345 $self->add_dbxref(-dbxrefs
=> \
@_, -context
=> 'member_list');
348 =head2 remove_members
350 Title : remove_members
352 Function: Remove all members for this class.
354 Returns : The list of previous members as an array of
355 Bio::Annotation::DBLink objects.
363 return $self->remove_dbxrefs('member_list');
369 Usage : @arr = get_examples()
370 Function: Get the list of example(s) for this object.
372 This is an element of the InterPro xml schema.
375 Returns : An array of Bio::Annotation::DBLink objects
383 return $self->get_dbxrefs('example_list');
390 Function: Add one or more example(s) to this object.
392 This is an element of the InterPro xml schema.
396 Args : One or more Bio::Annotation::DBLink objects.
403 return $self->add_dbxref(-dbxrefs
=> \
@_, -context
=> 'example_list');
406 =head2 remove_examples
408 Title : remove_examples
410 Function: Remove all examples for this class.
412 This is an element of the InterPro xml schema.
415 Returns : The list of previous examples as an array of
416 Bio::Annotation::DBLink objects.
424 return $self->remove_dbxrefs('example_list');
427 =head2 get_external_documents
429 Title : get_external_documents
430 Usage : @arr = get_external_documents()
431 Function: Get the list of external_document(s) for this object.
433 This is an element of the InterPro xml schema.
436 Returns : An array of Bio::Annotation::DBLink objects
442 sub get_external_documents
{
444 return $self->get_dbxrefs('external_doc_list');
447 =head2 add_external_document
449 Title : add_external_document
451 Function: Add one or more external_document(s) to this object.
453 This is an element of the InterPro xml schema.
457 Args : One or more Bio::Annotation::DBLink objects.
462 sub add_external_document
{
464 return $self->add_dbxref(-dbxrefs
=> \
@_, -context
=> 'external_doc_list');
467 =head2 remove_external_documents
469 Title : remove_external_documents
471 Function: Remove all external_documents for this class.
473 This is an element of the InterPro xml schema.
476 Returns : The list of previous external_documents as an array of
477 Bio::Annotation::DBLink objects.
483 sub remove_external_documents
{
485 return $self->remove_dbxrefs('external_doc_list');
491 Usage : $obj->class_list($newval)
492 Function: Set/get for class list element of the InterPro xml schema
494 Returns : reference to an array of Bio::Annotation::DBLink objects
495 Args : reference to an array of Bio::Annotation::DBLink objects
499 # this is inconsistent with the above, but we work around it and hope nothing
503 my ($self, $value) = @_;
504 if( defined $value && ref $value eq 'ARRAY') {
506 # passing an empty array ref is essentially same as remove_dbxrefs,
508 $self->remove_dbxrefs('class_list');
510 $self->add_dbxref(-dbxrefs
=> $value, -context
=> 'class_list');
513 return [$self->get_dbxrefs('class_list')];
519 Usage : print $term->to_string();
520 Function: to_string method for InterPro terms.
521 Returns : A string representation of this InterPro term.
530 $s .= "-- InterPro id:\n";
531 $s .= $self->interpro_id() . "\n";
532 if ( defined $self->name ) {
534 $s .= $self->name() . "\n";
535 $s .= "-- Definition:\n";
536 $s .= ( $self->definition() || '' ) . "\n";
537 $s .= "-- Category:\n";
538 if ( defined( $self->ontology() ) ) {
539 $s .= $self->ontology()->name() . "\n";
544 $s .= "-- Version:\n";
545 $s .= ( $self->version() || '' ) . "\n";
546 $s .= "-- Is obsolete:\n";
547 $s .= $self->is_obsolete() . "\n";
548 $s .= "-- Comment:\n";
549 $s .= ( $self->comment() || '' ) . "\n";
550 if ( defined $self->get_references ) {
551 $s .= "-- References:\n";
552 foreach my $ref ( $self->get_references ) {
556 . $ref->location . "\n\n";
560 if ( defined $self->get_members ) {
561 $s .= "-- Member List:\n";
562 foreach my $ref ( $self->get_members ) {
563 $s .= $ref->database . "\t" . $ref->primary_id . "\n";
567 if ( defined $self->get_external_documents ) {
568 $s .= "-- External Document List:\n";
569 foreach my $ref ( $self->get_external_documents ) {
570 $s .= $ref->database . "\t" . $ref->primary_id . "\n";
574 if ( defined $self->get_examples ) {
575 $s .= "-- Examples:\n";
576 foreach my $ref ( $self->get_examples ) {
578 map { $ref->$_ || '' } qw(database primary_id comment) )
583 if ( defined $self->class_list ) {
584 $s .= "-- Class List:\n";
585 foreach my $ref ( @
{ $self->class_list } ) {
586 $s .= $ref->primary_id . "\n";
590 if ( $self->get_secondary_ids ) {
591 $s .= "-- Secondary IDs:\n";
592 foreach my $ref ( $self->get_secondary_ids() ) {
593 # TODO: getting undef here in some cases, needs to be checked
594 next unless defined ($ref);
601 $s .= "InterPro term not fully instantiated\n";
606 =head1 Deprecated methods
608 These are here for backwards compatibility.
614 Title : secondary_ids
615 Usage : $obj->secondary_ids($newval)
616 Function: This is deprecated. Use get_secondary_ids() or
617 add_secondary_id() instead.
619 Returns : reference to an array of strings
620 Args : reference to an array of strings
629 $self->warn("secondary_ids is deprecated. Use ".
630 "get_secondary_ids/add_secondary_id instead.");
636 $self->add_secondary_id(@
$sids);
639 # we interpret setting to undef as removing the array
640 $self->remove_secondary_ids();
644 @ids = $self->get_secondary_ids();