-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCRN_find_elementary_function.m
39 lines (30 loc) · 1.44 KB
/
CRN_find_elementary_function.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function F = CRN_find_elementary_function(complexes, lambda_cell, ncell, kappa)
% complexes: d * K matrix whose column vectors are the source complexs of
% reactions.
[d, ~] = size(complexes);
% syms n [d 1] integer
% ncell = sym2cell(n);
[a_list_tmp, b_list_tmp, H] = CRN_find_elementary_path(complexes);
% the row vectors of H form a basis.
number_of_elementary_path = rank(H);
length_of_elementary_path = sum(a_list_tmp ~= 0, 2); % compute row sum.
% F_tmp(n) = sym(zeros(number_of_elementary_path, 1));
F_tmp = sym(zeros(number_of_elementary_path, 1));
F = sym2cell(formula(F_tmp));
for l = 1:number_of_elementary_path
a_list = a_list_tmp(l, 1:length_of_elementary_path(l));
b_list = b_list_tmp(l, 1:length_of_elementary_path(l));
trace_of_current_path = cumsum(complexes(:,a_list) - complexes(:,b_list), 2);
for j = 1:length_of_elementary_path(l)
tmp_arg_n_a = sym2cell(cellfun(@sum, ncell) + trace_of_current_path(:,j));
if j == 1
F{l}(ncell{:}) = (lambda_cell{a_list(j)}(tmp_arg_n_a{:})/kappa(a_list(j))) / ...
(lambda_cell{b_list(j)}(ncell{:}) / kappa(b_list(j)));
else
tmp_arg_n_b = sym2cell(cellfun(@sum, ncell) + trace_of_current_path(:,j-1));
F{l}(ncell{:}) = F{l}(ncell{:}) * (lambda_cell{a_list(j)}(tmp_arg_n_a{:})/kappa(a_list(j))) / ...
(lambda_cell{b_list(j)}(tmp_arg_n_b{:}) / kappa(b_list(j)));
end
end
end
end