2 # BioPerl module for Bio::Ontology::GOterm
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Christian M. Zmasek <czmasek-at-burnham.org> or <cmzmasek@yahoo.com>
8 # (c) Christian M. Zmasek, czmasek-at-burnham.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 # You may distribute this module under the same terms as perl itself
22 # POD documentation - main docs before the code
27 Bio::Ontology::GOterm - representation of GO terms
31 $term = Bio::Ontology::GOterm->new
32 ( -go_id => "GO:0016847",
33 -name => "1-aminocyclopropane-1-carboxylate synthase",
34 -definition => "Catalysis of ...",
38 $term->add_definition_references( @refs );
39 $term->add_secondary_GO_ids( @ids );
40 $term->add_aliases( @aliases );
42 foreach my $dr ( $term->each_definition_reference() ) {
50 This is "dumb" class for GO terms (it provides no functionality
51 related to graphs). Implements Bio::Ontology::TermI.
57 User feedback is an integral part of the evolution of this and other
58 Bioperl modules. Send your comments and suggestions preferably to one
59 of the Bioperl mailing lists. Your participation is much appreciated.
61 bioperl-l@bioperl.org - General discussion
62 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
66 Please direct usage questions or support issues to the mailing list:
68 I<bioperl-l@bioperl.org>
70 rather than to the module maintainer directly. Many experienced and
71 reponsive experts will be able look at the problem and quickly
72 address it. Please include a thorough description of the problem
73 with code and data examples if at all possible.
77 Report bugs to the Bioperl bug tracking system to help us keep track
78 the bugs and their resolution. Bug reports can be submitted via the web:
80 https://github.com/bioperl/bioperl-live/issues
86 Email: czmasek-at-burnham.org or cmzmasek@yahoo.com
88 WWW: http://monochrome-effect.net/
92 Genomics Institute of the Novartis Research Foundation
93 10675 John Jay Hopkins Drive
98 The rest of the documentation details each of the object
104 # Let the code begin...
106 package Bio
::Ontology
::GOterm
;
109 use constant GOID_DEFAULT
=> "GO:0000000";
110 use constant TRUE
=> 1;
111 use constant FALSE
=> 0;
113 use base
qw(Bio::Ontology::Term);
118 Usage : $term = Bio::Ontology::GOterm->new(
119 -go_id => "GO:0016847",
120 -name => "1-aminocyclopropane-1-carboxylate synthase",
121 -definition => "Catalysis of ...",
124 Function: Creates a new Bio::Ontology::GOterm.
125 Returns : A new Bio::Ontology::GOterm object.
126 Args : -go_id => the goid of this GO term [GO:nnnnnnn]
127 or [nnnnnnn] (nnnnnnn is a zero-padded
128 integer of seven digits)
129 -name => the name of this GO term [scalar]
130 -definition => the definition of this GO term [scalar]
131 -ontology => the ontology for this term (a
132 Bio::Ontology::OntologyI compliant object)
133 -version => version information [scalar]
134 -is_obsolete => the obsoleteness of this GO term [0 or 1]
135 -comment => a comment [scalar]
141 my( $class,@args ) = @_;
143 my $self = $class->SUPER::new
( @args );
146 = $self->_rearrange( [ qw( GO_ID ) ], @args );
148 $GO_id && $self->GO_id( $GO_id );
159 Usage : $term->init();
160 Function: Initializes this GOterm to all "" and empty lists.
170 # first call the inherited version to properly chain up the hierarchy
171 $self->SUPER::init
(@_);
173 # then only initialize what we implement ourselves here
174 #$self->GO_id( GOID_DEFAULT );
182 Usage : $term->GO_id( "GO:0003947" );
184 print $term->GO_id();
185 Function: Set/get for the goid of this GO term.
187 This is essentially an alias to identifier(), with added
190 Returns : The goid [GO:nnnnnnn].
191 Args : The goid [GO:nnnnnnn] or [nnnnnnn] (nnnnnnn is a
192 zero-padded integer of seven digits) (optional).
201 $value = $self->_check_go_id( shift );
205 return $self->identifier( @_ );
210 =head2 get_secondary_GO_ids
212 Title : get_secondary_GO_ids
213 Usage : @ids = $term->get_secondary_GO_ids();
214 Function: Returns a list of secondary goids of this Term.
216 This is aliased to remove_secondary_ids().
218 Returns : A list of secondary goids [array of [GO:nnnnnnn]]
219 (nnnnnnn is a zero-padded integer of seven digits).
224 sub get_secondary_GO_ids
{
225 return shift->get_secondary_ids(@_);
226 } # get_secondary_GO_ids
229 =head2 add_secondary_GO_id
231 Title : add_secondary_GO_id
232 Usage : $term->add_secondary_GO_id( @ids );
234 $term->add_secondary_GO_id( $id );
235 Function: Pushes one or more secondary goids into
236 the list of secondary goids.
238 This is aliased to remove_secondary_ids().
241 Args : One secondary goid [GO:nnnnnnn or nnnnnnn] or a list
242 of secondary goids [array of [GO:nnnnnnn or nnnnnnn]]
243 (nnnnnnn is a zero-padded integer of seven digits).
247 sub add_secondary_GO_id
{
248 return shift->add_secondary_id(@_);
249 } # add_secondary_GO_id
252 =head2 remove_secondary_GO_ids
254 Title : remove_secondary_GO_ids()
255 Usage : $term->remove_secondary_GO_ids();
256 Function: Deletes (and returns) the secondary goids of this Term.
258 This is aliased to remove_secondary_ids().
260 Returns : A list of secondary goids [array of [GO:nnnnnnn]]
261 (nnnnnnn is a zero-padded integer of seven digits).
266 sub remove_secondary_GO_ids
{
267 return shift->remove_secondary_ids(@_);
268 } # remove_secondary_GO_ids
274 Usage : print $term->to_string();
275 Function: to_string method for GO terms.
276 Returns : A string representation of this GOterm.
287 $s .= ($self->GO_id() || '')."\n";
289 $s .= ($self->name() || '') ."\n";
290 $s .= "-- Definition:\n";
291 $s .= ($self->definition() || '') ."\n";
292 $s .= "-- Category:\n";
293 if ( defined( $self->ontology() ) ) {
294 $s .= $self->ontology()->name()."\n";
299 $s .= "-- Version:\n";
300 $s .= ($self->version() || '') ."\n";
301 $s .= "-- Is obsolete:\n";
302 $s .= $self->is_obsolete()."\n";
303 $s .= "-- Comment:\n";
304 $s .= ($self->comment() || '') ."\n";
305 $s .= "-- Definition references:\n";
306 $s .= $self->_array_to_string( $self->get_dbxrefs() )."\n";
307 $s .= "-- Secondary GO ids:\n";
308 $s .= $self->_array_to_string( $self->get_secondary_GO_ids() )."\n";
309 $s .= "-- Aliases:\n";
310 $s .= $self->_array_to_string( $self->get_synonyms() );
319 # Title : _check_go_id
320 # Function: Checks whether the argument is [GO:nnnnnnn].
321 # If "GO:" is not present, it adds it.
322 # Returns : The canonical GO id.
323 # Args : The value to be checked.
325 my ( $self, $value ) = @_;
326 unless ( $value =~ /^(GO:)?\d{7}$/ || $value eq GOID_DEFAULT
) {
327 $self->throw( "Found [" . $value
328 . "] where [GO:nnnnnnn] or [nnnnnnn] expected" );
330 unless ( $value =~ /^GO:/ ) {
331 $value = "GO:".$value;
338 # Title : _array_to_string
342 sub _array_to_string
{
343 my( $self, @value ) = @_;
347 for ( my $i = 0; $i < scalar( @value ); ++$i ) {
348 if ( ! ref( $value[ $i ] ) ) {
349 $s .= "#" . $i . "\n-- " . $value[ $i ] . "\n";
357 #################################################################
358 # aliases or forwards to maintain backward compatibility
359 #################################################################
361 *each_secondary_GO_id
= \
&get_secondary_GO_ids
;
362 *add_secondary_GO_ids
= \
&add_secondary_GO_id
;