3 # BioPerl module for Bio::Ontology::InterProTerm
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Peter Dimitrov <dimitrov@gnf.org>
9 # Copyright Peter Dimitrov
10 # (c) Peter Dimitrov, dimitrov@gnf.org, 2002.
11 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
13 # You may distribute this module under the same terms as perl itself.
14 # Refer to the Perl Artistic License (see the license accompanying this
15 # software package, or see http://www.perl.com/language/misc/Artistic.html)
16 # for the terms under which you may use, modify, and redistribute this module.
18 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
19 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 # POD documentation - main docs before the code
26 Bio::Ontology::InterProTerm - Implementation of InterProI term interface
30 my $term = Bio::Ontology::InterProTerm->new(
31 -interpro_id => "IPR000001",
33 -definition => "Kringles are autonomous structural domains ...",
36 print $term->interpro_id(), "\n";
37 print $term->name(), "\n";
38 print $term->definition(), "\n";
39 print $term->is_obsolete(), "\n";
40 print $term->ontology->name(), "\n";
44 This is a simple extension of L<Bio::Ontology::Term> for InterPro terms.
50 User feedback is an integral part of the evolution of this and other
51 Bioperl modules. Send your comments and suggestions preferably to
52 the Bioperl mailing list. Your participation is much appreciated.
54 bioperl-l@bioperl.org - General discussion
55 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
59 Please direct usage questions or support issues to the mailing list:
61 I<bioperl-l@bioperl.org>
63 rather than to the module maintainer directly. Many experienced and
64 reponsive experts will be able look at the problem and quickly
65 address it. Please include a thorough description of the problem
66 with code and data examples if at all possible.
70 Report bugs to the Bioperl bug tracking system to help us keep track
71 of the bugs and their resolution. Bug reports can be submitted via
74 http://bugzilla.open-bio.org/
76 =head1 AUTHOR - Peter Dimitrov
78 Email dimitrov@gnf.org
82 The rest of the documentation details each of the object methods.
83 Internal methods are usually preceded with a _
88 # Let the code begin...
91 package Bio
::Ontology
::InterProTerm
;
94 use Bio
::Annotation
::Reference
;
96 use constant INTERPRO_ID_DEFAULT
=> "IPR000000";
98 use base
qw(Bio::Ontology::Term);
103 Usage : $term = Bio::Ontology::InterProTerm->new( -interpro_id => "IPR000002",
104 -name => "Cdc20/Fizzy",
105 -definition => "The Cdc20/Fizzy region is almost always ...",
106 -ontology => "Domain"
109 Function: Creates a new Bio::Ontology::InterProTerm.
111 Returns : A new Bio::Ontology::InterProTerm object.
113 -interpro_id => the InterPro ID of the term. Has the form IPRdddddd, where dddddd is a zero-padded six digit number
114 -name => the name of this InterPro term [scalar]
115 -definition => the definition/abstract of this InterPro term [scalar]
116 -ontology => ontology of InterPro terms [Bio::Ontology::OntologyI]
117 -comment => a comment [scalar]
122 my ($class, @args) = @_;
123 my $self = $class->SUPER::new
(@args);
127 = $self->_rearrange( [qw( INTERPRO_ID
132 $interpro_id && $self->interpro_id( $interpro_id );
133 $short_name && $self->short_name( $short_name );
141 Usage : $term->init();
142 Function: Initializes this InterProTerm to all "" and empty lists.
153 # first call the inherited version to properly chain up the hierarchy
154 $self->SUPER::init
(@_);
156 # then only initialize what we implement ourselves here
157 $self->interpro_id( INTERPRO_ID_DEFAULT
);
158 $self->short_name("");
162 =head2 _check_interpro_id
164 Title : _check_interpro_id
166 Function: Performs simple check in order to validate that its argument has the form IPRdddddd, where dddddd is a zero-padded six digit number.
168 Returns : Returns its argument if valid, otherwise throws exception.
174 sub _check_interpro_id
{
175 my ($self, $value) = @_;
177 $self->throw( "InterPro ID ".$value." is incorrect\n" )
178 unless ( $value =~ /^IPR\d{6}$/ ||
179 $value eq INTERPRO_ID_DEFAULT
);
187 Usage : $obj->interpro_id($newval)
188 Function: Set/get for the interpro_id of this InterProTerm
190 Returns : value of interpro_id (a scalar)
191 Args : new value (a scalar, optional)
197 my ($self, $value) = @_;
199 if( defined $value) {
200 $value = $self->_check_interpro_id($value);
201 return $self->identifier($value);
204 return $self->identifier();
210 Usage : $obj->short_name($newval)
211 Function: Set/get for the short name of this InterProTerm.
213 Returns : value of short_name (a scalar)
214 Args : new value (a scalar, optional)
220 my ($self, $value) = @_;
222 if( defined $value) {
223 $self->{'short_name'} = $value ?
$value : undef;
226 return $self->{'short_name'};
231 Title : protein_count
232 Usage : $obj->protein_count($newval)
233 Function: Set/get for the protein count of this InterProTerm.
235 Returns : value of protein_count (a scalar)
236 Args : new value (a scalar, optional)
242 my ($self,$value) = @_;
244 if( defined $value) {
245 $self->{'protein_count'} = $value ?
$value : undef;
248 return $self->{'protein_count'};
251 =head2 get_references
253 Title : get_references
255 Function: Get the references for this InterPro term.
257 Returns : An array of L<Bio::Annotation::Reference> objects
266 return @
{$self->{"_references"}} if exists($self->{"_references"});
272 Title : add_reference
274 Function: Add one or more references to this InterPro term.
277 Args : One or more L<Bio::Annotation::Reference> objects.
285 $self->{"_references"} = [] unless exists($self->{"_references"});
286 push(@
{$self->{"_references"}}, @_);
289 =head2 remove_references
291 Title : remove_references
293 Function: Remove all references for this InterPro term.
295 Returns : The list of previous references as an array of
296 L<Bio::Annotation::Reference> objects.
302 sub remove_references
{
305 my @arr = $self->get_references();
306 $self->{"_references"} = [];
313 Usage : @arr = get_members()
314 Function: Get the list of member(s) for this object.
316 Returns : An array of Bio::Annotation::DBLink objects
325 return @
{$self->{'_members'}} if exists($self->{'_members'});
333 Function: Add one or more member(s) to this object.
336 Args : One or more Bio::Annotation::DBLink objects.
344 $self->{'_members'} = [] unless exists($self->{'_members'});
345 push(@
{$self->{'_members'}}, @_);
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.
364 my @arr = $self->get_members();
365 $self->{'_members'} = [];
372 Usage : @arr = get_examples()
373 Function: Get the list of example(s) for this object.
375 This is an element of the InterPro xml schema.
378 Returns : An array of Bio::Annotation::DBLink objects
387 return @
{$self->{'_examples'}} if exists($self->{'_examples'});
395 Function: Add one or more example(s) to this object.
397 This is an element of the InterPro xml schema.
401 Args : One or more Bio::Annotation::DBLink objects.
409 $self->{'_examples'} = [] unless exists($self->{'_examples'});
410 push(@
{$self->{'_examples'}}, @_);
413 =head2 remove_examples
415 Title : remove_examples
417 Function: Remove all examples for this class.
419 This is an element of the InterPro xml schema.
422 Returns : The list of previous examples as an array of
423 Bio::Annotation::DBLink objects.
432 my @arr = $self->get_examples();
433 $self->{'_examples'} = [];
437 =head2 get_external_documents
439 Title : get_external_documents
440 Usage : @arr = get_external_documents()
441 Function: Get the list of external_document(s) for this object.
443 This is an element of the InterPro xml schema.
446 Returns : An array of Bio::Annotation::DBLink objects
452 sub get_external_documents
{
455 return @
{$self->{'_external_documents'}} if exists($self->{'_external_documents'});
459 =head2 add_external_document
461 Title : add_external_document
463 Function: Add one or more external_document(s) to this object.
465 This is an element of the InterPro xml schema.
469 Args : One or more Bio::Annotation::DBLink objects.
474 sub add_external_document
{
477 $self->{'_external_documents'} = [] unless exists($self->{'_external_documents'});
478 push(@
{$self->{'_external_documents'}}, @_);
481 =head2 remove_external_documents
483 Title : remove_external_documents
485 Function: Remove all external_documents for this class.
487 This is an element of the InterPro xml schema.
490 Returns : The list of previous external_documents as an array of
491 Bio::Annotation::DBLink objects.
497 sub remove_external_documents
{
500 my @arr = $self->get_external_documents();
501 $self->{'_external_documents'} = [];
508 Usage : $obj->class_list($newval)
509 Function: Set/get for class list element of the InterPro xml schema
511 Returns : reference to an array of Bio::Annotation::DBLink objects
512 Args : reference to an array of Bio::Annotation::DBLink objects
518 my ($self, $value) = @_;
520 if( defined $value) {
521 $self->{'class_list'} = $value;
524 return $self->{'class_list'};
530 Usage : print $term->to_string();
531 Function: to_string method for InterPro terms.
532 Returns : A string representation of this InterPro term.
541 $s .= "-- InterPro id:\n";
542 $s .= $self->interpro_id()."\n";
543 if (defined $self->name) {
545 $s .= $self->name()."\n";
546 $s .= "-- Definition:\n";
547 $s .= $self->definition()."\n";
548 $s .= "-- Category:\n";
549 if ( defined( $self->ontology() ) ) {
550 $s .= $self->ontology()->name()."\n";
554 $s .= "-- Version:\n";
555 $s .= $self->version()."\n";
556 $s .= "-- Is obsolete:\n";
557 $s .= $self->is_obsolete()."\n";
558 $s .= "-- Comment:\n";
559 $s .= $self->comment()."\n";
560 if (defined $self->get_references) {
561 $s .= "-- References:\n";
562 foreach my $ref ( $self->get_references ) {
563 $s .= $ref->authors."\n".$ref->title."\n".$ref->location."\n\n";
567 if (defined $self->get_members) {
568 $s .= "-- Member List:\n";
569 foreach my $ref ( $self->get_members ) {
570 $s .= $ref->database."\t".$ref->primary_id."\n";
574 if (defined $self->get_external_documents) {
575 $s .= "-- External Document List:\n";
576 foreach my $ref ( $self->get_external_documents ) {
577 $s .= $ref->database."\t".$ref->primary_id."\n";
581 if (defined $self->get_examples) {
582 $s .= "-- Examples:\n";
583 foreach my $ref ( $self->get_examples ) {
584 $s .= $ref->database."\t".$ref->primary_id."\t".$ref->comment."\n";
588 if (defined $self->class_list) {
589 $s .= "-- Class List:\n";
590 foreach my $ref ( @
{$self->class_list} ) {
591 $s .= $ref->primary_id."\n";
595 if ($self->get_secondary_ids) {
596 $s .= "-- Secondary IDs:\n";
597 foreach my $ref ( $self->get_secondary_ids() ) {
604 $s .= "InterPro term not fully instantiated\n";
609 =head1 Deprecated methods
611 These are here for backwards compatibility.
617 Title : secondary_ids
618 Usage : $obj->secondary_ids($newval)
619 Function: This is deprecated. Use get_secondary_ids() or
620 add_secondary_id() instead.
622 Returns : reference to an array of strings
623 Args : reference to an array of strings
632 $self->warn("secondary_ids is deprecated. Use ".
633 "get_secondary_ids/add_secondary_id instead.");
639 $self->add_secondary_id(@
$sids);
642 # we interpret setting to undef as removing the array
643 $self->remove_secondary_ids();
647 @ids = $self->get_secondary_ids();