line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Bio::Metabolic::Substrate - Perl extension for the description of biochemical substrates |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Bio::Metabolic::Substrate; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $sub1 = Bio::Metabolic::Substrate->new('Water'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $sub2 = Bio::Metabolic::Substrate->new('Oxygen', {o => 2}); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This class implements the object class representing Biochemical Compounds (Substrates) |
17
|
|
|
|
|
|
|
occurring in biochemical reactions. |
18
|
|
|
|
|
|
|
Substrates must contain a name and arbitrary many attributes. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 EXPORT |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
None |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 OVERLOADED OPERATORS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
String Conversion |
27
|
|
|
|
|
|
|
$string = "$substrate"; |
28
|
|
|
|
|
|
|
print "\$substrate = '$substrate'\n"; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Equality |
31
|
|
|
|
|
|
|
if ($sub1 == $sub2) |
32
|
|
|
|
|
|
|
if ($sub1 != $sub2) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Lexical comparison |
35
|
|
|
|
|
|
|
$cmp = $sub1 cmp $sub2; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 AUTHOR |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Oliver Ebenhöh, oliver.ebenhoeh@rz.hu-berlin.de |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Bio::Metabolic. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package Bio::Metabolic::Substrate; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
require 5.005_62; |
54
|
5
|
|
|
5
|
|
29
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
174
|
|
55
|
5
|
|
|
5
|
|
40
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
157
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
require Exporter; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#use AutoLoader qw(AUTOLOAD); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#use Math::Symbolic; |
62
|
5
|
|
|
5
|
|
28
|
use Carp; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
614
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use overload |
65
|
5
|
|
|
|
|
72
|
"\"\"" => \&substrate_to_string, |
66
|
|
|
|
|
|
|
"==" => \&equals, |
67
|
|
|
|
|
|
|
"!=" => \¬_equals, |
68
|
5
|
|
|
5
|
|
30
|
"cmp" => \&compare_names; |
|
5
|
|
|
|
|
16
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 Constructor new |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
First argument must specify the name. Second argument is a hash reference of |
77
|
|
|
|
|
|
|
key-value pairs defining the object attributes. Attributes are optional. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Upon creation, each substrate object gets associated with a variable |
80
|
|
|
|
|
|
|
(Math::Symbolic::Variable object) which is accessible by the accessor method |
81
|
|
|
|
|
|
|
var(). The purpose for this is the automatic creation of ordinary differential |
82
|
|
|
|
|
|
|
equation systems describing the dynamic behaviour of a metabolic system. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns a Bio::Metabolic::Substrate. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub new { |
89
|
23
|
|
|
23
|
1
|
6800
|
my $pkg = shift; |
90
|
23
|
100
|
|
|
|
67
|
$pkg = ref($pkg) if ref($pkg); |
91
|
|
|
|
|
|
|
|
92
|
23
|
|
33
|
|
|
64
|
my $name = shift() |
93
|
|
|
|
|
|
|
|| croak("no name has been provided for constructor new"); |
94
|
|
|
|
|
|
|
|
95
|
23
|
100
|
|
|
|
62
|
my $attr = @_ ? shift() : {}; |
96
|
|
|
|
|
|
|
|
97
|
23
|
|
|
|
|
67
|
my $self = { |
98
|
|
|
|
|
|
|
name => $name, |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# var => Math::Symbolic::Variable->new($name), |
101
|
|
|
|
|
|
|
attributes => $attr, |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
23
|
|
|
|
|
85
|
bless $self => $pkg; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 Method copy |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
copy() returns a copy of the object. Attributes are cloned. The variable |
110
|
|
|
|
|
|
|
associated with the substrate (see var() below) is new defined and the value |
111
|
|
|
|
|
|
|
(if existing) is not copied. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub copy { |
116
|
1
|
|
|
1
|
1
|
3
|
my $orig = shift; |
117
|
1
|
50
|
|
|
|
3
|
$orig = shift unless ref($orig); |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
2
|
my %attr = %{ $orig->attributes }; |
|
1
|
|
|
|
|
3
|
|
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
3
|
return $orig->new( $orig->name, \%attr ); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 Method name |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Optional argument: sets the object's name. Returns the object's name. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub name { |
131
|
329
|
|
|
329
|
1
|
666
|
my $self = shift; |
132
|
329
|
50
|
|
|
|
596
|
$self->{name} = shift if @_; |
133
|
329
|
|
|
|
|
1616
|
return $self->{name}; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 Method attributes |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Optional argument: sets the object's attributes. Returns the object's |
139
|
|
|
|
|
|
|
attributes. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub attributes { |
144
|
127
|
|
|
127
|
1
|
140
|
my $self = shift; |
145
|
127
|
50
|
|
|
|
261
|
$self->{attributes} = shift if @_; |
146
|
127
|
|
|
|
|
249
|
return $self->{attributes}; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 Method var |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Optional argument: sets the object's variable. Returns the object's |
152
|
|
|
|
|
|
|
variable (Math::Symbolic::Variable object). |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#sub var { |
157
|
|
|
|
|
|
|
# my $self = shift; |
158
|
|
|
|
|
|
|
# $self->{var} = shift if @_; |
159
|
|
|
|
|
|
|
# return $self->{var}; |
160
|
|
|
|
|
|
|
#} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 Method fix |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Sets the value of the object's variable, thus fixing the substrate's |
165
|
|
|
|
|
|
|
concentration. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
#sub fix { |
170
|
|
|
|
|
|
|
# my $self = shift; |
171
|
|
|
|
|
|
|
# my $value = shift; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# return $self->var->value($value); |
174
|
|
|
|
|
|
|
#} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 Method release |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Sets the value of the object's variable to undef, thus releasing the substrate's |
179
|
|
|
|
|
|
|
concentration. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
#sub release { |
184
|
|
|
|
|
|
|
# shift->var->value(undef); |
185
|
|
|
|
|
|
|
#} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 Method get_attribute |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Argument specifies the attribute name. Returns the attribute value or undef |
190
|
|
|
|
|
|
|
if such an attribute does not exist. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub get_attribute { |
195
|
2
|
|
|
2
|
1
|
241
|
my $self = shift; |
196
|
2
|
|
|
|
|
4
|
my $attr_name = shift; |
197
|
|
|
|
|
|
|
|
198
|
2
|
|
|
|
|
4
|
return $self->attributes->{$attr_name}; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 Method substrate_to_string |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Returns a readable string. The string consists of the object's attributes listed |
204
|
|
|
|
|
|
|
in braces. If the object does not have any attributes, the string consists of |
205
|
|
|
|
|
|
|
the object's name in square brackets. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub substrate_to_string { |
210
|
109
|
|
|
109
|
1
|
137
|
my $substrate = shift; |
211
|
109
|
|
|
|
|
203
|
my $attributes = $substrate->attributes; |
212
|
|
|
|
|
|
|
|
213
|
109
|
50
|
|
|
|
341
|
return "[" . $substrate->name . "]" unless keys(%$attributes); |
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
0
|
my $str = "{"; |
216
|
0
|
|
|
|
|
0
|
foreach my $k ( keys(%$attributes) ) { |
217
|
0
|
0
|
|
|
|
0
|
$str .= "," if ( $str !~ /\{$/ ); |
218
|
0
|
|
|
|
|
0
|
$str .= "'$k'=>$attributes->{$k}"; |
219
|
|
|
|
|
|
|
} |
220
|
0
|
|
|
|
|
0
|
$str .= "}"; |
221
|
0
|
|
|
|
|
0
|
return $str; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 Method equals |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Compares two substrates. If one of the substrates has attributes the set of |
227
|
|
|
|
|
|
|
attributes is compared. If both objects are without attributes, the names are |
228
|
|
|
|
|
|
|
compared. Returns 1 upon equality, 0 otherwise. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub equals { |
233
|
6
|
|
|
6
|
1
|
276
|
my ( $s1, $s2 ) = @_; |
234
|
6
|
|
|
|
|
12
|
my $sub1 = $s1->attributes; |
235
|
6
|
|
|
|
|
11
|
my $sub2 = $s2->attributes; |
236
|
|
|
|
|
|
|
|
237
|
6
|
|
|
|
|
15
|
my @sub1_keys = keys(%$sub1); |
238
|
6
|
|
|
|
|
14
|
my @sub2_keys = keys(%$sub2); |
239
|
|
|
|
|
|
|
|
240
|
6
|
50
|
|
|
|
16
|
return 0 if ( @sub1_keys != @sub2_keys ); |
241
|
|
|
|
|
|
|
|
242
|
6
|
100
|
|
|
|
12
|
return ( $s1->name eq $s2->name ) unless @sub2_keys; |
243
|
|
|
|
|
|
|
|
244
|
4
|
|
|
|
|
5
|
my $k; |
245
|
4
|
|
|
|
|
8
|
foreach $k (@sub2_keys) { |
246
|
4
|
100
|
66
|
|
|
38
|
return 0 if ( !defined( $sub2->{$k} ) |
247
|
|
|
|
|
|
|
|| $sub2->{$k} ne $sub1->{$k} ); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
2
|
|
|
|
|
11
|
return 1; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head2 Method not_equals |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
Compares two substrates. If one of the substrates has attributes the set of |
256
|
|
|
|
|
|
|
attributes is compared. If both objects are without attributes, the names are |
257
|
|
|
|
|
|
|
compared. Returns 0 upon equality, 1 otherwise. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=cut |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub not_equals { |
262
|
3
|
|
|
3
|
1
|
8
|
return 1 - equals(@_); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head2 Method is_empty |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
returns 1 if the object does not have any attributes |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub is_empty { |
272
|
2
|
|
|
2
|
1
|
5
|
my $substrate = shift->attributes; |
273
|
2
|
100
|
|
|
|
10
|
return keys(%$substrate) ? 0 : 1; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head2 Method compare_names |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Lexical comparison of the object names or optionally strings. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub compare_names { |
283
|
5
|
|
|
5
|
1
|
116
|
my $s1 = shift; |
284
|
5
|
50
|
|
|
|
19
|
my $n1 = ref($s1) ? $s1->name : $s1; |
285
|
5
|
|
|
|
|
8
|
my $s2 = shift; |
286
|
5
|
100
|
|
|
|
15
|
my $n2 = ref($s2) ? $s2->name : $s2; |
287
|
5
|
|
|
|
|
29
|
return $n1 cmp $n2; |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
1; |
291
|
|
|
|
|
|
|
__END__ |