3 # BioPerl module for Bio::Ontology::InterProTerm
5 # Cared for by Peter Dimitrov <dimitrov@gnf.org>
7 # Copyright Peter Dimitrov
8 # (c) Peter Dimitrov, dimitrov@gnf.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 # POD documentation - main docs before the code
24 Bio::Ontology::InterProTerm - Implementation of InterProI term interface
28 my $term = Bio::Ontology::InterProTerm->new(
29 -interpro_id => "IPR000001",
31 -definition => "Kringles are autonomous structural domains ...",
34 print $term->interpro_id(), "\n";
35 print $term->name(), "\n";
36 print $term->definition(), "\n";
37 print $term->is_obsolete(), "\n";
38 print $term->ontology->name(), "\n";
42 This is a simple extension of L<Bio::Ontology::Term> for InterPro terms.
48 User feedback is an integral part of the evolution of this and other
49 Bioperl modules. Send your comments and suggestions preferably to
50 the Bioperl mailing list. Your participation is much appreciated.
52 bioperl-l@bioperl.org - General discussion
53 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 of the bugs and their resolution. Bug reports can be submitted via
61 http://bugzilla.open-bio.org/
63 =head1 AUTHOR - Peter Dimitrov
65 Email dimitrov@gnf.org
69 The rest of the documentation details each of the object methods.
70 Internal methods are usually preceded with a _
75 # Let the code begin...
78 package Bio
::Ontology
::InterProTerm
;
81 use Bio
::Annotation
::Reference
;
83 use constant INTERPRO_ID_DEFAULT
=> "IPR000000";
85 use base
qw(Bio::Ontology::Term);
90 Usage : $term = Bio::Ontology::InterProTerm->new( -interpro_id => "IPR000002",
91 -name => "Cdc20/Fizzy",
92 -definition => "The Cdc20/Fizzy region is almost always ...",
96 Function: Creates a new Bio::Ontology::InterProTerm.
98 Returns : A new Bio::Ontology::InterProTerm object.
100 -interpro_id => the InterPro ID of the term. Has the form IPRdddddd, where dddddd is a zero-padded six digit number
101 -name => the name of this InterPro term [scalar]
102 -definition => the definition/abstract of this InterPro term [scalar]
103 -ontology => ontology of InterPro terms [Bio::Ontology::OntologyI]
104 -comment => a comment [scalar]
109 my ($class, @args) = @_;
110 my $self = $class->SUPER::new
(@args);
114 = $self->_rearrange( [qw( INTERPRO_ID
119 $interpro_id && $self->interpro_id( $interpro_id );
120 $short_name && $self->short_name( $short_name );
128 Usage : $term->init();
129 Function: Initializes this InterProTerm to all "" and empty lists.
140 # first call the inherited version to properly chain up the hierarchy
141 $self->SUPER::init
(@_);
143 # then only initialize what we implement ourselves here
144 $self->interpro_id( INTERPRO_ID_DEFAULT
);
145 $self->short_name("");
149 =head2 _check_interpro_id
151 Title : _check_interpro_id
153 Function: Performs simple check in order to validate that its argument has the form IPRdddddd, where dddddd is a zero-padded six digit number.
155 Returns : Returns its argument if valid, otherwise throws exception.
161 sub _check_interpro_id
{
162 my ($self, $value) = @_;
164 $self->throw( "InterPro ID ".$value." is incorrect\n" )
165 unless ( $value =~ /^IPR\d{6}$/ ||
166 $value eq INTERPRO_ID_DEFAULT
);
174 Usage : $obj->interpro_id($newval)
175 Function: Set/get for the interpro_id of this InterProTerm
177 Returns : value of interpro_id (a scalar)
178 Args : new value (a scalar, optional)
184 my ($self, $value) = @_;
186 if( defined $value) {
187 $value = $self->_check_interpro_id($value);
188 return $self->identifier($value);
191 return $self->identifier();
197 Usage : $obj->short_name($newval)
198 Function: Set/get for the short name of this InterProTerm.
200 Returns : value of short_name (a scalar)
201 Args : new value (a scalar, optional)
207 my ($self, $value) = @_;
209 if( defined $value) {
210 $self->{'short_name'} = $value ?
$value : undef;
213 return $self->{'short_name'};
218 Title : protein_count
219 Usage : $obj->protein_count($newval)
220 Function: Set/get for the protein count of this InterProTerm.
222 Returns : value of protein_count (a scalar)
223 Args : new value (a scalar, optional)
229 my ($self,$value) = @_;
231 if( defined $value) {
232 $self->{'protein_count'} = $value ?
$value : undef;
235 return $self->{'protein_count'};
238 =head2 get_references
240 Title : get_references
242 Function: Get the references for this InterPro term.
244 Returns : An array of L<Bio::Annotation::Reference> objects
253 return @
{$self->{"_references"}} if exists($self->{"_references"});
259 Title : add_reference
261 Function: Add one or more references to this InterPro term.
264 Args : One or more L<Bio::Annotation::Reference> objects.
272 $self->{"_references"} = [] unless exists($self->{"_references"});
273 push(@
{$self->{"_references"}}, @_);
276 =head2 remove_references
278 Title : remove_references
280 Function: Remove all references for this InterPro term.
282 Returns : The list of previous references as an array of
283 L<Bio::Annotation::Reference> objects.
289 sub remove_references
{
292 my @arr = $self->get_references();
293 $self->{"_references"} = [];
300 Usage : @arr = get_members()
301 Function: Get the list of member(s) for this object.
303 Returns : An array of Bio::Annotation::DBLink objects
312 return @
{$self->{'_members'}} if exists($self->{'_members'});
320 Function: Add one or more member(s) to this object.
323 Args : One or more Bio::Annotation::DBLink objects.
331 $self->{'_members'} = [] unless exists($self->{'_members'});
332 push(@
{$self->{'_members'}}, @_);
335 =head2 remove_members
337 Title : remove_members
339 Function: Remove all members for this class.
341 Returns : The list of previous members as an array of
342 Bio::Annotation::DBLink objects.
351 my @arr = $self->get_members();
352 $self->{'_members'} = [];
359 Usage : @arr = get_examples()
360 Function: Get the list of example(s) for this object.
362 This is an element of the InterPro xml schema.
365 Returns : An array of Bio::Annotation::DBLink objects
374 return @
{$self->{'_examples'}} if exists($self->{'_examples'});
382 Function: Add one or more example(s) to this object.
384 This is an element of the InterPro xml schema.
388 Args : One or more Bio::Annotation::DBLink objects.
396 $self->{'_examples'} = [] unless exists($self->{'_examples'});
397 push(@
{$self->{'_examples'}}, @_);
400 =head2 remove_examples
402 Title : remove_examples
404 Function: Remove all examples for this class.
406 This is an element of the InterPro xml schema.
409 Returns : The list of previous examples as an array of
410 Bio::Annotation::DBLink objects.
419 my @arr = $self->get_examples();
420 $self->{'_examples'} = [];
424 =head2 get_external_documents
426 Title : get_external_documents
427 Usage : @arr = get_external_documents()
428 Function: Get the list of external_document(s) for this object.
430 This is an element of the InterPro xml schema.
433 Returns : An array of Bio::Annotation::DBLink objects
439 sub get_external_documents
{
442 return @
{$self->{'_external_documents'}} if exists($self->{'_external_documents'});
446 =head2 add_external_document
448 Title : add_external_document
450 Function: Add one or more external_document(s) to this object.
452 This is an element of the InterPro xml schema.
456 Args : One or more Bio::Annotation::DBLink objects.
461 sub add_external_document
{
464 $self->{'_external_documents'} = [] unless exists($self->{'_external_documents'});
465 push(@
{$self->{'_external_documents'}}, @_);
468 =head2 remove_external_documents
470 Title : remove_external_documents
472 Function: Remove all external_documents for this class.
474 This is an element of the InterPro xml schema.
477 Returns : The list of previous external_documents as an array of
478 Bio::Annotation::DBLink objects.
484 sub remove_external_documents
{
487 my @arr = $self->get_external_documents();
488 $self->{'_external_documents'} = [];
495 Usage : $obj->class_list($newval)
496 Function: Set/get for class list element of the InterPro xml schema
498 Returns : reference to an array of Bio::Annotation::DBLink objects
499 Args : reference to an array of Bio::Annotation::DBLink objects
505 my ($self, $value) = @_;
507 if( defined $value) {
508 $self->{'class_list'} = $value;
511 return $self->{'class_list'};
517 Usage : print $term->to_string();
518 Function: to_string method for InterPro terms.
519 Returns : A string representation of this InterPro term.
528 $s .= "-- InterPro id:\n";
529 $s .= $self->interpro_id()."\n";
530 if (defined $self->name) {
532 $s .= $self->name()."\n";
533 $s .= "-- Definition:\n";
534 $s .= $self->definition()."\n";
535 $s .= "-- Category:\n";
536 if ( defined( $self->ontology() ) ) {
537 $s .= $self->ontology()->name()."\n";
541 $s .= "-- Version:\n";
542 $s .= $self->version()."\n";
543 $s .= "-- Is obsolete:\n";
544 $s .= $self->is_obsolete()."\n";
545 $s .= "-- Comment:\n";
546 $s .= $self->comment()."\n";
547 if (defined $self->get_references) {
548 $s .= "-- References:\n";
549 foreach my $ref ( $self->get_references ) {
550 $s .= $ref->authors."\n".$ref->title."\n".$ref->location."\n\n";
554 if (defined $self->get_members) {
555 $s .= "-- Member List:\n";
556 foreach my $ref ( $self->get_members ) {
557 $s .= $ref->database."\t".$ref->primary_id."\n";
561 if (defined $self->get_external_documents) {
562 $s .= "-- External Document List:\n";
563 foreach my $ref ( $self->get_external_documents ) {
564 $s .= $ref->database."\t".$ref->primary_id."\n";
568 if (defined $self->get_examples) {
569 $s .= "-- Examples:\n";
570 foreach my $ref ( $self->get_examples ) {
571 $s .= $ref->database."\t".$ref->primary_id."\t".$ref->comment."\n";
575 if (defined $self->class_list) {
576 $s .= "-- Class List:\n";
577 foreach my $ref ( @
{$self->class_list} ) {
578 $s .= $ref->primary_id."\n";
582 if ($self->get_secondary_ids) {
583 $s .= "-- Secondary IDs:\n";
584 foreach my $ref ( $self->get_secondary_ids() ) {
591 $s .= "InterPro term not fully instantiated\n";
596 =head1 Deprecated methods
598 These are here for backwards compatibility.
604 Title : secondary_ids
605 Usage : $obj->secondary_ids($newval)
606 Function: This is deprecated. Use get_secondary_ids() or
607 add_secondary_id() instead.
609 Returns : reference to an array of strings
610 Args : reference to an array of strings
619 $self->warn("secondary_ids is deprecated. Use ".
620 "get_secondary_ids/add_secondary_id instead.");
626 $self->add_secondary_id(@
$sids);
629 # we interpret setting to undef as removing the array
630 $self->remove_secondary_ids();
634 @ids = $self->get_secondary_ids();