line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Path.pm,v 1.5 2004/11/29 20:18:17 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
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package GO::Model::Path; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
GO::Model::Path; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
represents a path between two nodes in a graph |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
TODO: have the path be built of relationships rather than terms, so |
24
|
|
|
|
|
|
|
we can get the edgetypes in here |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
14
|
|
85
|
use Carp; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
976
|
|
30
|
14
|
|
|
14
|
|
85
|
use Exporter; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
483
|
|
31
|
14
|
|
|
14
|
|
89
|
use GO::Utils qw(rearrange); |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
855
|
|
32
|
14
|
|
|
14
|
|
79
|
use GO::Model::Root; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
1672
|
|
33
|
14
|
|
|
14
|
|
82
|
use strict; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
563
|
|
34
|
14
|
|
|
14
|
|
95
|
use vars qw(@ISA); |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
6885
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
@ISA = qw(GO::Model::Root Exporter); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _valid_params { |
40
|
32
|
|
|
32
|
|
72
|
return qw(link_list); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 link_list |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Usage - |
47
|
|
|
|
|
|
|
Returns - arrayref of alternating type, GO::Model::Term |
48
|
|
|
|
|
|
|
Args - |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 term_list |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Usage - |
56
|
|
|
|
|
|
|
Returns - arrayref of GO::Model::Term |
57
|
|
|
|
|
|
|
Args - |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
gets/sets an ordered list of terms in the path |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
L |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub term_list { |
66
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
67
|
0
|
|
0
|
|
|
0
|
my $links = $self->link_list || []; |
68
|
0
|
|
|
|
|
0
|
my @terms = (); |
69
|
0
|
|
|
|
|
0
|
for (my $i=1; $i<@$links; $i+=2) { |
70
|
0
|
|
|
|
|
0
|
push(@terms, $links->[$i]); |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
0
|
\@terms; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# add_link - private |
77
|
|
|
|
|
|
|
sub add_link { |
78
|
10
|
|
|
10
|
0
|
14
|
my $self = shift; |
79
|
10
|
50
|
|
|
|
21
|
if (!$self->{link_list}) { |
80
|
0
|
|
|
|
|
0
|
$self->{link_list} = []; |
81
|
|
|
|
|
|
|
} |
82
|
10
|
50
|
|
|
|
21
|
push(@{$self->{link_list}}, shift, shift) if @_; |
|
10
|
|
|
|
|
25
|
|
83
|
10
|
|
|
|
|
22
|
$self->{link_list}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 length |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Usage - print $path->length |
90
|
|
|
|
|
|
|
Returns - int |
91
|
|
|
|
|
|
|
Args - |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub length { |
96
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
97
|
0
|
0
|
|
|
|
0
|
return scalar(@{$self->{link_list} || []})/2; |
|
0
|
|
|
|
|
0
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 to_text |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Usage - |
104
|
|
|
|
|
|
|
Returns - |
105
|
|
|
|
|
|
|
Args - |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub to_text { |
110
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
111
|
0
|
|
|
|
|
0
|
my $use = shift; |
112
|
0
|
|
0
|
|
|
0
|
my $links = $self->link_list || []; |
113
|
0
|
|
|
|
|
0
|
my @parts = (); |
114
|
0
|
|
|
|
|
0
|
for (my $i=0; $i<@$links; $i+=2) { |
115
|
0
|
|
|
|
|
0
|
my $t = $links->[$i+1]; |
116
|
0
|
0
|
0
|
|
|
0
|
push(@parts, "[$links->[$i]]", $use && $use eq 'acc' ? $t->acc : $t->name); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
return |
119
|
0
|
|
|
|
|
0
|
join(' ', @parts); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 duplicate |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Usage - |
125
|
|
|
|
|
|
|
Returns - |
126
|
|
|
|
|
|
|
Args - |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub duplicate { |
131
|
10
|
|
|
10
|
1
|
11
|
my $self = shift; |
132
|
10
|
|
|
|
|
24
|
my $dup = $self->new; |
133
|
10
|
100
|
|
|
|
14
|
$dup->link_list([@{$self->link_list || []}]); |
|
10
|
|
|
|
|
62
|
|
134
|
10
|
|
|
|
|
215
|
$dup; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |