comparison variant_effect_predictor/Bio/Ontology/GOterm.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 # $Id: GOterm.pm,v 1.12.2.4 2003/07/03 00:41:40 lapp Exp $
2 #
3 # BioPerl module for Bio::Ontology::GOterm
4 #
5 # Cared for by Christian M. Zmasek <czmasek@gnf.org> or <cmzmasek@yahoo.com>
6 #
7 # (c) Christian M. Zmasek, czmasek@gnf.org, 2002.
8 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
9 #
10 # You may distribute this module under the same terms as perl itself.
11 # Refer to the Perl Artistic License (see the license accompanying this
12 # software package, or see http://www.perl.com/language/misc/Artistic.html)
13 # for the terms under which you may use, modify, and redistribute this module.
14 #
15 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
16 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 #
19 # You may distribute this module under the same terms as perl itself
20
21 # POD documentation - main docs before the code
22
23
24 =head1 NAME
25
26 GOterm - representation of GO terms
27
28 =head1 SYNOPSIS
29
30 $term = Bio::Ontology::GOterm->new
31 ( -go_id => "GO:0016847",
32 -name => "1-aminocyclopropane-1-carboxylate synthase",
33 -definition => "Catalysis of ...",
34 -is_obsolete => 0,
35 -comment => "" );
36
37 $term->add_definition_references( @refs );
38 $term->add_secondary_GO_ids( @ids );
39 $term->add_aliases( @aliases );
40
41 foreach my $dr ( $term->each_definition_reference() ) {
42 print $dr, "\n";
43 }
44
45 # etc.
46
47 =head1 DESCRIPTION
48
49 This is "dumb" class for GO terms (it provides no functionality related to graphs).
50 Implements Bio::Ontology::TermI.
51
52 =head1 FEEDBACK
53
54 =head2 Mailing Lists
55
56 User feedback is an integral part of the evolution of this and other
57 Bioperl modules. Send your comments and suggestions preferably to one
58 of the Bioperl mailing lists. Your participation is much appreciated.
59
60 bioperl-l@bioperl.org - General discussion
61 http://bio.perl.org/MailList.html - About the mailing lists
62
63 =head2 Reporting Bugs
64
65 Report bugs to the Bioperl bug tracking system to help us keep track
66 the bugs and their resolution. Bug reports can be submitted via email
67 or the web:
68
69 bioperl-bugs@bio.perl.org
70 http://bugzilla.bioperl.org/
71
72 =head1 AUTHOR
73
74 Christian M. Zmasek
75
76 Email: czmasek@gnf.org or cmzmasek@yahoo.com
77
78 WWW: http://www.genetics.wustl.edu/eddy/people/zmasek/
79
80 Address:
81
82 Genomics Institute of the Novartis Research Foundation
83 10675 John Jay Hopkins Drive
84 San Diego, CA 92121
85
86 =head1 APPENDIX
87
88 The rest of the documentation details each of the object
89 methods.
90
91 =cut
92
93
94 # Let the code begin...
95
96 package Bio::Ontology::GOterm;
97 use vars qw( @ISA );
98 use strict;
99 use Bio::Ontology::Term;
100
101 use constant GOID_DEFAULT => "GO:0000000";
102 use constant TRUE => 1;
103 use constant FALSE => 0;
104
105 @ISA = qw( Bio::Ontology::Term );
106
107
108
109
110 =head2 new
111
112 Title : new
113 Usage : $term = Bio::Ontology::GOterm->new( -go_id => "GO:0016847",
114 -name => "1-aminocyclopropane-1-carboxylate synthase",
115 -definition => "Catalysis of ...",
116 -is_obsolete => 0,
117 -comment => "" );
118 Function: Creates a new Bio::Ontology::GOterm.
119 Returns : A new Bio::Ontology::GOterm object.
120 Args : -go_id => the goid of this GO term [GO:nnnnnnn]
121 or [nnnnnnn] (nnnnnnn is a zero-padded
122 integer of seven digits)
123 -name => the name of this GO term [scalar]
124 -definition => the definition of this GO term [scalar]
125 -ontology => the ontology for this term (a
126 Bio::Ontology::OntologyI compliant object)
127 -version => version information [scalar]
128 -is_obsolete => the obsoleteness of this GO term [0 or 1]
129 -comment => a comment [scalar]
130
131 =cut
132
133 sub new {
134
135 my( $class,@args ) = @_;
136
137 my $self = $class->SUPER::new( @args );
138
139 my ( $GO_id )
140 = $self->_rearrange( [ qw( GO_ID ) ], @args );
141
142 $GO_id && $self->GO_id( $GO_id );
143
144
145 return $self;
146
147 } # new
148
149
150 =head2 init
151
152 Title : init()
153 Usage : $term->init();
154 Function: Initializes this GOterm to all "" and empty lists.
155 Returns :
156 Args :
157
158 =cut
159
160 sub init {
161
162 my $self = shift;
163
164 # first call the inherited version to properly chain up the hierarchy
165 $self->SUPER::init(@_);
166
167 # then only initialize what we implement ourselves here
168 #$self->GO_id( GOID_DEFAULT );
169
170 } # init
171
172
173
174
175 =head2 GO_id
176
177 Title : GO_id
178 Usage : $term->GO_id( "GO:0003947" );
179 or
180 print $term->GO_id();
181 Function: Set/get for the goid of this GO term.
182
183 This is essentially an alias to identifier(), with added
184 format checking.
185
186 Returns : The goid [GO:nnnnnnn].
187 Args : The goid [GO:nnnnnnn] or [nnnnnnn] (nnnnnnn is a
188 zero-padded integer of seven digits) (optional).
189
190 =cut
191
192 sub GO_id {
193 my $self = shift;
194 my $value;
195
196 if ( @_ ) {
197 $value = $self->_check_go_id( shift );
198 unshift(@_, $value);
199 }
200
201 return $self->identifier( @_ );
202
203 } # GO_id
204
205
206 =head2 get_secondary_GO_ids
207
208 Title : get_secondary_GO_ids
209 Usage : @ids = $term->get_secondary_GO_ids();
210 Function: Returns a list of secondary goids of this Term.
211
212 This is aliased to remove_secondary_ids().
213
214 Returns : A list of secondary goids [array of [GO:nnnnnnn]]
215 (nnnnnnn is a zero-padded integer of seven digits).
216 Args :
217
218 =cut
219
220 sub get_secondary_GO_ids {
221 return shift->get_secondary_ids(@_);
222 } # get_secondary_GO_ids
223
224
225 =head2 add_secondary_GO_id
226
227 Title : add_secondary_GO_id
228 Usage : $term->add_secondary_GO_id( @ids );
229 or
230 $term->add_secondary_GO_id( $id );
231 Function: Pushes one or more secondary goids into
232 the list of secondary goids.
233
234 This is aliased to remove_secondary_ids().
235
236 Returns :
237 Args : One secondary goid [GO:nnnnnnn or nnnnnnn] or a list
238 of secondary goids [array of [GO:nnnnnnn or nnnnnnn]]
239 (nnnnnnn is a zero-padded integer of seven digits).
240
241 =cut
242
243 sub add_secondary_GO_id {
244 return shift->add_secondary_id(@_);
245 } # add_secondary_GO_id
246
247
248 =head2 remove_secondary_GO_ids
249
250 Title : remove_secondary_GO_ids()
251 Usage : $term->remove_secondary_GO_ids();
252 Function: Deletes (and returns) the secondary goids of this Term.
253
254 This is aliased to remove_secondary_ids().
255
256 Returns : A list of secondary goids [array of [GO:nnnnnnn]]
257 (nnnnnnn is a zero-padded integer of seven digits).
258 Args :
259
260 =cut
261
262 sub remove_secondary_GO_ids {
263 return shift->remove_secondary_ids(@_);
264 } # remove_secondary_GO_ids
265
266
267
268
269 =head2 to_string
270
271 Title : to_string()
272 Usage : print $term->to_string();
273 Function: to_string method for GO terms.
274 Returns : A string representation of this GOterm.
275 Args :
276
277 =cut
278
279 sub to_string {
280 my( $self ) = @_;
281
282 my $s = "";
283
284 $s .= "-- GO id:\n";
285 $s .= ($self->GO_id() || '')."\n";
286 $s .= "-- Name:\n";
287 $s .= ($self->name() || '') ."\n";
288 $s .= "-- Definition:\n";
289 $s .= ($self->definition() || '') ."\n";
290 $s .= "-- Category:\n";
291 if ( defined( $self->ontology() ) ) {
292 $s .= $self->ontology()->name()."\n";
293 }
294 else {
295 $s .= "\n";
296 }
297 $s .= "-- Version:\n";
298 $s .= ($self->version() || '') ."\n";
299 $s .= "-- Is obsolete:\n";
300 $s .= $self->is_obsolete()."\n";
301 $s .= "-- Comment:\n";
302 $s .= ($self->comment() || '') ."\n";
303 $s .= "-- Definition references:\n";
304 $s .= $self->_array_to_string( $self->get_dblinks() )."\n";
305 $s .= "-- Secondary GO ids:\n";
306 $s .= $self->_array_to_string( $self->get_secondary_GO_ids() )."\n";
307 $s .= "-- Aliases:\n";
308 $s .= $self->_array_to_string( $self->get_synonyms() );
309
310 return $s;
311
312 } # to_string
313
314
315
316
317 # Title : _check_go_id
318 # Function: Checks whether the argument is [GO:nnnnnnn].
319 # If "GO:" is not present, it adds it.
320 # Returns : The canonical GO id.
321 # Args : The value to be checked.
322 sub _check_go_id {
323 my ( $self, $value ) = @_;
324 unless ( $value =~ /^(GO:)?\d{7}$/ || $value eq GOID_DEFAULT ) {
325 $self->throw( "Found [" . $value
326 . "] where [GO:nnnnnnn] or [nnnnnnn] expected" );
327 }
328 unless ( $value =~ /^GO:/ ) {
329 $value = "GO:".$value;
330 }
331 return $value;
332 } # _check_go_id
333
334
335
336 # Title : _array_to_string
337 # Function:
338 # Returns :
339 # Args :
340 sub _array_to_string {
341 my( $self, @value ) = @_;
342
343 my $s = "";
344
345 for ( my $i = 0; $i < scalar( @value ); ++$i ) {
346 if ( ! ref( $value[ $i ] ) ) {
347 $s .= "#" . $i . "\n-- " . $value[ $i ] . "\n";
348 }
349 }
350
351 return $s;
352
353 } # _array_to_string
354
355 #################################################################
356 # aliases or forwards to maintain backward compatibility
357 #################################################################
358
359 *each_secondary_GO_id = \&get_secondary_GO_ids;
360 *add_secondary_GO_ids = \&add_secondary_GO_id;
361
362 1;