This file is indexed.

/usr/share/SBMLToolbox/Convenience/SubstituteFunction.m is in sbmltoolbox 4.1.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
function Formula = SubstituteFunction(OriginalFormula, SBMLFunctionDefinition)
% newExpression = SubstituteFunction(expression, SBMLFunctionDefinition) 
%
% Takes
% 
% 1. expression, a string representation of a math expression
% 2. SBMLFunctionDefinition, an SBML FunctionDefinition structure
% 
% Returns
% 
% 1. newExpression
%  - the string representation of the expression when any instances of the 
% functionDefinition have been substituted
%  - an empty string if the functiondefinition is not in the original
%  expression
%
% *EXAMPLE:*
%
%          Consider fD to be an SBMLFunctionDefinition 
%               with id = 'g' and math = 'lambda(x,x+0.5)' 
%
%          formula = SubstituteFormula('g(y)', fD)
%           
%          formula = 'y+0.5'
%
%    
%          formula = SubstituteFormula('h(y)', fD)
%           
%          formula = ''
%


%<!---------------------------------------------------------------------------
% This file is part of SBMLToolbox.  Please visit http://sbml.org for more
% information about SBML, and the latest version of SBMLToolbox.
%
% Copyright (C) 2009-2012 jointly by the following organizations: 
%     1. California Institute of Technology, Pasadena, CA, USA
%     2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK
%
% Copyright (C) 2006-2008 jointly by the following organizations: 
%     1. California Institute of Technology, Pasadena, CA, USA
%     2. University of Hertfordshire, Hatfield, UK
%
% Copyright (C) 2003-2005 jointly by the following organizations: 
%     1. California Institute of Technology, Pasadena, CA, USA 
%     2. Japan Science and Technology Agency, Japan
%     3. University of Hertfordshire, Hatfield, UK
%
% SBMLToolbox is free software; you can redistribute it and/or modify it
% under the terms of the GNU Lesser General Public License as published by
% the Free Software Foundation.  A copy of the license agreement is provided
% in the file named "LICENSE.txt" included with this software distribution.
%----------------------------------------------------------------------- -->





%check arguments are appropriate
if (~isstruct(SBMLFunctionDefinition))
  error(sprintf('%s', ...
    'first argument must be an SBML functionDefinition structure'));
end;
 
[sbmlLevel, sbmlVersion] = GetLevelVersion(SBMLFunctionDefinition);

if (~ischar(OriginalFormula))
    error('SubstituteFunction(OriginalFormula, SBMLFunctionDefinition)\n%s', 'first argument must be a character array containing the id of the function definition');
elseif (~isSBML_FunctionDefinition(SBMLFunctionDefinition, sbmlLevel, sbmlVersion))
    error('SubstituteFunction(OriginalFormula, SBMLFunctionDefinition)\n%s', 'second argument must be an SBML function definition structure');
end;

OriginalFormula = LoseWhiteSpace(OriginalFormula);

startPoint = matchFunctionName(OriginalFormula, SBMLFunctionDefinition.id);
if (isempty(startPoint))
  Formula = '';
  return;
end;

ElementsOfFuncDef = GetArgumentsFromLambdaFunction(SBMLFunctionDefinition.math);

% get the arguments of the application of the formula
Formula = '';
index = length(startPoint);
StartFunctionInFormula = startPoint(index);

j = StartFunctionInFormula + length(SBMLFunctionDefinition.id);
pairs = PairBrackets(OriginalFormula);
for i=1:length(pairs)
  if (pairs(i, 1) == j)
    endPt = pairs(i, 2);
    break;
  end;
end;
[NoElements, ElementsInFormula] = GetElementsOfFunction(OriginalFormula(j:endPt));

OriginalFunction = '';
for i = StartFunctionInFormula:endPt
    OriginalFunction = strcat(OriginalFunction, OriginalFormula(i));
end;

% check got right number
if (NoElements ~= length(ElementsOfFuncDef) - 1)
    error('SubstituteFunction(OriginalFormula, SBMLFunctionDefinition)\n%s', 'mismatch in number of arguments between formula and function');
end;

% check that same arguments have not been used

for i = 1:NoElements
  for j = 1:NoElements
    if (strcmp(ElementsInFormula{i}, ElementsOfFuncDef{j}))
      newElem = strcat(ElementsInFormula{i}, '_new');
      ElementsOfFuncDef{j} = newElem;
      ElementsOfFuncDef{end} = strrep(ElementsOfFuncDef{end}, ElementsInFormula{i}, newElem);
    end;
  end;
end;
% replace the arguments in function definition with those in the formula
FuncFormula = '(';
FuncFormula = strcat(FuncFormula, ElementsOfFuncDef{end});
FuncFormula = strcat(FuncFormula, ')');
for i = 1:NoElements
    FuncFormula = strrep(FuncFormula, ElementsOfFuncDef{i}, ElementsInFormula{i});
end;

Formula = strrep(OriginalFormula, OriginalFunction, FuncFormula);

% if the function occurred more than once
if (index - 1) > 0
  Formula = SubstituteFunction(Formula, SBMLFunctionDefinition);
end;



function [NoElements, ElementsInFormula] = GetElementsOfFunction(OriginalFormula);

j = 2;
c = OriginalFormula(j);
element = '';
NoElements = 1;
ElementsInFormula = {};
while (j < length(OriginalFormula))
    if (strcmp(c, ','))
        ElementsInFormula{NoElements} = element;
        element = '';
        NoElements = NoElements + 1;
    else
        element = strcat(element, c);
    end;
    
    j = j + 1;
    c = OriginalFormula(j);
end;
ElementsInFormula{NoElements} = element;