1
# $Id: OntologyTerm.pm,v 1.8 2003/10/13 20:02:43 lapp Exp $
3
# BioPerl module for Bio::Annotation::OntologyTerm
5
# Cared for by Hilmar Lapp <hlapp at gmx.net>
7
# Copyright Hilmar Lapp
9
# You may distribute this module under the same terms as perl itself
12
# (c) Hilmar Lapp, hlapp at gmx.net, 2002.
13
# (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
15
# You may distribute this module under the same terms as perl itself.
16
# Refer to the Perl Artistic License (see the license accompanying this
17
# software package, or see http://www.perl.com/language/misc/Artistic.html)
18
# for the terms under which you may use, modify, and redistribute this module.
20
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
21
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
22
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25
# POD documentation - main docs before the code
29
Bio::Annotation::OntologyTerm - An ontology term adapted to AnnotationI
33
use Bio::Annotation::OntologyTerm;
34
use Bio::Annotation::Collection;
35
use Bio::Ontology::Term;
37
my $coll = new Bio::Annotation::Collection;
39
# this also implements a tag/value pair, where tag _and_ value are treated
41
my $annterm = new Bio::Annotation::OntologyTerm(-label => 'ABC1',
42
-tagname => 'Gene Name');
43
# ontology terms can be added directly - they implicitly have a tag
44
$coll->add_Annotation($annterm);
46
# implementation is by composition - you can get/set the term object
48
my $term = $annterm->term(); # term is-a Bio::Ontology::TermI
49
print "ontology term ",$term->name()," (ID ",$term->identifier(),
50
"), ontology ",$term->ontology()->name(),"\n";
51
$term = Bio::Ontology::Term->new(-name => 'ABC2', -ontology => 'Gene Name');
52
$annterm->term($term);
56
Ontology term annotation object
62
User feedback is an integral part of the evolution of this and other
63
Bioperl modules. Send your comments and suggestions preferably to one
64
of the Bioperl mailing lists. Your participation is much appreciated.
66
bioperl-l@bioperl.org - General discussion
67
http://bio.perl.org/MailList.html - About the mailing lists
71
Report bugs to the Bioperl bug tracking system to help us keep track
72
the bugs and their resolution. Bug reports can be submitted via email
75
bioperl-bugs@bioperl.org
76
http://bugzilla.bioperl.org/
78
=head1 AUTHOR - Hilmar Lapp
80
Email bioperl-l@bio.perl.org
81
Email hlapp at gmx.net
86
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
91
# Let the code begin...
94
package Bio::Annotation::OntologyTerm;
98
# Object preamble - inherits from Bio::Root::Root
100
use Bio::AnnotationI;
101
use Bio::Ontology::TermI;
102
use Bio::Ontology::Term;
105
@ISA = qw(Bio::Root::Root Bio::AnnotationI Bio::Ontology::TermI);
110
Usage : my $sv = new Bio::Annotation::OntologyTerm;
111
Function: Instantiate a new OntologyTerm object
112
Returns : Bio::Annotation::OntologyTerm object
113
Args : -term => $term to initialize the term data field [optional]
114
Most named arguments that Bio::Ontology::Term accepts will work
115
here too. -label is a synonym for -name, -tagname is a synonym for
121
my ($class,@args) = @_;
123
my $self = $class->SUPER::new(@args);
125
my ($term,$name,$label,$identifier,$definition,$ont,$tag) =
126
$self->_rearrange([qw(TERM
137
$self->name($name || $label) if $name || $label;
138
$self->identifier($identifier) if $identifier;
139
$self->definition($definition) if $definition;
141
$self->ontology($ont || $tag) if $ont || $tag;
147
=head1 AnnotationI implementing functions
154
Usage : my $text = $obj->as_text
155
Function: return the string "Name: $v" where $v is the name of the term
165
return $self->tagname()."|".$self->name()."|".$self->identifier();
171
Usage : my $hashtree = $value->hash_tree
172
Function: For supporting the AnnotationI interface just returns the value
173
as a hashref with the key 'value' pointing to the value
184
$h->{'name'} = $self->name();
185
$h->{'identifier'} = $self->identifier();
186
$h->{'definition'} = $self->definition();
187
$h->{'synonyms'} = [$self->get_synonyms()];
194
Usage : $obj->tagname($newval)
195
Function: Get/set the tagname for this annotation value.
197
Setting this is optional. If set, it obviates the need to provide
198
a tag to AnnotationCollection when adding this object.
200
This is aliased to ontology() here.
202
Returns : value of tagname (a scalar)
203
Args : new value (a scalar, optional)
211
return $self->ontology(@_) if @_;
212
# if in get mode we need to get the name from the ontology
213
my $ont = $self->ontology();
214
return ref($ont) ? $ont->name() : $ont;
217
=head1 Methods for Bio::Ontology::TermI compliance
224
Usage : $obj->term($newval)
225
Function: Get/set the Bio::Ontology::TermI implementing object.
227
We implement TermI by composition, and this method sets/gets the
228
object we delegate to.
230
Returns : value of term (a Bio::Ontology::TermI compliant object)
231
Args : new value (a Bio::Ontology::TermI compliant object, optional)
237
my ($self,$value) = @_;
238
if( defined $value) {
239
$self->{'term'} = $value;
241
if(! exists($self->{'term'})) {
242
$self->{'term'} = Bio::Ontology::Term->new();
244
return $self->{'term'};
250
Usage : $term->identifier( "0003947" );
252
print $term->identifier();
253
Function: Set/get for the identifier of this Term.
254
Returns : The identifier [scalar].
255
Args : The identifier [scalar] (optional).
260
return shift->term()->identifier(@_);
266
Usage : $term->name( "N-acetylgalactosaminyltransferase" );
269
Function: Set/get for the name of this Term.
270
Returns : The name [scalar].
271
Args : The name [scalar] (optional).
276
return shift->term()->name(@_);
283
Usage : $term->definition( "Catalysis of ..." );
285
print $term->definition();
286
Function: Set/get for the definition of this Term.
287
Returns : The definition [scalar].
288
Args : The definition [scalar] (optional).
293
return shift->term()->definition(@_);
299
Usage : $term->ontology( $top );
301
$top = $term->ontology();
302
Function: Set/get for a relationship between this Term and
303
another Term (e.g. the top level of the ontology).
304
Returns : The ontology of this Term [TermI].
305
Args : The ontology of this Term [TermI or scalar -- which
306
becomes the name of the catagory term] (optional).
311
return shift->term()->ontology(@_);
317
Usage : $term->is_obsolete( 1 );
319
if ( $term->is_obsolete() )
320
Function: Set/get for the obsoleteness of this Term.
321
Returns : the obsoleteness [0 or 1].
322
Args : the obsoleteness [0 or 1] (optional).
327
return shift->term()->is_obsolete(@_);
333
Usage : $term->comment( "Consider the term ..." );
335
print $term->comment();
336
Function: Set/get for an arbitrary comment about this Term.
338
Args : A comment (optional).
343
return shift->term()->comment(@_);
348
Title : get_synonyms()
349
Usage : @aliases = $term->get_synonyms();
350
Function: Returns a list of aliases of this Term.
351
Returns : A list of aliases [array of [scalar]].
357
return shift->term()->get_synonyms(@_);
363
Usage : $term->add_synonym( @asynonyms );
365
$term->add_synonym( $synonym );
366
Function: Pushes one or more synonyms into the list of synonyms.
368
Args : One synonym [scalar] or a list of synonyms [array of [scalar]].
373
return shift->term()->add_synonym(@_);
377
=head2 remove_synonyms
379
Title : remove_synonyms()
380
Usage : $term->remove_synonyms();
381
Function: Deletes (and returns) the synonyms of this Term.
382
Returns : A list of synonyms [array of [scalar]].
387
sub remove_synonyms {
388
return shift->term()->remove_synonyms(@_);
393
Title : get_dblinks()
394
Usage : @ds = $term->get_dblinks();
395
Function: Returns a list of each dblinks of this GO term.
396
Returns : A list of dblinks [array of [scalars]].
402
return shift->term->get_dblinks(@_);
409
Usage : $term->add_dblink( @dbls );
411
$term->add_dblink( $dbl );
412
Function: Pushes one or more dblinks
413
into the list of dblinks.
415
Args : One dblink [scalar] or a list of
416
dblinks [array of [scalars]].
421
return shift->term->add_dblink(@_);
425
=head2 remove_dblinks
427
Title : remove_dblinks()
428
Usage : $term->remove_dblinks();
429
Function: Deletes (and returns) the definition references of this GO term.
430
Returns : A list of definition references [array of [scalars]].
436
return shift->term->remove_dblinks(@_);
439
=head2 get_secondary_ids
441
Title : get_secondary_ids
442
Usage : @ids = $term->get_secondary_ids();
443
Function: Returns a list of secondary identifiers of this Term.
445
Secondary identifiers mostly originate from merging terms,
446
or possibly also from splitting terms.
448
Returns : A list of secondary identifiers [array of [scalar]]
453
sub get_secondary_ids {
454
return shift->term->get_secondary_ids(@_);
455
} # get_secondary_ids
458
=head2 add_secondary_id
460
Title : add_secondary_id
461
Usage : $term->add_secondary_id( @ids );
463
$term->add_secondary_id( $id );
464
Function: Adds one or more secondary identifiers to this term.
466
Args : One or more secondary identifiers [scalars]
470
sub add_secondary_id {
471
return shift->term->add_secondary_id(@_);
475
=head2 remove_secondary_ids
477
Title : remove_secondary_ids
478
Usage : $term->remove_secondary_ids();
479
Function: Deletes (and returns) the secondary identifiers of this Term.
480
Returns : The previous list of secondary identifiers [array of [scalars]]
485
sub remove_secondary_ids {
486
return shift->term->remove_secondary_ids(@_);
487
} # remove_secondary_ids