Error when writing a .xml file with WriteCbModel()

114 views
Skip to first unread message

Michel_Lavoie

unread,
Oct 18, 2018, 11:02:25 PM10/18/18
to COBRA Toolbox
Hi all,
     I am trying to write a .xml file from a .mat file or a cobra model (see the matlab code below) and I always get the same error (see the error message at the end).  I do not understand why I cannot write a .xml file from this .mat file. Could anyone suggest potential explanations and solutions? I tried with another .mat file (the file Recon2.0model.mat) and I was able to write a xml file and then read the xml file. However, with the file 'ILB1025bon.mat', I cannot convert it to a .xml file.
Thanks a lot,
Michel

___________________________________________________________
% Matlab code and results and error messages
load('iLB1025bon.mat') % this load the model in a structure called pti

pti = convertOldStyleModel(pti)  % this convert the pti structure so that I can read the subSystem field

pti = 

  struct with fields:

                     id: 'iLB1025'
            description: 'Metabolic network reconstruction of Phaeodactylum tricornutum'
                   rxns: {2156×1 cell}
               rxnNames: {2156×1 cell}
                grRules: {2156×1 cell}
                  rules: {2156×1 cell}
                      c: [2156×1 double]
                      S: [1704×2156 double]
                     lb: [2156×1 double]
                     ub: [2156×1 double]
             subSystems: {2156×1 cell}
           rxnECNumbers: {2156×1 cell}
              rxnKEGGID: {2156×1 cell}
               rxnNotes: {2156×1 cell}
     proteinAssociation: {2156×1 cell}
       rxnsLocalization: {2156×1 cell}
          rxnReferences: {2156×1 cell}
             rxnGeneMat: [2156×1025 double]
                  genes: {1025×1 cell}
                   mets: {1704×1 cell}
               metNames: {1704×1 cell}
               metComps: [1704×1 double]
            metFormulas: {1704×1 cell}
              metKEGGID: {1704×1 cell}
             metChEBIID: {1704×1 cell}
         metInChIString: {1704×1 cell}
                      b: [1704×1 double]
                  comps: {6×1 cell}
              compNames: {6×1 cell}
    rxnConfidenceScores: [2156×1 double]
             metCharges: [1704×1 double]
              osenseStr: 'max'
                 csense: [1704×1 char]

>> verifyModel(pti, 'simpleCheck', true)
The following problems have been encountered in the model structure
propertiesNotMatched:
metChEBIID: Field does not match the required properties

ans =

  logical

   0

>> pti = rmfield(pti, 'metChEBIID') 

pti = 

  struct with fields:

                     id: 'iLB1025'
            description: 'Metabolic network reconstruction of Phaeodactylum tricornutum'
                   rxns: {2156×1 cell}
               rxnNames: {2156×1 cell}
                grRules: {2156×1 cell}
                  rules: {2156×1 cell}
                      c: [2156×1 double]
                      S: [1704×2156 double]
                     lb: [2156×1 double]
                     ub: [2156×1 double]
             subSystems: {2156×1 cell}
           rxnECNumbers: {2156×1 cell}
              rxnKEGGID: {2156×1 cell}
               rxnNotes: {2156×1 cell}
     proteinAssociation: {2156×1 cell}
       rxnsLocalization: {2156×1 cell}
          rxnReferences: {2156×1 cell}
             rxnGeneMat: [2156×1025 double]
                  genes: {1025×1 cell}
                   mets: {1704×1 cell}
               metNames: {1704×1 cell}
               metComps: [1704×1 double]
            metFormulas: {1704×1 cell}
              metKEGGID: {1704×1 cell}
         metInChIString: {1704×1 cell}
                      b: [1704×1 double]
                  comps: {6×1 cell}
              compNames: {6×1 cell}
    rxnConfidenceScores: [2156×1 double]
             metCharges: [1704×1 double]
              osenseStr: 'max'
                 csense: [1704×1 char]

>> verifyModel(pti, 'simpleCheck', true)
writeCbModel(pti, 'fileName', 'modelptitest.xml') . % This command does not work.

ans =

  logical

   1

Error using regexprep
Evaluation of 'model.genes{str2num($1)}' failed:

Index exceeds array bounds.

Error in creategrRulesField (line 44)
currentrules = regexprep(currentrules,'x\(([0-9]+)\)','${model.genes{str2num($1)}}');

Error in writeSBML (line 390)
model = creategrRulesField(model);

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

Thomas Pfau

unread,
Oct 19, 2018, 1:23:36 AM10/19/18
to cobra-...@googlegroups.com

Hi Michel.

This model is thoroughly broken, or rather, the mat struct is really badly curated.
The rules field in this model is simply wrong, and needs to be refilled from the grRules, as it references positions which are outside the model.genes field.

you can use:

model = generateRules(model)

on it to try and restore the rules field, but I can't tell if the grRules field is correct on this model neither, so this is only something to correct the structural error, not sure if it actually corrects the model itself....

Best

Thomas


On 2018-10-19 05:02, 'Michel_Lavoie' via COBRA Toolbox wrote:

Unsubscribe

It appears that you have subscribed to commercial messages from this sender. To stop receiving such messages from this sender, please unsubscribe

--

---
You received this message because you are subscribed to the Google Groups "COBRA Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbo...@googlegroups.com.
For more options, visit http://secure-web.cisco.com/1F2RrDPGmqkC9aWiKZ39lk7rtMJsP7P2oog809O4heTSCOdwnbOb2zY1UaGVyIgZmDlayG_apj5ZeKygnThYyHbZzhWhY7vWNR0ScubrEFd9YPIee3s72gIgkMTBWZCzKp4qzrivI38BUpwuA0B0xnrVWhvTjlfMzqSh8_OG2SaQmI52bbvfOoSpv5N4Cicje8-I6dPizgpyrJq38_q27zgNfeZ19A0EyXpngn412cJc5_Ea5cnXUP14ZJKEyTKkStwmJcn6aeeAp0FTXWi1i8c4lmIbnUVXcwh8JRagZ8LUFYva01pQsHf3yvVWUKoEodj57do0SKSqRRp1EDbGKCf4l890ygbTG2f6C69FjPqzQQxrAJQVk42BrSKuKnuIODK82gVzoSOPT0e01e7FM5Z6SyVibOxyJMU3ql7_9Jr0/l34%3Ahttps%3A%2F%2Fgroups.google.com%2Fd%2Foptoute.

-- 
Université du Luxembourg
Faculté des Sciences, de la Technologie et de la Communication
Campus Belval, Biotech II 115
6 avenue du Swing
L-4367 Belvaux
Tel: (+352) 46 66 44 5309
Email: thoma...@uni.lu

Michel_Lavoie

unread,
Oct 20, 2018, 8:17:32 AM10/20/18
to COBRA Toolbox
Hi Thomas,
                 Thanks for drawing my attention to the generateRules() function. This is a very handy function when we want to convert the field grRule to rules. I tried it and the conversion of grRules to rules seems to work since I did not get the same error message than before. However, now when I try to write a .xml file from the model structure using the function writeCbModel(), I get the following error message (see below). Would you have any idea to debug this?
Thanks for your help,
Michel

>> writeCbModel(pti, 'fileName', 'modelptitest.xml')
Error using OutputSBML

First input must be a valid MATLAB_SBML Structure

Errors reported: species structure reports species fbc_charge field incorrect type
USAGE: OutputSBML(SBMLModel, (filename), (exclusiveFlag), (applyUserValidation))

Error in writeSBML (line 592)
OutputSBML(sbmlModel,fileName,1,0,[1,0]);
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbox+unsubscribe@googlegroups.com.

Thomas Pfau

unread,
Oct 22, 2018, 2:11:06 AM10/22/18
to cobra-...@googlegroups.com

Hi Michel,

This error is due to the model containing on Integer charges, along with formulas containing non integer compositions. While this is allowed in the COBRA structure, the SBML FBC package does not allow non integer charge values. This has been a point of debate in the past, but it was, in general, agreed that non integer charges don't make a lot of sense, and that it would be preferable to adjust the corresponding coefficients.

The only situations this comes up (under normal conditions), is when trying to assign Formulas/Charges to "artificial" compounds such as biomass, or biomass parts (which is exactly what is happening in this model). Assigning these values is a design question, but they are definitely inconsistent with SBML specifications. Personally, I don't see much use in these charge/formula definitions, as they can directly be derived from the reactions, and the compounds commonly represent something that is not existing as a compound but rather as a placeholder to distribute the biomass formation information (which can help in model curation).

I have implemented a check for these instances in the writeSBML function (which will be submitted once github is back up), which discards these "invalid" values. The fix also removes invalid metFormulas fields in order to assure that we produce valid SBML files.

This currently means, that the SBML IO will loose some information, but there is already a suggestion from the FBC package developers that will allow us to retain this type of information.

Best

Thomas

To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ronan M.T. Fleming

unread,
Oct 25, 2018, 6:42:39 AM10/25/18
to cobra-...@googlegroups.com, The SBML L3 Flux Balance Constraints package discussion list
Hi Michael,

since this is an important issue at the intersection of the COBRA toolbox and the SBML FBC specification, I cross post to sbml-flux where there are experts on SBML.

Indeed the SBML FBC specification (*v2) requires each species to have an integer charge. I think it may be too restrictive for FBC-type modelling. Some change to the specifications might be necessary, so that is why I'd like to involve the sbml experts to see what their opinion is.

From a thermodynamic perspective, almost all COBRA models implicitly assume that each reaction involves a set of reactants, rather than a set of species. A reactant is a pseudoisomer group of species that differ only in their state of, e.g., protonation. Hence ATP (the reactant = pseudoisomer group with respect to protons) is actually representative of multiple species at a physiological pH range, that is: ATP^4-, HATP^3-, H2ATP^2- . Even for a model compartment at a given pH one can simultaneously have multiple species at non-negligible concentrations (see e.g. https://doi.org/10.1016/j.bpc.2009.08.007). When people talk about the thermodynamically favourable direction of a reaction, they are almost always implicitly talking about a reaction involving reactants, rather than species.

The current SBML FBC specification seems a bit too restrictive when asking for charge to be an integer. It might be better to only require charge to be a double. This is consistent with allowing a stoichioimetric coefficient to be a double. Actually, allowing a stoichiometric coefficient to be a double, while only allowing charge to be an integer seems inconsistent with charge balancing.

There may be other ways around this problem, in the interim, that the sbml community might suggest to us, but for now the COBRA toolbox will continue to support charge in double format, as we have previously done, its just that we cannot export to SBML without some adaption to the format we export.

Regards,

Ronan






--
--
Mr. Ronan MT Fleming B.V.M.S. Dip. Math. Ph.D.
----------------------------------------------------------------------------
Assistant Professor,
Division of Systems Biomedicine and Pharmacology,
Leiden Academic Centre for Drug Research,
Faculty of Science,
Leiden University.
&
H2020 Project Coordinator
Systems Medicine of Mitochondrial Parkinson’s Disease
----------------------------------------------------------------------------
Mobile:  +353 873 413 072
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.)
Reply all
Reply to author
Forward
0 new messages