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
;
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
263 # Defined in parent class
268 # return @{$self->{"_references"}} if exists($self->{"_references"});
274 Title : add_reference
276 Function: Add one or more references to this InterPro term.
279 Args : One or more L<Bio::Annotation::Reference> objects.
284 # Defined in parent class
289 # $self->{"_references"} = [] unless exists($self->{"_references"});
290 # push(@{$self->{"_references"}}, @_);
293 =head2 remove_references
295 Title : remove_references
297 Function: Remove all references for this InterPro term.
299 Returns : The list of previous references as an array of
300 L<Bio::Annotation::Reference> objects.
306 # Defined in parent class
307 #sub remove_references{
310 # my @arr = $self->get_references();
311 # $self->{"_references"} = [];
318 Usage : @arr = get_members()
319 Function: Get the list of member(s) for this object.
321 Returns : An array of Bio::Annotation::DBLink objects
329 return $self->get_dbxrefs('member_list');
336 Function: Add one or more member(s) to this object.
339 Args : One or more Bio::Annotation::DBLink objects.
346 $self->add_dbxref(-dbxrefs
=> \
@_, -context
=> 'member_list');
349 =head2 remove_members
351 Title : remove_members
353 Function: Remove all members for this class.
355 Returns : The list of previous members as an array of
356 Bio::Annotation::DBLink objects.
364 return $self->remove_dbxrefs('member_list');
370 Usage : @arr = get_examples()
371 Function: Get the list of example(s) for this object.
373 This is an element of the InterPro xml schema.
376 Returns : An array of Bio::Annotation::DBLink objects
384 return $self->get_dbxrefs('example_list');
391 Function: Add one or more example(s) to this object.
393 This is an element of the InterPro xml schema.
397 Args : One or more Bio::Annotation::DBLink objects.
404 return $self->add_dbxref(-dbxrefs
=> \
@_, -context
=> 'example_list');
407 =head2 remove_examples
409 Title : remove_examples
411 Function: Remove all examples for this class.
413 This is an element of the InterPro xml schema.
416 Returns : The list of previous examples as an array of
417 Bio::Annotation::DBLink objects.
425 return $self->remove_dbxrefs('example_list');
428 =head2 get_external_documents
430 Title : get_external_documents
431 Usage : @arr = get_external_documents()
432 Function: Get the list of external_document(s) for this object.
434 This is an element of the InterPro xml schema.
437 Returns : An array of Bio::Annotation::DBLink objects
443 sub get_external_documents
{
445 return $self->get_dbxrefs('external_doc_list');
448 =head2 add_external_document
450 Title : add_external_document
452 Function: Add one or more external_document(s) to this object.
454 This is an element of the InterPro xml schema.
458 Args : One or more Bio::Annotation::DBLink objects.
463 sub add_external_document
{
465 return $self->add_dbxref(-dbxrefs
=> \
@_, -context
=> 'external_doc_list');
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
{
486 return $self->remove_dbxrefs('external_doc_list');
492 Usage : $obj->class_list($newval)
493 Function: Set/get for class list element of the InterPro xml schema
495 Returns : reference to an array of Bio::Annotation::DBLink objects
496 Args : reference to an array of Bio::Annotation::DBLink objects
500 # this is inconsistent with the above, but we work around it and hope nothing
504 my ($self, $value) = @_;
505 if( defined $value && ref $value eq 'ARRAY') {
507 # passing an empty array ref is essentially same as remove_dbxrefs,
509 $self->remove_dbxrefs('class_list');
511 $self->add_dbxref(-dbxrefs
=> $value, -context
=> 'class_list');
514 return [$self->get_dbxrefs('class_list')];
520 Usage : print $term->to_string();
521 Function: to_string method for InterPro terms.
522 Returns : A string representation of this InterPro term.
531 $s .= "-- InterPro id:\n";
532 $s .= $self->interpro_id() . "\n";
533 if ( defined $self->name ) {
535 $s .= $self->name() . "\n";
536 $s .= "-- Definition:\n";
537 $s .= ( $self->definition() || '' ) . "\n";
538 $s .= "-- Category:\n";
539 if ( defined( $self->ontology() ) ) {
540 $s .= $self->ontology()->name() . "\n";
545 $s .= "-- Version:\n";
546 $s .= ( $self->version() || '' ) . "\n";
547 $s .= "-- Is obsolete:\n";
548 $s .= $self->is_obsolete() . "\n";
549 $s .= "-- Comment:\n";
550 $s .= ( $self->comment() || '' ) . "\n";
551 if ( defined $self->get_references ) {
552 $s .= "-- References:\n";
553 foreach my $ref ( $self->get_references ) {
557 . $ref->location . "\n\n";
561 if ( defined $self->get_members ) {
562 $s .= "-- Member List:\n";
563 foreach my $ref ( $self->get_members ) {
564 $s .= $ref->database . "\t" . $ref->primary_id . "\n";
568 if ( defined $self->get_external_documents ) {
569 $s .= "-- External Document List:\n";
570 foreach my $ref ( $self->get_external_documents ) {
571 $s .= $ref->database . "\t" . $ref->primary_id . "\n";
575 if ( defined $self->get_examples ) {
576 $s .= "-- Examples:\n";
577 foreach my $ref ( $self->get_examples ) {
579 map { $ref->$_ || '' } qw(database primary_id comment) )
584 if ( defined $self->class_list ) {
585 $s .= "-- Class List:\n";
586 foreach my $ref ( @
{ $self->class_list } ) {
587 $s .= $ref->primary_id . "\n";
591 if ( $self->get_secondary_ids ) {
592 $s .= "-- Secondary IDs:\n";
593 foreach my $ref ( $self->get_secondary_ids() ) {
594 # TODO: getting undef here in some cases, needs to be checked
595 next unless defined ($ref);
602 $s .= "InterPro term not fully instantiated\n";
607 =head1 Deprecated methods
609 These are here for backwards compatibility.
615 Title : secondary_ids
616 Usage : $obj->secondary_ids($newval)
617 Function: This is deprecated. Use get_secondary_ids() or
618 add_secondary_id() instead.
620 Returns : reference to an array of strings
621 Args : reference to an array of strings
630 $self->warn("secondary_ids is deprecated. Use ".
631 "get_secondary_ids/add_secondary_id instead.");
637 $self->add_secondary_id(@
$sids);
640 # we interpret setting to undef as removing the array
641 $self->remove_secondary_ids();
645 @ids = $self->get_secondary_ids();