sys-bio / roadrunner

libRoadRunner: A high-performance SBML simulator
http://libroadrunner.org/
Other
40 stars 25 forks source link

order of metabolites in stoichiometric matrix not consistent depending on where it is run #1143

Open janisshin opened 1 year ago

janisshin commented 1 year ago

when I call r.getFullStoichiometryMatrix(), the order of the metabolites changes depending on whether the method is called in a class or in a Jupyter notebook. From what I can tell, the order of the reactions remains constant.

Since I am passing in the stoichiometry matrix back and forth for matrix operations, the consistency of the order of the metabolites is crucial. Can you make the order consistent like the order of reactions? Thanks.

hsauro commented 1 year ago

That’s very odd. The only thing that can affect the order is the order you declare the species in the antimony model. You need to gives some examples that show that behavior.

janisshin commented 1 year ago

Also, when I call r.getFloatingSpeciesIds(), the order is different in a Jupyter notebook (first image) than when I call it in a class (second image).

image image In the second image, r.getIndependentFloatingSpeciesIds() is stored in variable a and r.getFloatingSpeciesIds() is stored in variable b.

janisshin commented 1 year ago

Okay, I think I got to the bottom of the issue.

import tellurium as te

# load the Teusink model
ant_file = 'data/interim/Antimony/BIOMD0000000064_e.ant'
r = te.loada(ant_file)
print(r.getFullStoichiometryMatrix())

ant_file = 'data/interim/Antimony/BIOMD0000000064_e.ant'
s  = te.loada(ant_file)
s.steadyState()
print(s.getFullStoichiometryMatrix())

For some reason, running s.steadyState changes the order of the floating species. image

hsauro commented 1 year ago

Try setting the conservation flag to true first

H

On Wed, Sep 6, 2023 at 11:50 AM Janis Shin @.***> wrote:

Okay, I think I got to the bottom of the issue.

import tellurium as te

load the Teusink model

ant_file = 'data/interim/Antimony/BIOMD0000000064_e.ant' r = te.loada(ant_file) print(r.getFullStoichiometryMatrix())

ant_file = 'data/interim/Antimony/BIOMD0000000064_e.ant' s = te.loada(ant_file) s.steadyState() print(s.getFullStoichiometryMatrix())

For some reason, running r.steadyState changes the order of the floating species. [image: image] https://urldefense.com/v3/__https://user-images.githubusercontent.com/49432660/266110084-69b90e8e-203f-4ec0-9560-dc3d503e81a2.png__;!!K-Hz7m0Vt54!hD0DS3V2nY6jl1F-PJtBqjNwQxSDo_-58hayp68yg6U8CWOWsZdA0x3F2kMobHPHHodA-tKyalTHFQ4Uwi9r6TVgWR-pxA$

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/sys-bio/roadrunner/issues/1143*issuecomment-1708915800__;Iw!!K-Hz7m0Vt54!hD0DS3V2nY6jl1F-PJtBqjNwQxSDo_-58hayp68yg6U8CWOWsZdA0x3F2kMobHPHHodA-tKyalTHFQ4Uwi9r6TXO-ElRbw$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAIBSDQZDJHFOJKPPXNFKGTXZDAWZANCNFSM6AAAAAA4NXO26E__;!!K-Hz7m0Vt54!hD0DS3V2nY6jl1F-PJtBqjNwQxSDo_-58hayp68yg6U8CWOWsZdA0x3F2kMobHPHHodA-tKyalTHFQ4Uwi9r6TVcfd6a6g$ . You are receiving this because you commented.Message ID: @.***>

janisshin commented 1 year ago

this generally works, but if I'm converting my antimony to sbml for running on Cobra, then Cobra uses the order of metabolites that is the same order as the one prior to running conservation on antimony. So, it would be nice if we could always just use one order instead of having the user be responsible for converting each time the model is loaded in both antimony and cobra.