I would like to do a FVA only for selected reactions, in my case on transport reactions between compartments (e.g. between the cytosol and mitochondrion). I know that I can use selected_reactions
in doFVA
like this:
import cbmpy as cbm
mod = cbm.CBRead.readSBML3FBC('iMM904.xml.gz')
cbm.doFVA(mod, selected_reactions=['R_FORtm', 'R_CO2tm'])
Is there a way to get the entire list of transport reactions, not only the two I manually added? I thought about
selecting the reactions based on their ending tm
but that fails for 'R_ORNt3m'
(and probably other reactions, too).
I want to share this model with others. What is the best way of storing the information in the SBML file? Currently, I would store the information in the reaction annotation as in this answer. For example
mod.getReaction('R_FORtm').setAnnotation('FVA', 'yes')
which could be parsed.
There is no built-in function for this kind of task. As you already mentioned, relying on the IDs is generally not a good idea as those can differ between different databases, models and groups (e.g. if someone decided just to enumerate reactions from
r1
tillrn
and or metabolites fromm1
tillmm
, filtering based on IDs fails). Instead, one can make use of thecompartment
field of the species. In CBMPy you can access a species' compartment by doingThis can be used to find all fluxes between compartments as one can check for each reaction in which compartment their reagents are located. A possible implementation could look as follows:
So you pass your model object and a list of compartments and then for each reaction it is checked whether there is at least one reagent located in the specified compartments.
In your case you would use it as follows:
The list
trans_cyt_mit
will then contain all desired reaction IDs (also the two you specified in your question) which you can then pass to thedoFVA
function.About the second part of your question. I highly recommend to store those reactions in a group rather than using annotation:
When you now export the model, e.g. by using
this group will be stored as well in SBML. If a colleague reads the SBML again, he/she can then easily run a
FVA
for the same reactions by accessing the group members which is far easier than parsing the annotation:Now you can easily query the dataframe and find the flexible and not flexible reactions within your group: