File Coverage

blib/lib/OBO/APO/GoaAssociation.pm
Criterion Covered Total %
statement 125 126 99.2
branch 56 76 73.6
condition n/a
subroutine 21 21 100.0
pod 13 18 72.2
total 215 241 89.2


line stmt bran cond sub pod time code
1             # $Id: GoaAssociation.pm 2010-09-29 erick.antezana $
2             #
3             # Module : GoaAssociation.pm
4             # Purpose : GOA associaton entry structure.
5             # License : Copyright (c) 2006 ONTO-perl. All rights reserved.
6             # This program is free software; you can redistribute it and/or
7             # modify it under the same terms as Perl itself.
8              
9             package OBO::APO::GoaAssociation;
10              
11             =head1 NAME
12              
13             OBO::APO::GoaAssociation - A GOA association record.
14              
15             =head1 SYNOPSIS
16              
17             use OBO::APO::GoaAssociation;
18             use strict;
19              
20             # three new assoc's
21             my $goa_association1 = OBO::APO::GoaAssociation->new();
22             my $goa_association2 = OBO::APO::GoaAssociation->new();
23             my $goa_association3 = OBO::APO::GoaAssociation->new();
24              
25             $goa_association1->assc_id("APO:vm");
26             $goa_association1->description("this is a description");
27              
28             $goa_association2->assc_id("APO:ls");
29             $goa_association3->assc_id("APO:ea");
30              
31             my $goa_association4 = $goa_association3;
32              
33             my $goa_association5 = OBO::APO::GoaAssociation->new();
34             $goa_association5->assc_id("APO:vm");
35             $goa_association5->description("this is a description");
36              
37              
38             =head1 DESCRIPTION
39              
40             A goa_association object encapsulates the structure of a GOA association record.
41              
42             =head1 COPYRIGHT AND LICENSE
43              
44             Copyright (C) 2006 by ONTO-perl
45              
46             This library is free software; you can redistribute it and/or modify
47             it under the same terms as Perl itself, either Perl version 5.8.7 or,
48             at your option, any later version of Perl 5 you may have available.
49              
50             =cut
51              
52 4     4   4658 use strict;
  4         6  
  4         134  
53 4     4   18 use warnings;
  4         5  
  4         95  
54 4     4   22 use Carp;
  4         4  
  4         4332  
55              
56             sub new {
57 39     39 0 152 my $class = shift;
58 39         47 my $self = {};
59            
60 39         64 $self->{ASSC_ID} = ""; # required, scalar (1), unique association identifier
61 39         51 $self->{OBJ_SRC} = ""; # required, scalar (1), source database of the DB object (here protein) being annotated
62 39         51 $self->{OBJ_ID} = ""; # required, scalar (1), DB object (here protein) ID in the source DB
63 39         49 $self->{OBJ_SYMB} = ""; # required, scalar (1), (unique and valid) symbol to which object ID is matched
64 39         46 $self->{QUALIFIER} = ""; # scalar (0..1), flags modifying the interpretation of an annotation
65 39         47 $self->{GO_ID} = ""; # required, scalar (1), GO term ID
66 39         44 $self->{REFER} = ""; # required, scalar (1), reference cited to support the annotation, format database:reference
67 39         73 $self->{EVID_CODE} = ""; # required, scalar (1), evidence code (IMP, IC, IGI, IPI, ISS, IDA, IEP, IEA, TAS, NAS, NR, ND or RCA)
68 39         42 $self->{SUP_REF} = ""; # scalar (0..1), an additional identifier to support annotations, format database:ID
69 39         52 $self->{ASPECT} = ""; # required, scalar (1), P (biological process), F (molecular function), C (cellular component)
70 39         46 $self->{DESCRIPTION} = ""; # scalar (0..1), name(s) of gene/protein (optional), abbreviated description
71 39         48 $self->{SYNONYM} = ""; # required, scalar (1), here Iternational Protein Index identifier
72 39         44 $self->{TYPE} = ""; # required, scalar (1), kind of entity being annotated (here protein)
73 39         46 $self->{TAXON} = ""; # required, scalar (1), NCBI identifier for the species being annotated, format taxon:ID
74 39         51 $self->{DATE} = ""; # required, scalar (1), the date of last annotation update in the format 'YYYYMMDD'
75 39         68 $self->{ANNOT_SRC} = ""; # required, scalar (1)), attribute describing the source of the annotation
76            
77 39         72 bless ($self, $class);
78 39         90 return $self;
79             }
80              
81             =head2 assc_id
82              
83             Usage - print $goa_association->assc_id() or $goa_association->assc_id($assc_id)
84             Returns - the association ID (string)
85             Args - the association ID (string)
86             Function - gets/sets the association ID
87            
88             =cut
89             sub assc_id {
90 58     58 1 68 my $self = shift;
91 58 100       115 if (@_) {
92 40         79 $self->{ASSC_ID} = shift;
93             } else { # get-mode
94 18 50       28 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
95             }
96 58         97 return $self->{ASSC_ID};
97             }
98             =head2 obj_src
99              
100             Usage - print $goa_association->obj_src() or $goa_association->obj_src($obj_src)
101             Returns - the source database of the object being annotated (string)
102             Args - the source database of the object being annotated (string)
103             Function - gets/sets the source database of the object being annotated
104            
105             =cut
106             sub obj_src {
107 74     74 0 88 my $self = shift;
108 74 100       104 if (@_) {
109 40         48 $self->{OBJ_SRC} = shift;
110             } else { # get-mode
111 34 50       56 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
112             }
113 74         108 return $self->{OBJ_SRC};
114             }
115              
116             =head2 obj_id
117              
118             Usage - print $goa_association->obj_id() or $goa_association->obj_id($obj_id)
119             Returns - the ID of the object being annotated (string)
120             Args - the ID of the object being annotated (string)
121             Function - gets/sets the ID of the object being annotated
122            
123             =cut
124             sub obj_id {
125 74     74 1 70 my $self = shift;
126 74 100       98 if (@_) {
127 40         55 $self->{OBJ_ID} = shift;
128             } else { # get-mode
129 34 50       55 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
130             }
131 74         110 return $self->{OBJ_ID};
132             }
133              
134             =head2 obj_symb
135              
136             Usage - print $goa_association->obj_symb() or $goa_association->obj_symb($obj_symb)
137             Returns - the symbol of the object being annotated (string)
138             Args - the symbol of the object being annotated (string)
139             Function - gets/sets the symbol of the object being annotated
140            
141             =cut
142             sub obj_symb {
143 58     58 1 64 my $self = shift;
144 58 100       80 if (@_) {
145 40         52 $self->{OBJ_SYMB} = shift;
146             } else { # get-mode
147 18 50       30 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
148             }
149 58         85 return $self->{OBJ_SYMB};
150             }
151              
152             =head2 qualifier
153              
154             Usage - print $goa_association->qualifier() or $goa_association->qualifier($qualifier)
155             Returns - the qualifier of the annotation (string)
156             Args - the qualifier of the annotation (string)
157             Function - gets/sets the qualifier of the annotation
158            
159             =cut
160             sub qualifier {
161 58     58 1 60 my $self = shift;
162 58 100       73 if (@_) {
163 40         60 $self->{QUALIFIER} = shift;
164             } else { # get-mode
165 18 50       28 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
166             }
167 58         82 return $self->{QUALIFIER};
168             }
169              
170             =head2 go_id
171              
172             Usage - print $goa_association->go_id() or $goa_association->go_id($go_id)
173             Returns - the GO term ID associated with the object (string)
174             Args - the GO term ID associated with the object (string)
175             Function - gets/sets the GO term ID associated with the object
176            
177             =cut
178             sub go_id {
179 74     74 1 87 my $self = shift;
180 74 100       110 if (@_) {
181 40         47 $self->{GO_ID} = shift;
182             } else { # get-mode
183 34 50       57 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
184             }
185 74         113 return $self->{GO_ID};
186             }
187             =head2 refer
188              
189             Usage - print $goa_association->refer() or $goa_association->refer($refer)
190             Returns - the reference cited to support the annotation (string)
191             Args - the reference cited to support the annotationt (string)
192             Function - gets/sets the reference cited to support the annotation
193            
194             =cut
195             sub refer {
196 58     58 0 66 my $self = shift;
197 58 100       77 if (@_) {
198 40         47 $self->{REFER} = shift;
199             } else { # get-mode
200 18 50       23 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
201             }
202 58         93 return $self->{REFER};
203             }
204              
205             =head2 evid_code
206              
207             Usage - print $goa_association->evid_code() or $goa_association->evid_code($evid_code)
208             Returns - the code of the supporting evidence (string)
209             Args - the code of the supporting evidence (string)
210             Function - gets/sets the code of the supporting evidence
211            
212             =cut
213             sub evid_code {
214 47     47 1 37 my $self = shift;
215 47 100       67 if (@_) {
216 29         36 $self->{EVID_CODE} = shift;
217             } else { # get-mode
218 18 50       32 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
219             }
220 47         66 return $self->{EVID_CODE};
221             }
222             =head2 sup_ref
223              
224             Usage - print $goa_association->sup_ref() or $goa_association->sup_ref($sup_ref)
225             Returns - the supplementary reference to support annotation (string)
226             Args - the supplementary reference to support annotation (string)
227             Function - gets/sets the supplementary reference to support annotation
228            
229             =cut
230             sub sup_ref {
231 58     58 0 61 my $self = shift;
232 58 100       71 if (@_) {
233 40         48 $self->{SUP_REF} = shift;
234             } else { # get-mode
235 18 50       27 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
236             }
237 58         81 return $self->{SUP_REF};
238             }
239             =head2 aspect
240              
241             Usage - print $goa_association->aspect() or $goa_association->aspect($aspect)
242             Returns - the aspect (P, F or C)
243             Args - the aspect (P, F or C)
244             Function - gets/sets the aspect
245            
246             =cut
247             sub aspect {
248 74     74 0 91 my $self = shift;
249 74 100       98 if (@_) {
250 40         51 $self->{ASPECT} = shift;
251             } else { # get-mode
252 34 50       52 carp "The ID of this association is not defined." if (!defined($self->{ASSC_ID}));
253             }
254 74         117 return $self->{ASPECT};
255             }
256              
257             =head2 description
258              
259             Usage - print $goa_association->description() or $goa_association->description($description)
260             Returns - the description of the object (string)
261             Args - the description of the object (string)
262             Function - gets/sets the description of the object
263            
264             =cut
265             sub description {
266 58     58 1 65 my $self = shift;
267 58 100       87 if (@_) {
268 40         46 $self->{DESCRIPTION} = shift;
269             } else { # get-mode
270 18 50       28 carp "The obj_src of this 'assoc' is not defined." if (!defined($self->{ASSC_ID}));
271             }
272 58         81 return $self->{DESCRIPTION};
273             }
274              
275             =head2 synonym
276              
277             Usage - print $goa_association->synonym() or $goa_association->synonym($synonym)
278             Returns - the Iternational Protein Index identifier of the object (string)
279             Args - the Iternational Protein Index identifier of the object (string)
280             Function - gets/sets the Iternational Protein Index identifier of the object
281            
282             =cut
283             sub synonym {
284 58     58 1 68 my $self = shift;
285 58 100       74 if (@_) {
286 40         46 $self->{SYNONYM} = shift;
287             } else { # get-mode
288 18 50       29 carp "The obj_src of this 'assoc' is not defined." if (!defined($self->{ASSC_ID}));
289             }
290 58         79 return $self->{SYNONYM};
291             }
292              
293             =head2 type
294              
295             Usage - print $goa_association->type() or $goa_association->type($type)
296             Returns - the type of the object (here "protein")
297             Args - the type of the object (here "protein")
298             Function - gets/sets the type of the object
299            
300             =cut
301             sub type {
302 58     58 1 66 my $self = shift;
303 58 100       79 if (@_) {
304 40         43 $self->{TYPE} = shift;
305             } else { # get-mode
306 18 50       28 carp "The obj_src of this 'assoc' is not defined." if (!defined($self->{ASSC_ID}));
307             }
308 58         121 return $self->{TYPE};
309             }
310              
311             =head2 taxon
312              
313             Usage - print $goa_association->taxon() or $goa_association->taxon($taxon)
314             Returns - the NCBI identifier of the biological species (string)
315             Args - the NCBI identifier of the biological species (string)
316             Function - gets/sets the NCBI identifier of the biological species
317            
318             =cut
319             sub taxon {
320 74     74 1 85 my $self = shift;
321 74 100       89 if (@_) {
322 40         48 $self->{TAXON} = shift;
323             } else { # get-mode
324 34 50       55 carp "The obj_src of this 'assoc' is not defined." if (!defined($self->{ASSC_ID}));
325             }
326 74         139 return $self->{TAXON};
327             }
328              
329             =head2 date
330              
331             Usage - print $goa_association->date() or $goa_association->date($date)
332             Returns - the date of last annotation update (string)
333             Args - the date of last annotation update (string)
334             Function - gets/sets the date of last annotation update
335            
336             =cut
337             sub date {
338 58     58 1 67 my $self = shift;
339 58 100       85 if (@_) {
340 40         45 $self->{DATE} = shift;
341             } else { # get-mode
342 18 50       29 carp "The obj_src of this 'assoc' is not defined." if (!defined($self->{ASSC_ID}));
343             }
344 58         80 return $self->{DATE};
345             }
346              
347             =head2 annot_src
348              
349             Usage - print $goa_association->annot_src() or $goa_association->annot_src($annot_src)
350             Returns - the the source of the annotation (string)
351             Args - the the source of the annotation (string)
352             Function - gets/sets the source of the annotation
353            
354             =cut
355             sub annot_src {
356 71     71 1 99 my $self = shift;
357 71 100       121 if (@_) {
358 53         69 $self->{ANNOT_SRC} = shift;
359             } else { # get-mode
360 18 50       34 carp "The obj_src of this 'assoc' is not defined." if (!defined($self->{ASSC_ID}));
361             }
362 71         99 return $self->{ANNOT_SRC};
363             }
364              
365             =head2 equals
366              
367             Usage - print $goa_association->equals($another_association)
368             Returns - either 1(true) or 0 (false)
369             Args - the association (OBO::APO::GoaAssociation) to compare with
370             Function - tells whether the two associations are identical
371            
372             =cut
373             sub equals {
374 160     160 1 120 my $self = shift;
375 160         113 my $result = 0;
376            
377 160 50       261 if (@_) {
378 160         107 my $target = shift;
379 160         116 $result = 1;
380            
381 160         528 my @this = (keys %$self);
382 160         554 my @that = (keys %$target);
383 160 50       224 foreach (@this) {croak "The value of $_ of this association is undefined" if (!defined($self->{$_}));}
  2560         3500  
384 160 50       218 foreach (@that) {croak "The value of $_ of this association is undefined" if (!defined($target->{$_}));}
  2560         3361  
385 160 50       214 if ($#this != $#that){
386 0         0 $result = 0;
387             } else {
388 160         132 foreach (@this){
389 577 100       847 $result = 0 unless ($self->{$_} eq $target->{$_});
390 577 100       858 last if $result == 0;
391             }
392             }
393 160         583 return $result;
394             }
395             }
396              
397             1;