forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reassignFwBwMatch.m
36 lines (34 loc) · 917 Bytes
/
reassignFwBwMatch.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
function matchNew = reassignFwBwMatch(match,selVec)
%reassingFwBwMatch Reassing forward-backward matches when modifying an
%irreversible model
%
% matchNew = reassignFwBwMatch(match,selVec)
%
%INPUTS
% match Forward-backwards mapping vector
% selVec Selection vector marking reactions to remap
%
%OUTPUT
% matchNew Modified forward-backwards mapping vector
%
% Markus Herrgard 11/3/05
% Create an index map from the old indices to new ones
% If selVec = [1 0 0 1 1]
% indexMap = [1 0 0 2 3];
indexMap = selVec*1.0;
indexMap(selVec==1) = [1:sum(selVec)];
matchNew = [];
for i = 1:length(match)
if (selVec(i)==1)
if (match(i) > 0)
if (selVec(match(i)) == 1)
matchNew(end+1) = indexMap(match(i));
else
matchNew(end+1) = 0;
end
else
matchNew(end+1) = 0;
end
end
end
matchNew = matchNew';