| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: Association.pm,v 1.7 2007/03/27 22:36:16 sjcarbon Exp $ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This GO module is maintained by Chris Mungall |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# see also - http://www.geneontology.org |
|
6
|
|
|
|
|
|
|
# - http://www.fruitfly.org/annot/go |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package GO::Model::Association; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
GO::Model::Association; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# print all gene products associated with a GO::Model::Term |
|
19
|
|
|
|
|
|
|
my $assoc_l = $term->association_list; |
|
20
|
|
|
|
|
|
|
foreach my $assoc (@$assoc_l) { |
|
21
|
|
|
|
|
|
|
printf "gene product:%s %s %s (evidence: %s)\n", |
|
22
|
|
|
|
|
|
|
$assoc->gene_product->symbol, |
|
23
|
|
|
|
|
|
|
$assoc->is_not ? "IS NOT" : "IS", |
|
24
|
|
|
|
|
|
|
$term->name, |
|
25
|
|
|
|
|
|
|
map {$_->code} @{$assoc->evidence_list}; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Represents an association between a GO term (GO::Model::Term) and a |
|
31
|
|
|
|
|
|
|
gene product (GO::Model::GeneProduct) |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
24
|
|
|
24
|
|
210
|
use Carp; |
|
|
24
|
|
|
|
|
43
|
|
|
|
24
|
|
|
|
|
2190
|
|
|
37
|
24
|
|
|
24
|
|
129
|
use Exporter; |
|
|
24
|
|
|
|
|
47
|
|
|
|
24
|
|
|
|
|
842
|
|
|
38
|
24
|
|
|
24
|
|
132
|
use GO::Utils qw(rearrange); |
|
|
24
|
|
|
|
|
40
|
|
|
|
24
|
|
|
|
|
1052
|
|
|
39
|
24
|
|
|
24
|
|
131
|
use GO::Model::Root; |
|
|
24
|
|
|
|
|
47
|
|
|
|
24
|
|
|
|
|
506
|
|
|
40
|
24
|
|
|
24
|
|
11655
|
use GO::Model::Evidence; |
|
|
24
|
|
|
|
|
64
|
|
|
|
24
|
|
|
|
|
2087
|
|
|
41
|
24
|
|
|
24
|
|
263
|
use strict; |
|
|
24
|
|
|
|
|
48
|
|
|
|
24
|
|
|
|
|
931
|
|
|
42
|
24
|
|
|
24
|
|
877
|
use vars qw(@ISA); |
|
|
24
|
|
|
|
|
54
|
|
|
|
24
|
|
|
|
|
2306
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
24
|
|
|
24
|
|
219
|
use Data::Dumper; |
|
|
24
|
|
|
|
|
44
|
|
|
|
24
|
|
|
|
|
1319
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
24
|
|
|
24
|
|
130
|
use base qw(GO::Model::Root Exporter); |
|
|
24
|
|
|
|
|
44
|
|
|
|
24
|
|
|
|
|
58838
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _valid_params { |
|
50
|
605
|
|
|
605
|
|
2652
|
return qw(id gene_product evidence_list is_not role_group qualifier_list source_db_id assigned_by assocdate); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _initialize |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
346
|
|
|
346
|
|
441
|
my $self = shift; |
|
57
|
346
|
|
|
|
|
452
|
my $paramh = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# an association is a compound obj of both Association and |
|
60
|
|
|
|
|
|
|
# GeneProduct; both objs created together from same hash |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# sometimes this is from the external world and sometimes from the db |
|
63
|
346
|
|
|
|
|
487
|
my $product_h = {}; |
|
64
|
346
|
|
|
|
|
530
|
my $ev_h = {}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# SHULY Nov 28, 04 - added the gene product type to the product hash |
|
67
|
346
|
50
|
|
|
|
1113
|
if (defined ($paramh->{gene_product_id})) { |
|
68
|
0
|
|
|
|
|
0
|
$product_h->{speciesdb} = $paramh->{xref_dbname}; |
|
69
|
0
|
|
|
|
|
0
|
$product_h->{acc} = $paramh->{xref_key}; |
|
70
|
0
|
|
|
|
|
0
|
$product_h->{id} = $paramh->{gene_product_id}; |
|
71
|
0
|
|
|
|
|
0
|
$product_h->{symbol} = $paramh->{symbol}; |
|
72
|
0
|
0
|
|
|
|
0
|
$product_h->{full_name} = $paramh->{full_name} |
|
73
|
|
|
|
|
|
|
if defined ($paramh->{full_name}); |
|
74
|
|
|
|
|
|
|
# SHULY - added the type to the hash |
|
75
|
|
|
|
|
|
|
#$product_h->{type} = $paramh->{type_id}; |
|
76
|
0
|
|
|
|
|
0
|
$product_h->{type_id} = $paramh->{type_id}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
0
|
if (!$self->apph) { |
|
79
|
0
|
|
|
|
|
0
|
confess("ASSERTION ERROR"); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
my $product = $self->apph->create_gene_product_obj($product_h); |
|
83
|
0
|
|
|
|
|
0
|
$product->{species_id} = $paramh->{species_id}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
$self->gene_product($product); |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
delete $paramh->{xref_dbname}; |
|
88
|
0
|
|
|
|
|
0
|
delete $paramh->{xref_key}; |
|
89
|
0
|
|
|
|
|
0
|
delete $paramh->{gene_product_id}; |
|
90
|
0
|
|
|
|
|
0
|
delete $paramh->{symbol}; |
|
91
|
0
|
|
|
|
|
0
|
delete $paramh->{full_name}; |
|
92
|
|
|
|
|
|
|
# SHULY - added the type to the hash |
|
93
|
0
|
|
|
|
|
0
|
delete $paramh->{type_id}; |
|
94
|
0
|
|
|
|
|
0
|
delete $paramh->{species_id}; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
346
|
|
|
|
|
2721
|
$self->SUPER::_initialize($paramh); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 go_public_acc |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Usage - |
|
106
|
|
|
|
|
|
|
Returns - |
|
107
|
|
|
|
|
|
|
Args - |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub go_public_acc { |
|
112
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
113
|
0
|
0
|
|
|
|
0
|
$self->{go_public_acc} = shift if @_; |
|
114
|
0
|
|
0
|
|
|
0
|
return $self->{go_public_acc} || ''; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 add_evidence |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Usage - $assoc->add_evidence($my_evid); |
|
122
|
|
|
|
|
|
|
Returns - |
|
123
|
|
|
|
|
|
|
Args - GO::Model::Evidence |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub add_evidence { |
|
128
|
201
|
|
|
201
|
1
|
474
|
my $self = shift; |
|
129
|
201
|
100
|
|
|
|
508
|
if (!$self->{evidence_list}) { |
|
130
|
173
|
|
|
|
|
442
|
$self->{evidence_list} = []; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
201
|
|
|
|
|
257
|
push(@{$self->{evidence_list}}, (shift)); |
|
|
201
|
|
|
|
|
432
|
|
|
133
|
201
|
|
|
|
|
1022
|
return $self->{evidence_list}; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 evidence_list |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Usage - my $ev_l = $assoc->evidence_list; |
|
140
|
|
|
|
|
|
|
Returns - |
|
141
|
|
|
|
|
|
|
Args - |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
gets/sets arrayref of GO::Model::Evidence |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub evidence_list { |
|
148
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
149
|
0
|
0
|
|
|
|
0
|
$self->{evidence_list} = shift if @_; |
|
150
|
0
|
|
|
|
|
0
|
return $self->{evidence_list}; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 evidence_as_str |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Usage - print $assoc->evidence_as_str |
|
157
|
|
|
|
|
|
|
Usage - print $assoc->evidence_as_str(1); #verbose |
|
158
|
|
|
|
|
|
|
Returns - |
|
159
|
|
|
|
|
|
|
Args - verbose |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
concatenates evcodes together, for display |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub evidence_as_str { |
|
166
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
167
|
0
|
|
|
|
|
0
|
my $v = shift; |
|
168
|
0
|
0
|
|
|
|
0
|
if ($v) { |
|
169
|
|
|
|
|
|
|
return |
|
170
|
0
|
0
|
|
|
|
0
|
join("; ", |
|
|
|
0
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
map { |
|
172
|
0
|
0
|
|
|
|
0
|
sprintf("%s %s %s", |
|
173
|
|
|
|
|
|
|
$_->code, |
|
174
|
|
|
|
|
|
|
$_->seq_acc ? $_->seq_acc->as_str : "", |
|
175
|
|
|
|
|
|
|
$_->xref ? $_->xref->as_str : "") |
|
176
|
0
|
|
|
|
|
0
|
} @{$self->evidence_list || []}); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
else { |
|
179
|
0
|
0
|
|
|
|
0
|
return join("; ", map {$_->code} @{$self->evidence_list || []}); |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 has_evcode |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Usage - if $assoc->has_evcode("IEA"); |
|
186
|
|
|
|
|
|
|
Returns - boolean |
|
187
|
|
|
|
|
|
|
Args - evcode [string] |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub has_evcode { |
|
192
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
193
|
0
|
|
|
|
|
0
|
my $code = shift; |
|
194
|
0
|
0
|
|
|
|
0
|
return grep {$_->code eq $code} @{$self->evidence_list || []}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 remove_evcode |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Usage - $assoc->remove_evcode("IEA"); |
|
200
|
|
|
|
|
|
|
Returns - |
|
201
|
|
|
|
|
|
|
Args - evcode [string] |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
removes all evidence of the specified type from the |
|
204
|
|
|
|
|
|
|
association; useful for filtering |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub remove_evcode { |
|
209
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
210
|
0
|
|
|
|
|
0
|
my $code = shift; |
|
211
|
0
|
|
|
|
|
0
|
my @ok_ev = |
|
212
|
0
|
0
|
|
|
|
0
|
grep {$_->code ne $code} @{$self->evidence_list || []}; |
|
|
0
|
|
|
|
|
0
|
|
|
213
|
0
|
|
|
|
|
0
|
$self->evidence_list(\@ok_ev); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 evidence_score |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Usage - my $score = $assoc->evidence_score |
|
220
|
|
|
|
|
|
|
Returns - 0 <= float <= 1 |
|
221
|
|
|
|
|
|
|
Args - |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
returns a score for the association based on the evidence; |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This is an EXPERIMENTAL method; it may be removed in future versions. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
The evidence fields can be thought of in a loose hierachy: |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
TAS |
|
230
|
|
|
|
|
|
|
IDA |
|
231
|
|
|
|
|
|
|
IMP/IGI/IPI |
|
232
|
|
|
|
|
|
|
ISS |
|
233
|
|
|
|
|
|
|
NAS |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
see http://www.geneontology.org/GO.evidence.html |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=cut |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub evidence_score { |
|
240
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
241
|
0
|
|
|
|
|
0
|
my %probs = qw(IEA 0.1 |
|
242
|
|
|
|
|
|
|
NAS 0.3 |
|
243
|
|
|
|
|
|
|
NR 0.3 |
|
244
|
|
|
|
|
|
|
ISS 0.4 |
|
245
|
|
|
|
|
|
|
IMP 0.6 |
|
246
|
|
|
|
|
|
|
IGI 0.6 |
|
247
|
|
|
|
|
|
|
IPI 0.6 |
|
248
|
|
|
|
|
|
|
IDA 0.8 |
|
249
|
|
|
|
|
|
|
TAS 0.9); |
|
250
|
0
|
|
|
|
|
0
|
my $np = 1; |
|
251
|
0
|
0
|
|
|
|
0
|
map {$np *= (1 - $probs{$_}) } @{$self->evcodes||[]}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
252
|
0
|
|
|
|
|
0
|
return 1 - $np; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 gene_product |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Usage - my $gp = $assoc->gene_product |
|
258
|
|
|
|
|
|
|
Returns - |
|
259
|
|
|
|
|
|
|
Args - |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
gets sets GO::Model::GeneProduct |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=cut |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub gene_product { |
|
266
|
518
|
|
|
518
|
1
|
1423
|
my $self = shift; |
|
267
|
518
|
100
|
|
|
|
1277
|
$self->{gene_product} = shift if @_; |
|
268
|
518
|
|
|
|
|
1753
|
return $self->{gene_product}; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 assigned_by |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Usage - |
|
275
|
|
|
|
|
|
|
Returns - |
|
276
|
|
|
|
|
|
|
Args - |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=cut |
|
279
|
|
|
|
|
|
|
#autoloaded |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=head2 is_not |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
Usage - |
|
284
|
|
|
|
|
|
|
Returns - |
|
285
|
|
|
|
|
|
|
Args - |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
gets/sets boolean representing whether this relationship is negated |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=cut |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub is_not { |
|
292
|
173
|
|
|
173
|
1
|
247
|
my $self = shift; |
|
293
|
173
|
50
|
|
|
|
728
|
$self->{is_not} = shift if @_; |
|
294
|
173
|
|
|
|
|
791
|
return $self->{is_not}; |
|
295
|
|
|
|
|
|
|
} |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head2 assocdate |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Usage - |
|
300
|
|
|
|
|
|
|
Returns - |
|
301
|
|
|
|
|
|
|
Args - |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=cut |
|
304
|
|
|
|
|
|
|
#autoloaded |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head2 assocdate |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Usage - |
|
309
|
|
|
|
|
|
|
Returns - |
|
310
|
|
|
|
|
|
|
Args - |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
gets/sets integer representing the date of the association (YYYYMMDD format) |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=cut |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
sub assocdate { |
|
317
|
259
|
|
|
259
|
1
|
825
|
my $self = shift; |
|
318
|
259
|
100
|
|
|
|
989
|
$self->{assocdate} = shift if @_; |
|
319
|
259
|
|
|
|
|
705
|
return $self->{assocdate}; |
|
320
|
|
|
|
|
|
|
} |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head2 role_group |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Usage - |
|
325
|
|
|
|
|
|
|
Returns - |
|
326
|
|
|
|
|
|
|
Args - |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
gets/sets integer to indicate which associations go together |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=cut |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
sub role_group { |
|
333
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
334
|
0
|
0
|
|
|
|
|
$self->{role_group} = shift if @_; |
|
335
|
0
|
|
|
|
|
|
return $self->{role_group}; |
|
336
|
|
|
|
|
|
|
} |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub from_idl { |
|
339
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
340
|
0
|
|
|
|
|
|
my $h = shift; |
|
341
|
0
|
|
|
|
|
|
map { |
|
342
|
0
|
|
|
|
|
|
$_ = GO::Model::Evidence->from_idl($_); |
|
343
|
0
|
|
|
|
|
|
} @{$h->{"evidence_list"}}; |
|
344
|
0
|
|
|
|
|
|
$h->{"gene_product"} = |
|
345
|
|
|
|
|
|
|
GO::Model::GeneProduct->from_idl($h->{"gene_product"}); |
|
346
|
0
|
|
|
|
|
|
return $class->new($h); |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub to_idl_struct { |
|
350
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
351
|
0
|
|
|
|
|
|
my $struct; |
|
352
|
0
|
|
|
|
|
|
eval { |
|
353
|
0
|
|
|
|
|
|
$struct = |
|
354
|
|
|
|
|
|
|
{ |
|
355
|
0
|
|
|
|
|
|
"evidence_list"=>[map {$_->to_idl_struct} @{$self->evidence_list()}], |
|
|
0
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
"gene_product"=>$self->gene_product->to_idl_struct, |
|
357
|
|
|
|
|
|
|
"reference"=>"" |
|
358
|
|
|
|
|
|
|
}; |
|
359
|
|
|
|
|
|
|
}; |
|
360
|
0
|
0
|
|
|
|
|
if ($@) { |
|
361
|
0
|
|
|
|
|
|
print $self->dump; |
|
362
|
0
|
|
|
|
|
|
print $@; |
|
363
|
0
|
|
|
|
|
|
throw POA_GO::ProcessError(); |
|
364
|
|
|
|
|
|
|
} |
|
365
|
0
|
|
|
|
|
|
return $struct; |
|
366
|
|
|
|
|
|
|
} |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
sub to_ptuples { |
|
369
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
370
|
0
|
|
|
|
|
|
my ($term, $th) = |
|
371
|
|
|
|
|
|
|
rearrange([qw(term tuples)], @_); |
|
372
|
0
|
|
|
|
|
|
my @s = (); |
|
373
|
0
|
|
|
|
|
|
foreach my $e (@{$self->evidence_list()}) { |
|
|
0
|
|
|
|
|
|
|
|
374
|
0
|
|
|
|
|
|
my @xids = (); |
|
375
|
0
|
0
|
|
|
|
|
foreach my $x (@{$e->xref_list || []}) { |
|
|
0
|
|
|
|
|
|
|
|
376
|
0
|
|
|
|
|
|
push(@s, |
|
377
|
|
|
|
|
|
|
$x->to_ptuples(-tuples=>$th) |
|
378
|
|
|
|
|
|
|
); |
|
379
|
0
|
|
|
|
|
|
push(@xids, $x->as_str); |
|
380
|
|
|
|
|
|
|
} |
|
381
|
0
|
|
|
|
|
|
push(@s, |
|
382
|
|
|
|
|
|
|
["assoc", |
|
383
|
|
|
|
|
|
|
$term->acc, |
|
384
|
|
|
|
|
|
|
$self->gene_product->xref->as_str, |
|
385
|
|
|
|
|
|
|
$e->code, |
|
386
|
|
|
|
|
|
|
"[".join(", ", @xids)."]", |
|
387
|
|
|
|
|
|
|
], |
|
388
|
|
|
|
|
|
|
$self->gene_product->to_ptuples(-tuples=>$th), |
|
389
|
|
|
|
|
|
|
); |
|
390
|
|
|
|
|
|
|
} |
|
391
|
0
|
|
|
|
|
|
@s; |
|
392
|
|
|
|
|
|
|
} |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
# **** EXPERIMENTAL CODE **** |
|
395
|
|
|
|
|
|
|
# the idea is to be homogeneous and use graphs for |
|
396
|
|
|
|
|
|
|
# everything; eg gene products are nodes in a graph, |
|
397
|
|
|
|
|
|
|
# associations are arcs |
|
398
|
|
|
|
|
|
|
# cf rdf, daml+oil etc |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# args - optional graph to add to |
|
401
|
|
|
|
|
|
|
sub graphify { |
|
402
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
403
|
0
|
|
|
|
|
|
my ($term, $subg, $opts) = |
|
404
|
|
|
|
|
|
|
rearrange([qw(term graph opts)], @_); |
|
405
|
|
|
|
|
|
|
|
|
406
|
0
|
0
|
|
|
|
|
$opts = {} unless $opts; |
|
407
|
0
|
0
|
|
|
|
|
$subg = $self->apph->create_graph_obj unless $subg; |
|
408
|
|
|
|
|
|
|
|
|
409
|
0
|
|
|
|
|
|
my $acc = sprintf("%s", $self); |
|
410
|
0
|
|
|
|
|
|
my $t = |
|
411
|
|
|
|
|
|
|
$self->apph->create_term_obj({name=>$acc, |
|
412
|
|
|
|
|
|
|
acc=>$acc}); |
|
413
|
0
|
|
|
|
|
|
$subg->add_node($t); |
|
414
|
0
|
0
|
|
|
|
|
$subg->add_arc($t, $term, "hasAssociation") if $term; |
|
415
|
|
|
|
|
|
|
|
|
416
|
0
|
0
|
|
|
|
|
foreach my $ev (@{$self->evidence_list || []}) { |
|
|
0
|
|
|
|
|
|
|
|
417
|
0
|
|
|
|
|
|
$ev->apph($self->apph); |
|
418
|
0
|
|
|
|
|
|
$ev->graphify($t, $subg); |
|
419
|
|
|
|
|
|
|
} |
|
420
|
0
|
|
|
|
|
|
my $gp = $self->gene_product; |
|
421
|
0
|
|
|
|
|
|
$gp->graphify($t, $subg); |
|
422
|
|
|
|
|
|
|
|
|
423
|
0
|
|
|
|
|
|
$subg; |
|
424
|
|
|
|
|
|
|
} |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
1; |