opencobra / cobratoolbox

The COnstraint-Based Reconstruction and Analysis Toolbox. Documentation:
https://opencobra.github.io/cobratoolbox
Other
241 stars 306 forks source link

Error when using writeCbModel #2071

Closed RieCo432 closed 1 year ago

RieCo432 commented 1 year ago

I've been working with the COBRA Toolbox for almost a year now. Today, the writeCbModel function stopped working. I've tried reading and then saving various models I have been using for months and every time I try to save it, I get the following error:

Error using matlab.internal.math.uniqueCellstrHelper
Cell array input must be a cell array of character vectors.

Error in cell/unique (line 86)
    [varargout{1:nlhs}] = matlab.internal.math.uniqueCellstrHelper(A,[false true false true false]);

Error in getModelSubSystems (line 31)
        subSystems = unique(model.subSystems);

Error in writeSBML (line 453)
modelSubSystems = getModelSubSystems(model);

Error in writeCbModel (line 226)
        outmodel = writeSBML(model, fileName, input.compSymbols, input.compNames);

Error in enhance_iBsu1103v3 (line 152)
    outmodel = writeCbModel(model, 'format', 'sbml', 'filename', [filename '.xml']);

I have tried calling writeCbModel with the bare minimum of parameters (i.e. the model and a char array as a filename), but no luck.

I've had a look at the commit history for the source files that are involved in this, but there hasn't been any commits in about 3 weeks.

I hereby confirm that I have:

RieCo432 commented 1 year ago

Turns out my model.subSystems was filled with empty char arrays. It worked fine after fixing that. Still wondering how that's never been an issue before though.

rmtfleming commented 1 year ago

What extra option would be needed here to make it fail gracefully?

if all(charBool)
    subSystems = unique(model.subSystems);
elseif all(cellBool)
    orderedSubs = cellfun(@(x)

columnVector(x),model.subSystems,'UniformOUtput',false); subSystems = setdiff(vertcat(orderedSubs{:}),''); else subSystems = unique(model.subSystems); end

On Sun, 20 Nov 2022 at 19:18, Colin Ries @.***> wrote:

Turns out my model.subSystems was filled with empty char arrays. It worked fine after fixing that. Still wondering how that's never been an issue before though.

— Reply to this email directly, view it on GitHub https://github.com/opencobra/cobratoolbox/issues/2071#issuecomment-1321219230, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQMEOT7QQ3HIWDPKM4CCZ3WJJ2PJANCNFSM6AAAAAASFOVPQU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Mr. Ronan MT Fleming B.V.M.S. Dip. Math. Ph.D.

Associate Professor, School of Medicine, National University of Ireland, Galway. & Assistant Professor, Division of Systems Biomedicine and Pharmacology, Leiden Academic Centre for Drug Research, Faculty of Science, Leiden University. https://www.universiteitleiden.nl/en/staffmembers/ronan-fleming

Peer-reviewed publications: https://goo.gl/FZPG23 Mobile: +353 852 109 806 Skype: ronan.fleming

(This message is confidential and may contain privileged information. It is intended for the named recipient only. If you receive it in error please notify me and permanently delete the original message and any copies.)