line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: obj.pm,v 1.24 2008/01/17 20:08:14 cmungall Exp $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This GO module is maintained by Chris Mungall |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# see also - http://www.geneontology.org |
6
|
|
|
|
|
|
|
# - http://www.godatabase.org/dev |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
GO::Handlers::obj - parses GO files into GO object model |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use GO::Handlers::obj |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# makes objects from parser events |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package GO::Handlers::obj; |
29
|
13
|
|
|
13
|
|
79
|
use Data::Stag qw(:all); |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
10722
|
|
30
|
13
|
|
|
13
|
|
4352
|
use GO::Parsers::ParserEventNames; |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
4072
|
|
31
|
13
|
|
|
13
|
|
387
|
use base qw(GO::Handlers::base); |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
9272
|
|
32
|
13
|
|
|
13
|
|
93
|
use strict qw(vars refs); |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
825
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $TRACE = $ENV{GO_TRACE}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init { |
37
|
13
|
|
|
13
|
0
|
512
|
my $self = shift; |
38
|
13
|
|
|
|
|
128
|
$self->SUPER::init; |
39
|
|
|
|
|
|
|
|
40
|
13
|
|
|
13
|
|
2691
|
use GO::ObjCache; |
|
13
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
1016
|
|
41
|
13
|
|
|
|
|
235
|
my $apph = GO::ObjCache->new; |
42
|
13
|
|
|
|
|
33
|
$self->{apph} = $apph; |
43
|
|
|
|
|
|
|
|
44
|
13
|
|
|
13
|
|
104
|
use GO::Model::Graph; |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
55144
|
|
45
|
13
|
|
|
|
|
44
|
my $g = $self->apph->create_graph_obj; |
46
|
13
|
|
|
|
|
33
|
$self->{g} = $g; |
47
|
13
|
|
|
|
|
49
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 graph |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Usage - my $terms = $obj_handler->graph->get_all_terms; |
54
|
|
|
|
|
|
|
Synonym - g |
55
|
|
|
|
|
|
|
Synonym - ontology |
56
|
|
|
|
|
|
|
Returns - GO::Model::Graph object |
57
|
|
|
|
|
|
|
Args - |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
as files are parsed, objects are created; depending on what kind of |
60
|
|
|
|
|
|
|
datatype is being parsed, the classes of the created objects will be |
61
|
|
|
|
|
|
|
different - eg GO::Model::Term, GO::Model::Association etc |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
the way to access all of thses is through the top level graph object |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
eg |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$parser = GO::Parser->new({handler=>'obj'}); |
68
|
|
|
|
|
|
|
$parser->parse(@files); |
69
|
|
|
|
|
|
|
my $graph = $parser->graph; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub g { |
74
|
3571
|
|
|
3571
|
0
|
6720
|
my $self = shift; |
75
|
3571
|
50
|
|
|
|
7122
|
$self->{g} = shift if @_; |
76
|
3571
|
|
|
|
|
24318
|
return $self->{g}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
*graph = \&g; |
80
|
|
|
|
|
|
|
*ontology = \&g; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub apph { |
83
|
2672
|
|
|
2672
|
0
|
3457
|
my $self = shift; |
84
|
2672
|
50
|
|
|
|
5763
|
$self->{apph} = shift if @_; |
85
|
2672
|
|
|
|
|
12719
|
return $self->{apph}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub root_term { |
89
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
90
|
0
|
0
|
|
|
|
0
|
$self->{_root_term} = shift if @_; |
91
|
0
|
|
|
|
|
0
|
return $self->{_root_term}; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# 20041029 - not currently used |
95
|
|
|
|
|
|
|
sub add_root { |
96
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
97
|
0
|
|
|
|
|
0
|
my $g = $self->g; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
my $root = $self->apph->create_term_obj; |
100
|
0
|
|
|
|
|
0
|
$root->name('root'); |
101
|
0
|
|
|
|
|
0
|
$root->acc('root'); |
102
|
0
|
|
|
|
|
0
|
$g->add_term($root); |
103
|
0
|
|
|
|
|
0
|
$self->root_term($root); |
104
|
0
|
|
|
|
|
0
|
$self->root_to_be_added(1); |
105
|
0
|
|
|
|
|
0
|
$root; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# -- HANDLER METHODS -- |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub e_obo { |
111
|
13
|
|
|
13
|
0
|
747
|
my $self = shift; |
112
|
13
|
|
|
|
|
44
|
my $g = $self->g; |
113
|
13
|
|
|
|
|
55
|
return (); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub e_typedef { |
117
|
32
|
|
|
32
|
0
|
1965
|
my $self = shift; |
118
|
32
|
|
|
|
|
49
|
my $t = shift; |
119
|
32
|
|
|
|
|
95
|
$self->stanza('Typedef', $t); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub e_term { |
123
|
1337
|
|
|
1337
|
0
|
63762
|
my $self = shift; |
124
|
1337
|
|
|
|
|
1709
|
my $t = shift; |
125
|
1337
|
|
|
|
|
2803
|
$self->stanza('Term', $t); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub e_instance { |
129
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
130
|
0
|
|
|
|
|
0
|
my $t = shift; |
131
|
0
|
|
|
|
|
0
|
$self->stanza('Instance', $t); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub stanza { |
135
|
1369
|
|
|
1369
|
0
|
1771
|
my $self = shift; |
136
|
1369
|
|
|
|
|
2570
|
my $stanza = lc(shift); |
137
|
1369
|
|
|
|
|
1645
|
my $tree = shift; |
138
|
1369
|
|
|
|
|
6669
|
my $acc = stag_get($tree, ID); |
139
|
1369
|
50
|
|
|
|
98284
|
if (!$acc) { |
140
|
0
|
|
|
|
|
0
|
$self->throw( "NO ACC: $@\n" ); |
141
|
|
|
|
|
|
|
} |
142
|
1369
|
|
|
|
|
1724
|
my $term; |
143
|
1369
|
|
|
|
|
1826
|
eval { |
144
|
1369
|
|
|
|
|
3682
|
$term = $self->g->get_term($acc); |
145
|
|
|
|
|
|
|
}; |
146
|
1369
|
50
|
|
|
|
6947
|
if ($@) { |
147
|
0
|
|
|
|
|
0
|
$self->throw( "ARG:$@" ); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
# no point adding term twice; we |
150
|
|
|
|
|
|
|
# assume the details are the same |
151
|
1369
|
50
|
66
|
|
|
3402
|
return $term if $term && $self->strictorder; |
152
|
|
|
|
|
|
|
|
153
|
1369
|
|
|
|
|
3060
|
$term = $self->apph->create_term_obj; |
154
|
|
|
|
|
|
|
|
155
|
1369
|
100
|
|
|
|
3394
|
if ($stanza eq 'typedef') { |
156
|
32
|
|
|
|
|
422
|
$term->is_relationship_type(1); |
157
|
|
|
|
|
|
|
} |
158
|
1369
|
50
|
|
|
|
2721
|
if ($stanza eq 'instance') { |
159
|
0
|
|
|
|
|
0
|
$term->is_instance(1); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
1369
|
|
|
|
|
2442
|
my %h = (); |
163
|
1369
|
|
|
|
|
5995
|
foreach my $sn (stag_kids($tree)) { |
164
|
4441
|
|
|
|
|
73378
|
my $k = $sn->name; |
165
|
4441
|
|
|
|
|
31945
|
my $v = $sn->data; |
166
|
|
|
|
|
|
|
|
167
|
4441
|
100
|
66
|
|
|
56495
|
if ($k eq RELATIONSHIP) { |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
168
|
129
|
|
|
|
|
582
|
my $obj = stag_get($sn, TO); |
169
|
129
|
|
|
|
|
10084
|
$self->g->add_relationship($obj, $term->acc, stag_get($sn, TYPE)); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
elsif ($k eq IS_A) { |
172
|
604
|
|
|
|
|
1350
|
$self->g->add_relationship($v, $term->acc, IS_A); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
elsif ($k eq INSTANCE_OF) { |
175
|
0
|
|
|
|
|
0
|
$self->g->add_relationship($v, $term->acc, INSTANCE_OF); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
elsif ($k eq DEF) { |
178
|
41
|
|
|
|
|
188
|
my $defstr = stag_get($sn, DEFSTR); |
179
|
41
|
|
|
|
|
2955
|
my @xrefs = stag_get($sn, DBXREF); |
180
|
41
|
|
|
|
|
3515
|
$term->definition($defstr); |
181
|
41
|
|
|
|
|
320
|
$term->add_definition_dbxref($self->dbxref($_)) foreach @xrefs; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
elsif ($k eq SYNONYM) { |
184
|
124
|
|
|
|
|
587
|
my $synstr = stag_get($sn, SYNONYM_TEXT); |
185
|
124
|
|
|
|
|
7016
|
my $type = stag_find($sn, 'scope'); |
186
|
124
|
|
|
|
|
14207
|
my @xrefs = stag_get($sn, DBXREF); |
187
|
124
|
100
|
|
|
|
6175
|
$term->add_synonym_by_type($type ? lc($type) : '', $synstr); |
188
|
|
|
|
|
|
|
# $term->add_definition_dbxref($_) foreach @xrefs; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
elsif ($k eq ALT_ID) { |
191
|
15
|
|
|
|
|
61
|
$term->add_alt_id($v); |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
elsif ($k eq CONSIDER) { |
194
|
0
|
|
|
|
|
0
|
$term->add_consider($v); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
elsif ($k eq REPLACED_BY) { |
197
|
0
|
|
|
|
|
0
|
$term->add_replaced_by($v); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
elsif ($k eq ALT_ID) { |
200
|
0
|
|
|
|
|
0
|
$term->add_alt_id($v); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
elsif ($k eq XREF_ANALOG || $k eq XREF) { |
203
|
755
|
|
|
|
|
1523
|
my $xref = |
204
|
|
|
|
|
|
|
$self->apph->create_xref_obj(stag_pairs($sn)); |
205
|
755
|
|
|
|
|
3484
|
$term->add_dbxref($xref); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
elsif ($k eq XREF_UNKNOWN) { |
208
|
0
|
|
|
|
|
0
|
my $xref = |
209
|
|
|
|
|
|
|
$self->apph->create_xref_obj(stag_pairs($sn)); |
210
|
0
|
|
|
|
|
0
|
$term->add_dbxref($xref); |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
elsif ($k eq ID) { |
213
|
1369
|
|
|
|
|
3622
|
$term->acc($v); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
elsif ($k eq NAMESPACE) { |
216
|
652
|
|
|
|
|
1952
|
$term->namespace($v); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
elsif ($k eq NAME) { |
219
|
653
|
|
|
|
|
2154
|
$term->name($v); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
elsif ($k eq SUBSET) { |
222
|
23
|
|
|
|
|
168
|
$term->add_subset($v); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
elsif ($k eq COMMENT) { |
225
|
8
|
|
|
|
|
46
|
$term->comment($v); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
elsif ($k eq IS_ROOT) { |
228
|
12
|
|
|
|
|
77
|
$term->is_root($v); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
elsif ($k eq BUILTIN) { |
231
|
|
|
|
|
|
|
# ignore |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
elsif ($k eq PROPERTY_VALUE) { |
234
|
|
|
|
|
|
|
# ignore |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
elsif ($k eq IS_METADATA_TAG) { |
237
|
|
|
|
|
|
|
# ignore |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
elsif ($k eq IS_OBSOLETE) { |
240
|
0
|
|
|
|
|
0
|
$term->is_obsolete($v); |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
elsif ($k eq IS_TRANSITIVE || |
243
|
|
|
|
|
|
|
$k eq IS_SYMMETRIC || |
244
|
|
|
|
|
|
|
$k eq IS_ANTI_SYMMETRIC || |
245
|
|
|
|
|
|
|
$k eq IS_REFLEXIVE || |
246
|
|
|
|
|
|
|
$k eq INVERSE_OF || |
247
|
|
|
|
|
|
|
$k eq TRANSITIVE_OVER || |
248
|
|
|
|
|
|
|
$k eq DOMAIN || |
249
|
|
|
|
|
|
|
$k eq RANGE) { |
250
|
49
|
|
|
|
|
88
|
my $m = lc($k); |
251
|
49
|
|
|
|
|
1079
|
$term->$m($v); |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
elsif ($term->can("add_$k")) { |
254
|
|
|
|
|
|
|
# CONVENIENCE METHOD - map directly to object method |
255
|
0
|
|
|
|
|
0
|
warn("add method for $k"); |
256
|
0
|
|
|
|
|
0
|
my $m = "add_$k"; |
257
|
0
|
|
|
|
|
0
|
$term->$m($v); |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
elsif ($term->can($k)) { |
260
|
0
|
|
|
|
|
0
|
warn("add method for $k"); |
261
|
|
|
|
|
|
|
# CONVENIENCE METHOD - map directly to object method |
262
|
0
|
|
|
|
|
0
|
$term->$k($v); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
elsif ($k eq INTERSECTION_OF) { |
265
|
4
|
|
|
|
|
19
|
my $rel = stag_get($sn, TYPE); |
266
|
4
|
|
|
|
|
236
|
my $obj = stag_get($sn, TO); |
267
|
4
|
|
|
|
|
218
|
my $isect = [$rel,$obj]; |
268
|
4
|
|
|
|
|
18
|
my $ns = stag_find($sn, 'namespace'); |
269
|
4
|
100
|
|
|
|
491
|
if (!$rel) { |
270
|
2
|
|
|
|
|
12
|
shift @$isect; |
271
|
|
|
|
|
|
|
} |
272
|
4
|
|
|
|
|
37
|
my $ldef = $term->logical_definition; |
273
|
4
|
100
|
|
|
|
15
|
if (!$ldef) { |
274
|
2
|
|
|
|
|
7
|
$ldef = $self->apph->create_logical_definition_obj(); |
275
|
2
|
|
|
|
|
13
|
$term->logical_definition($ldef); |
276
|
|
|
|
|
|
|
} |
277
|
4
|
50
|
|
|
|
24
|
$ldef->namespace($ns) if ($ns); |
278
|
4
|
|
|
|
|
25
|
$ldef->add_intersection($isect); |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
elsif ($k eq UNION_OF) { |
281
|
0
|
|
|
|
|
0
|
my $obj = stag_get($sn, TO); |
282
|
0
|
|
|
|
|
0
|
$term->add_equivalent_to_union_of_term($obj); |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
elsif ($k eq DISJOINT_FROM) { |
285
|
2
|
|
|
|
|
27
|
$term->add_disjoint_from_term($v); |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
else { |
288
|
|
|
|
|
|
|
# warn("add method for $k"); |
289
|
0
|
|
|
|
|
0
|
$term->stag->add($k, $v); |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# $self->throw("don't know what to do with $k"); |
292
|
|
|
|
|
|
|
# print "no $k\n"; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
} |
295
|
1369
|
0
|
33
|
|
|
5377
|
if ($self->root_to_be_added && |
|
|
|
33
|
|
|
|
|
296
|
|
|
|
|
|
|
!$term->is_obsolete && |
297
|
|
|
|
|
|
|
$stanza eq 'term') { |
298
|
0
|
|
|
|
|
0
|
my $parents = $self->g->get_parent_relationships($term->acc); |
299
|
0
|
0
|
|
|
|
0
|
if (!@$parents) { |
300
|
0
|
|
0
|
|
|
0
|
my $root = $self->root_term || $self->throw("no root term"); |
301
|
0
|
|
|
|
|
0
|
$self->g->add_relationship($root, $term->acc, IS_A); |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# $term->type($self->{ontology_type}) unless $term->type; |
306
|
1369
|
100
|
|
|
|
3778
|
if (!$term->name) { |
307
|
|
|
|
|
|
|
# warn("no name; using acc ".$term->acc); |
308
|
|
|
|
|
|
|
# $term->name($term->acc); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
1369
|
|
|
|
|
3062
|
$self->g->add_term($term); |
312
|
1369
|
50
|
|
|
|
2723
|
printf STDERR "Added term %s %s\n", $term->acc, $term->name |
313
|
|
|
|
|
|
|
if $TRACE; |
314
|
|
|
|
|
|
|
# $term; |
315
|
1369
|
|
|
|
|
6044
|
return (); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub dbxref { |
319
|
53
|
|
|
53
|
0
|
80
|
my $self = shift; |
320
|
53
|
|
|
|
|
64
|
my $x = shift; |
321
|
53
|
|
|
|
|
119
|
$self->apph->create_xref_obj(stag_pairs($x)) |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub e_proddb { |
326
|
2
|
|
|
2
|
0
|
191
|
my $self = shift; |
327
|
2
|
|
|
|
|
11
|
$self->proddb(shift->data); |
328
|
2
|
|
|
|
|
7
|
return; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub e_prod { |
332
|
33
|
|
|
33
|
0
|
1340
|
my $self = shift; |
333
|
33
|
|
|
|
|
49
|
my $tree = shift; |
334
|
33
|
|
|
|
|
127
|
my $g = $self->g; |
335
|
33
|
|
|
|
|
101
|
my $prod = |
336
|
|
|
|
|
|
|
$self->apph->create_gene_product_obj({symbol=>stag_sget($tree, PRODSYMBOL), |
337
|
|
|
|
|
|
|
type=>stag_sget($tree, PRODTYPE), |
338
|
|
|
|
|
|
|
full_name=>stag_sget($tree, PRODNAME), |
339
|
|
|
|
|
|
|
speciesdb=>$self->proddb, |
340
|
|
|
|
|
|
|
}); |
341
|
33
|
|
|
|
|
244
|
my @syns = stag_get($tree, PRODSYN); |
342
|
33
|
|
|
|
|
5822
|
$prod->xref->xref_key(stag_sget($tree, PRODACC)); |
343
|
33
|
|
|
|
|
232
|
$prod->synonym_list(\@syns); |
344
|
33
|
|
|
|
|
179
|
my @assocs = stag_get($tree, ASSOC); |
345
|
33
|
|
|
|
|
6774
|
my $taxid = stag_get($tree, PRODTAXA); |
346
|
33
|
|
|
|
|
4868
|
my $species; |
347
|
33
|
50
|
|
|
|
152
|
if ($taxid) { |
348
|
33
|
|
|
|
|
113
|
$species = |
349
|
|
|
|
|
|
|
$self->apph->create_species_obj({ncbi_taxa_id=>$taxid}); |
350
|
33
|
|
|
|
|
200
|
$prod->species($species); |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
} |
353
|
33
|
|
|
|
|
98
|
foreach my $assoc (@assocs) { |
354
|
173
|
|
|
|
|
1009
|
my $acc = stag_get($assoc, TERMACC); |
355
|
173
|
50
|
|
|
|
19287
|
if (!$acc) { |
356
|
0
|
|
|
|
|
0
|
$self->message("no accession given"); |
357
|
0
|
|
|
|
|
0
|
next; |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
|
361
|
173
|
|
|
|
|
898
|
my $t = $g->get_term($acc); |
362
|
173
|
100
|
|
|
|
471
|
if (!$t) { |
363
|
40
|
50
|
|
|
|
299
|
if (!$self->strictorder) { |
364
|
40
|
|
|
|
|
88
|
$t = $self->apph->create_term_obj({acc=>$acc}); |
365
|
40
|
|
|
|
|
121
|
$self->g->add_term($t); |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
else { |
368
|
0
|
|
|
|
|
0
|
$self->message("no such term $acc"); |
369
|
0
|
|
|
|
|
0
|
next; |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
} |
372
|
173
|
|
|
|
|
813
|
my $aspect = stag_get($assoc, ASPECT); |
373
|
173
|
50
|
|
|
|
25165
|
if ($aspect) { |
374
|
173
|
|
|
|
|
959
|
$t->set_namespace_by_code($aspect); |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
173
|
|
|
|
|
722
|
my @evs = stag_get($assoc, EVIDENCE); |
378
|
173
|
|
|
|
|
16774
|
my $ao = |
379
|
|
|
|
|
|
|
$self->apph->create_association_obj({gene_product=>$prod, |
380
|
|
|
|
|
|
|
is_not=>stag_sget($assoc, IS_NOT), |
381
|
|
|
|
|
|
|
}); |
382
|
173
|
|
|
|
|
1044
|
my $date = stag_get($assoc,ASSOCDATE); |
383
|
173
|
50
|
|
|
|
15763
|
$ao->assocdate($date) if $date; |
384
|
|
|
|
|
|
|
|
385
|
173
|
|
|
|
|
670
|
my $assigned_by = stag_get($assoc,SOURCE_DB); |
386
|
173
|
50
|
|
|
|
15406
|
$ao->assigned_by($assigned_by) if $assigned_by; |
387
|
|
|
|
|
|
|
|
388
|
173
|
|
|
|
|
417
|
foreach my $ev (@evs) { |
389
|
201
|
|
|
|
|
468
|
my $eo = |
390
|
|
|
|
|
|
|
$self->apph->create_evidence_obj({ |
391
|
|
|
|
|
|
|
code=>stag_sget($ev, EVCODE), |
392
|
|
|
|
|
|
|
}); |
393
|
201
|
|
|
|
|
1160
|
my @seq_xrefs = stag_get($ev, WITH), |
394
|
|
|
|
|
|
|
my @refs = stag_get($ev, REF); |
395
|
201
|
|
|
|
|
24626
|
map { $eo->add_seq_xref($_) } @seq_xrefs; |
|
42
|
|
|
|
|
143
|
|
396
|
201
|
|
|
|
|
309
|
map { $eo->add_pub_xref($_) } @refs; |
|
273
|
|
|
|
|
811
|
|
397
|
201
|
|
|
|
|
705
|
$ao->add_evidence($eo); |
398
|
|
|
|
|
|
|
} |
399
|
173
|
|
|
|
|
633
|
$t->add_association($ao); |
400
|
|
|
|
|
|
|
} |
401
|
33
|
|
|
|
|
259
|
return; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
1; |