I have noticed a small glitch between the implementations of the cobra toolbox in python and Matlab. After removing several genes, metabolites and reactions from a yeast model ( always taking into account that it should be possible to create biomass ) I am able to get a solution (FBA) in python but not in Matlab.
What I do more specifically:
I take a standard yeast model (SBML file) and import it into Matlab. I modify the lower bounds to match my medium and remove all dead end reactions using the standard functions.
next, I export this model as an SBML file and import it into python.
And then I use this model to determine which reaction should be removed, and remove them using the code below.
Next, I perform an FBA on both the model before deleting the reactions, metabolites and genes and after deleting. Finally,I write out an SBML file
# Original model
model = cobra.io.sbml.create_cobra_model_from_sbml_file(os.path.join('data','iMM904_NADcorrected_pappEtAl2011_adj_and_remove.xml'))
model.optimize(solver='glpk')
print 'optimal f full model '+str(model.solution.f)
# Remove
for reaction in removed_reactions: model.reactions.__getattr__(reaction[2:]).remove_from_model(model)
for gene in removed_genes: model.genes.__getattr__(gene).remove_from_model(model)
for metabolite in removed_metabolites: model.metabolites.__getattr__(metabolite[2:]).remove_from_model(model)
# New model calculations
model.optimize(solver='glpk')
print 'optimal f partial model ' + str(model.solution.f)
FVA_result = cobra.flux_analysis.variability.flux_variability_analysis(model, fraction_of_optimum=1.0, number_of_processes=15)
# Write to file
write_cobra_model_to_sbml_file(model, os.path.join('data','iMM904_examo_%s.xml' % description))
Outputs:
optimal f full model 0.287998303658
optimal f partial model 0.0635426076692
as you can see both the full model and the model in which I deleted some reactions, metabolites and genes are able to create biomass. The partial model is only able to do it less efficiently.
I import the SBML file in Matlab using the code below:
as you can see the partial model gives the exact same result in both python in Matlab. However, the model in which I deleted some genes, reactions and metabolites is not able to generate a solution in Matlab. If I try to do an FVA, it generates an error in Matlab but works fine in python.
Am I doing something wrong in exporting the SBML file from python, or could there be some other cause?
Any help would be greatly appreciated,
cheers,
Rob
here's what I'm using:
Matlab R2013a
Python 2.7
cobra.version: 0.2.1
Initilization Matlab:
Warning: LP solver Gurobi not useable: gurobi.m not in Matlab path
In changeCobraSolver at 138
In initCobraToolbox at 42
In fa_fba_analysis at 1
Warning: LP solver Gurobi not useable: gurobi_mex not in Matlab path
In changeCobraSolver at 133
In initCobraToolbox at 42
In fa_fba_analysis at 1
Warning: LP solver CPLEX through Tomlab not usable: tomRun.m not in Matlab path
In changeCobraSolver at 113
In initCobraToolbox at 42
In fa_fba_analysis at 1
LP solver set to glpk successful
Warning: MILP solver Gurobi not useable: gurobi.m not in Matlab path
In changeCobraSolver at 175
In initCobraToolbox at 55
In fa_fba_analysis at 1
Warning: MILP solver Gurobi not useable: gurobi_mex not in Matlab path
In changeCobraSolver at 170
In initCobraToolbox at 55
In fa_fba_analysis at 1
Warning: MILP solver CPLEX through Tomlab not usable: tomRun.m not in Matlab path
In changeCobraSolver at 160
In initCobraToolbox at 55
In fa_fba_analysis at 1
MILP solver set to glpk successful
Warning: QP solver Gurobi not useable: gurobi.m not in Matlab path
In changeCobraSolver at 231
In initCobraToolbox at 67
In fa_fba_analysis at 1
Warning: QP solver Gurobi not useable: gurobi_mex not in Matlab path
In changeCobraSolver at 224
In initCobraToolbox at 67
In fa_fba_analysis at 1
Warning: QP solver CPLEX through Tomlab not usable: tomRun.m not in Matlab path
In changeCobraSolver at 195
In initCobraToolbox at 67
In fa_fba_analysis at 1
Warning: qpng solver has not been fully tested - results may not be correct
In changeCobraSolver at 205
In initCobraToolbox at 67
In fa_fba_analysis at 1
QP solver set to qpng successful
Warning: MIQP solver gurobi not usable: gurobi.m not in Matlab path
In changeCobraSolver at 262
In initCobraToolbox at 78
In fa_fba_analysis at 1
Warning: MIQP solver gurobi not usable: gurobi_mex not in Matlab path
In changeCobraSolver at 255
In initCobraToolbox at 78
In fa_fba_analysis at 1
Warning: MIQP solver CPLEX through Tomlab not usable: tomRun.m not in Matlab path
In changeCobraSolver at 248
In initCobraToolbox at 78
In fa_fba_analysis at 1
MIQP solver set failed
CB map output set to svg successful
hi everyone,
I have noticed a small glitch between the implementations of the cobra toolbox in python and Matlab. After removing several genes, metabolites and reactions from a yeast model ( always taking into account that it should be possible to create biomass ) I am able to get a solution (FBA) in python but not in Matlab.
What I do more specifically: I take a standard yeast model (SBML file) and import it into Matlab. I modify the lower bounds to match my medium and remove all dead end reactions using the standard functions. next, I export this model as an SBML file and import it into python. And then I use this model to determine which reaction should be removed, and remove them using the code below. Next, I perform an FBA on both the model before deleting the reactions, metabolites and genes and after deleting. Finally,I write out an SBML file
Outputs: optimal f full model 0.287998303658 optimal f partial model 0.0635426076692
as you can see both the full model and the model in which I deleted some reactions, metabolites and genes are able to create biomass. The partial model is only able to do it less efficiently.
I import the SBML file in Matlab using the code below:
Outputs: ans = 0.2880 ans = 0
as you can see the partial model gives the exact same result in both python in Matlab. However, the model in which I deleted some genes, reactions and metabolites is not able to generate a solution in Matlab. If I try to do an FVA, it generates an error in Matlab but works fine in python.
Am I doing something wrong in exporting the SBML file from python, or could there be some other cause?
Any help would be greatly appreciated,
cheers, Rob
here's what I'm using: Matlab R2013a Python 2.7 cobra.version: 0.2.1
Initilization Matlab: Warning: LP solver Gurobi not useable: gurobi.m not in Matlab path