line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Relationship.pm,v 1.6 2006/10/19 18:38:28 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::Model::Relationship; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
GO::Model::Relationship |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
a relationship between two GO::Model::Terms |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
relationships can be thought of as B or sentences of the form |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
SUBJECT-TERM PREDICATE OBJECT-TERM |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
for example, |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
"dog" IS_A "animal" |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
"G-Protein coupled receptor" IS_A "transmembrane receptor" |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Statements have a B (i.e. the subject of the |
33
|
|
|
|
|
|
|
sentence/statement), a predicate/relationship-type and an B |
34
|
|
|
|
|
|
|
(i.e. the object of the sentence/statement) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Relationships can also be seen as arcs in a directed graph, with the |
37
|
|
|
|
|
|
|
subject being equivalent to the child, and the object equivalent to |
38
|
|
|
|
|
|
|
the parent. The arc is labeled with the predicate/relationship-type. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
A Relationship object currently does not contain an actual pointer to |
41
|
|
|
|
|
|
|
a GO::Model::Term object. Instead it stores the ID of that term. This |
42
|
|
|
|
|
|
|
is intended to be used in conjunction with the Graph object, or with |
43
|
|
|
|
|
|
|
the database. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
14
|
|
|
14
|
|
81
|
use Carp; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
877
|
|
49
|
14
|
|
|
14
|
|
79
|
use Exporter; |
|
14
|
|
|
|
|
1357
|
|
|
14
|
|
|
|
|
519
|
|
50
|
14
|
|
|
14
|
|
79
|
use GO::Utils qw(rearrange); |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
865
|
|
51
|
14
|
|
|
14
|
|
81
|
use GO::Model::Root; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
310
|
|
52
|
14
|
|
|
14
|
|
91
|
use strict; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
669
|
|
53
|
14
|
|
|
14
|
|
80
|
use vars qw(@ISA); |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
8960
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
@ISA = qw(GO::Model::Root Exporter); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _valid_params { |
58
|
739
|
|
|
739
|
|
2534
|
return qw(acc1 acc2 is_inheritance complete type); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _initialize { |
63
|
739
|
|
|
739
|
|
1003
|
my $self = shift; |
64
|
739
|
|
|
|
|
2201
|
$self->SUPER::_initialize(@_); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub acc1 { |
68
|
5561
|
|
|
5561
|
0
|
7264
|
my $self = shift; |
69
|
5561
|
100
|
|
|
|
11778
|
$self->{"acc1"} = shift if @_; |
70
|
5561
|
|
|
|
|
22689
|
return $self->{"acc1"}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
*obj_acc = \&acc1; |
73
|
|
|
|
|
|
|
*object_acc = \&acc1; |
74
|
|
|
|
|
|
|
*parent_acc = \&acc1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub acc2 { |
77
|
6778
|
|
|
6778
|
0
|
9562
|
my $self = shift; |
78
|
6778
|
100
|
|
|
|
13278
|
$self->{"acc2"} = shift if @_; |
79
|
6778
|
|
|
|
|
26074
|
return $self->{"acc2"}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
*subj_acc = \&acc2; |
82
|
|
|
|
|
|
|
*subject_acc = \&acc2; |
83
|
|
|
|
|
|
|
*child_acc = \&acc2; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 subject_acc |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Title : subject_acc |
88
|
|
|
|
|
|
|
Usage : $obj->subject_acc($newid) |
89
|
|
|
|
|
|
|
Usage : $currid = $obj->subject_acc() |
90
|
|
|
|
|
|
|
Synonyms: subj_acc, acc2, child_acc |
91
|
|
|
|
|
|
|
Function: gets or sets the identifier for the child/subject term |
92
|
|
|
|
|
|
|
Example : |
93
|
|
|
|
|
|
|
Returns : value of subject_acc (string) |
94
|
|
|
|
|
|
|
Args : on set, new value (string) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
All Relationships can be thought of "subject-predicate-object" |
97
|
|
|
|
|
|
|
statements. The statement is *about* the subject, and states something |
98
|
|
|
|
|
|
|
about the relationship *to* the object. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
For example, the if we have a Relationship: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
cell |
103
|
|
|
|
|
|
|
^ |
104
|
|
|
|
|
|
|
| |
105
|
|
|
|
|
|
|
| [part_of] |
106
|
|
|
|
|
|
|
| |
107
|
|
|
|
|
|
|
cell nucleus |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is a statement about cell nuclei in general, so "cell nucleus" is |
110
|
|
|
|
|
|
|
the subject (sometimes called the child node). The Relationship tells |
111
|
|
|
|
|
|
|
us that all cell nuclei are part_of some cell, so the object of the |
112
|
|
|
|
|
|
|
relationship (sometimes called the parent node) is "cell" |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 object_acc |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Title : object_acc |
120
|
|
|
|
|
|
|
Usage : $obj->object_acc($newid) |
121
|
|
|
|
|
|
|
Usage : $currid = $obj->object_acc() |
122
|
|
|
|
|
|
|
Synonyms: obj_acc, acc1, parent_acc |
123
|
|
|
|
|
|
|
Function: gets or sets the identifier for the parent/object term |
124
|
|
|
|
|
|
|
Example : |
125
|
|
|
|
|
|
|
Returns : value of object_acc (string) |
126
|
|
|
|
|
|
|
Args : on set, new value (string) |
127
|
|
|
|
|
|
|
See Also: subj_acc |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 type |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Title : type |
135
|
|
|
|
|
|
|
Usage : $obj->type($newval) |
136
|
|
|
|
|
|
|
Usage : $currval = $obj->type() |
137
|
|
|
|
|
|
|
Synonyms: |
138
|
|
|
|
|
|
|
Function: gets or sets the relationship type (a string) |
139
|
|
|
|
|
|
|
Example : |
140
|
|
|
|
|
|
|
Returns : value of type (string) |
141
|
|
|
|
|
|
|
Args : on set, new value (string) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Currently any string is allowed; in future the type string may be |
144
|
|
|
|
|
|
|
constrained to come from a controlled vocabulary of relationship types |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub type { |
150
|
1821
|
|
|
1821
|
1
|
2292
|
my $self = shift; |
151
|
1821
|
100
|
|
|
|
3739
|
if (@_) { |
152
|
738
|
|
|
|
|
881
|
my $type = shift; |
153
|
738
|
50
|
|
|
|
1449
|
if ($type) { |
154
|
738
|
|
|
|
|
1536
|
$self->{type} = $type; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
1821
|
|
100
|
|
|
32237
|
return $self->{type} || "unknown"; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub is_obsolete { |
161
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
162
|
0
|
0
|
|
|
|
0
|
$self->{is_obsolete} = shift if @_; |
163
|
0
|
0
|
|
|
|
0
|
return $self->{is_obsolete} ? 1:0; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub as_str { |
167
|
849
|
|
|
849
|
0
|
1038
|
my $self = shift; |
168
|
849
|
|
|
|
|
1778
|
sprintf("%s:%s:%s", $self->type, $self->acc1, $self->acc2); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub to_ptuples { |
172
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
173
|
0
|
|
|
|
|
|
warn("deprecated"); |
174
|
0
|
|
|
|
|
|
my ($th) = |
175
|
|
|
|
|
|
|
rearrange([qw(tuples)], @_); |
176
|
0
|
|
|
|
|
|
(["rel", $self->type, $self->acc1, $self->acc2]); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub is_inheritance { |
182
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
183
|
0
|
|
|
|
|
|
warn("deprecated"); |
184
|
0
|
0
|
|
|
|
|
if (@_) { |
185
|
0
|
|
|
|
|
|
my $is = shift; |
186
|
0
|
0
|
|
|
|
|
$is && $self->type("isa"); |
187
|
0
|
0
|
|
|
|
|
!$is && $self->type("partof"); |
188
|
|
|
|
|
|
|
} |
189
|
0
|
|
|
|
|
|
return $self->type eq "isa"; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
193
|
|
|
|
|
|
|
|