line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: ObjCache.pm,v 1.3 2005/05/20 18:46:57 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
|
|
|
|
|
|
|
package GO::ObjCache; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
GO::ObjCache; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This is a kind of L - you should not need to use this |
19
|
|
|
|
|
|
|
method directly |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
13
|
|
|
13
|
|
4041
|
use Carp; |
|
13
|
|
|
|
|
29
|
|
|
13
|
|
|
|
|
863
|
|
24
|
13
|
|
|
13
|
|
74
|
use strict; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
385
|
|
25
|
13
|
|
|
13
|
|
68
|
use Exporter; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
592
|
|
26
|
13
|
|
|
13
|
|
68
|
use GO::Utils qw(rearrange); |
|
13
|
|
|
|
|
29
|
|
|
13
|
|
|
|
|
697
|
|
27
|
|
|
|
|
|
|
#use strict; |
28
|
13
|
|
|
13
|
|
92
|
use FileHandle; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
120
|
|
29
|
13
|
|
|
13
|
|
5707
|
use Exporter; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
4739
|
|
30
|
13
|
|
|
13
|
|
79
|
use vars qw(@ISA); |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
645
|
|
31
|
13
|
|
|
13
|
|
64
|
use strict; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
415
|
|
32
|
|
|
|
|
|
|
|
33
|
13
|
|
|
13
|
|
1912
|
use base qw(GO::Model::Graph GO::ObjFactory); |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
11859
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _valid_params { |
36
|
13
|
|
|
13
|
|
53
|
return qw(dbh); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _initialize { |
40
|
13
|
|
|
13
|
|
30
|
my $self = shift; |
41
|
13
|
|
|
|
|
127
|
$self->SUPER::_initialize(@_); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub apph { |
45
|
1677
|
|
|
1677
|
0
|
2203
|
my $self = shift; |
46
|
1677
|
50
|
|
|
|
3560
|
$self->{apph} = shift if @_; |
47
|
1677
|
|
33
|
|
|
9976
|
return $self->{apph} || $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub n_deep_associations { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my $acc = shift; |
53
|
0
|
|
|
|
|
|
$self->extend_down([$acc]); # make sure all terms loaded |
54
|
0
|
|
|
|
|
|
$self->SUPER::n_deep_associations($acc); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub deep_association_list { |
58
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $acc = shift; |
60
|
0
|
|
|
|
|
|
$self->extend_down([$acc]); # make sure all terms loaded |
61
|
0
|
|
|
|
|
|
$self->SUPER::deep_association_list($acc); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#------ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub extend_graph_by_acc { |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
my $graph = shift; |
69
|
0
|
|
|
|
|
|
my $acc = shift; |
70
|
0
|
|
|
|
|
|
my $depth = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $term = $self->get_term($acc); |
73
|
0
|
|
|
|
|
|
$self->extend_up($graph, [$acc]); |
74
|
0
|
|
|
|
|
|
$self->extend_down($graph, [$acc], $depth); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub extend_up { |
79
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
my $graph = shift; |
81
|
0
|
0
|
|
|
|
|
my @accs = @{shift || []}; |
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $i=0; |
83
|
0
|
|
|
|
|
|
while ($i < scalar(@accs)) { |
84
|
0
|
|
|
|
|
|
my $acc = $accs[$i]; |
85
|
0
|
|
|
|
|
|
$i++; |
86
|
0
|
|
|
|
|
|
my $term = $self->get_term($acc); |
87
|
0
|
|
|
|
|
|
$graph->add_term($term); |
88
|
0
|
|
|
|
|
|
my $parent_rels = $self->get_parent_relationships($acc); |
89
|
0
|
|
|
|
|
|
foreach my $rel (@$parent_rels) { |
90
|
0
|
|
|
|
|
|
$graph->add_relationship($rel); |
91
|
0
|
0
|
|
|
|
|
if (!(grep {$_ == $rel->acc1} @accs)) { |
|
0
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# only put new accs in |
93
|
0
|
|
|
|
|
|
push(@accs, $rel->acc1); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
|
} @accs; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub extend_down { |
100
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
101
|
0
|
|
|
|
|
|
my $graph = shift; |
102
|
0
|
0
|
|
|
|
|
my @accs = @{shift || []}; |
|
0
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
my $max_depth = shift; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $i=0; |
106
|
0
|
|
|
|
|
|
while ($i < scalar(@accs)) { |
107
|
0
|
|
|
|
|
|
printf STDERR |
108
|
|
|
|
|
|
|
"======== %d %d %s\n", |
109
|
|
|
|
|
|
|
$i, |
110
|
|
|
|
|
|
|
$#accs, |
111
|
|
|
|
|
|
|
join(", ", @accs); |
112
|
0
|
|
|
|
|
|
my $acc = $accs[$i]; |
113
|
0
|
|
|
|
|
|
$i++; |
114
|
0
|
|
|
|
|
|
my $term = $self->get_term($acc); |
115
|
0
|
|
|
|
|
|
$graph->add_term($term); |
116
|
0
|
|
|
|
|
|
my $child_rels = $self->get_child_relationships($acc); |
117
|
0
|
|
|
|
|
|
foreach my $rel (@$child_rels) { |
118
|
0
|
|
|
|
|
|
$graph->add_relationship($rel); |
119
|
0
|
0
|
|
|
|
|
if (!(grep {$_ == $rel->acc2} @accs)) { |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# only put new accs in |
121
|
0
|
|
|
|
|
|
push(@accs, $rel->acc2); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
0
|
|
|
|
|
|
} @accs; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
0
|
|
sub get_deep_product_count { 0 } |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |