sbmlteam / libsbml

LibSBML is a native library for reading, writing and manipulating files and data streams containing the Systems Biology Markup Language (SBML). It offers language bindings for C, C++, C#, Java, JavaScript, MATLAB, Perl, PHP, Python, R and Ruby.

Home Page:https://sbml.org/software/libsbml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libSBML SBMLode causes sym>convertChar error

thomassligon opened this issue · comments

In genSSI I am getting an error from libSBML while retesting all old models (https://github.com/genssi-developer/GenSSI). There are no changes in gennSSI in this part of the code, so it looks like a problem with a newer version somewhere, maybe a change in MATLAB or in libSBML. I am currently using MATLAB Version: 9.8.0.1873465 (R2020a) Update 8 and libSBML 5.19.0.

runExample('BIOMD0000000003')
loading compartments ...
applying rules ...
Error using sym>convertChar (line 1546)
Character vectors and strings in the first argument can only specify a variable or number. To evaluate character
vectors and strings representing symbolic expressions, use 'str2sym'.

Error in sym>tomupad (line 1262)
S = convertChar(x);

Error in sym (line 229)
S.s = tomupad(x);

Error in cell2sym (line 31)
Csym = cellfun(conv, C, 'UniformOutput', false);

Error in sym>tomupad (line 1274)
xsym = cell2sym(x);

Error in sym (line 229)
S.s = tomupad(x);

Error in SBMLode/importSBML>cleanedsym (line 686)
csym = sym(sanitizeString(strrep(str,'time','time_internal_amici')));

Error in SBMLode/importSBML (line 80)
all_rulemath = cleanedsym({model.rule.formula});

Error in SBMLode (line 63)
model.importSBML(filename);

Error in runBIOMD0000000003 (line 18)
ODE = SBMLode([modelName '.xml']);

Error in run (line 91)
evalin('caller', strcat(script, ';'));

Error in runExample (line 4)
run(runFile);

I think what has changed here, is that matlabs behavior for the syms command has changed since R2018a. see also:

https://www.mathworks.com/matlabcentral/answers/403463-error-in-sym-character-vectors-and-strings-in-the-first-argument-can-only-specify-a-variable-or-num

Hello Frank, thanks for the quick response. Now, I need to think about how to address the problem.

In this case, genSSI does nothing other than call libSBML to import an SBML model, and I don't see any way to fix or work around the issue in gennSSI. Can something be done in libSBML? Since cell2sym is a part of MATLAB, I don't see anything in the error message that indicates that this could be fixed in libSBML. Please correct me if that is wrong.

What it importSBML here? I can see that AMICI has a module called importSBML and that had exactly the same problem and was fixed in AMICI issue #234. I can also see that genSSI used AMICI's importSBML. So, I think I need to address this with AMICI. Testing shows me that the problem occurs the second time that importSBML line 686 is called

Finally, if this is a pure MATLAB problem, I could open a support request with MATLAB, or extend the discussion that you cited above.

Yes, this problem is not something we can fix on the libsbml side. We return a matlab structure with the string of the expressions. If you still have an old matlab version < 2017 around, that would solve the issue. Or the code in the importSBML project would have to be adjusted:

https://github.com/genssi-developer/GenSSI/blob/master/SBMLimporter/%40SBMLode/importSBML.m

to call a function like the one form the post:

https://github.com/is-centre/gptips2f-matlab/blob/master/core/gpsym.m

wherever the code called sym and replace it with qgpsym. But that is nothing we can do.