So the previous question was apparently not wisely asked. So here is the rephrased original question:
I am planing on building up a new GSMM from nothong (i.e. I need a empty model, 0 reaction/metabolite/compartment/GPR/annotation, but with a proper model structure that toolbox will accept).
I used to work with Matlab and COBRA toolbox but recently changed into Python and cbmpy toolbox. I know how to create a model structure in Matlab through COBRA but not in python with cbmpy. I am really not familiar with cmbpy's functions and I am here ask for help.
There are ways to meet my needs:
The most stupid way: read an exist model and remove all its contents.
import cbmpy as cbm mod = cbm.CBRead.readSBML3FBC('example.xml') for ri in mod.getSpeciesIds(): mod.deleteSpecies(ri, also_delete = 'reaction')
Similarly, different functions start with 'mod.delete....' will clean all the stuff. Eventually you will have a clean empty model.
As suggested by Cleb, I looked into the source code and found the function I need
import cbmpy as cbm mod = cbm.CBModel.Model('Name') mod.createSpecies('M_a_c',boundary=False,value=float('nan'),name='AA',compartment='c',charge=None,chemFormula='C2H2O2') mod.createSpecies('M_b_c',boundary=False,value=float('nan'),name='BB',compartment='c',charge=None,chemFormula='CHO') mod.createReaction('R_AB',reversible=False) mod.createReactionReagent('R_AB','M_a_c',-1.0) mod.createReactionReagent('R_AB','M_b_c',2)
Then a model object with ID 'Name' is created. It is a very simple question and its answer very straightforward, if you have found the right function. Later you may gradually add reaction/metabolites/etc and assign the objective reaction. It is of course also possible to directly use cbm.CBModelTools.quickDefaultBuild
but you need to prepare necessary arguments for adding reactions/species/boundary/objective.
While you can indeed build a model as you described, it might be easier (and cleaner) to use
I will show how to use it for a minimal example which is quite self-explanatory:
Now you can call
and
and
and you can also simulate the model
When you look for the genes you defined for reaction
R02
, you will see an empty list:You will first have to call
which prints
And then
will give the desired outcome
as well as
which returns
I highly recommend to use this approach as this is easier to read and edit later on if you want to change the model definition.
If you want to add further annotation, you can check this question.