sys-bio / tellurium

Python Environment for Modeling and Simulating Biological Systems
http://tellurium.analogmachine.org/
Apache License 2.0
107 stars 36 forks source link

sedmlToPython fails when steadystate simulation is run #117

Closed kirichoi closed 8 years ago

kirichoi commented 8 years ago

When running steady-state simulation, the translation from sedml to Python is not functional due to the current implementation on datagenerator. This is due to the fact that steadyState simulation returns a float not an array. Possible solution: in tesedml.py, under dataGeneratorToPython(), catch steady-state simulation and automatically create an array with repeated value of each element to plot a line representing a steady-state value.

matthiaskoenig commented 8 years ago

@kirichoi Is this in the new implementation? (in the new one I have some steady state test cases which work, so should be okay) Can you add example code which produces the error?

kirichoi commented 8 years ago

@matthiaskoenig I am using the latest implementation and at least on my machine those tests are failing. For example, if you translate something like

import tellurium as te
import roadrunner

a1 = """
        model m1()
            J0: S1 -> S2; k1*S1;
            S1 = 10.0; S2=0.0;
            k1 = 0.1;
        end
"""

p = """
        model0 = model "m1"
        sim0 = simulate steadystate
        sim0.algorithm.486 = 10
        task0 = run sim0 on model0
        plot task0.time vs task0.S1
"""

exp = te.experiment(a1, p)
print(exp.getPython())

into Python code, you get this problematic part:

task0 = [None]
model0.setSteadyStateSolver('nleq')
model0.steadyStateSolver.setValue('minimum_damping', 1.0)
model0.conservedMoietyAnalysis = True
model0.steadyStateSelections = ['[S1]', 'time']
model0.simulate()
task0[0] = model0.steadyState()
model0.conservedMoietyAnalysis = False

__var__task0_____time = np.transpose(np.array([sim['time'] for sim in task0]))
if len(__var__task0_____time.shape) == 1:
     __var__task0_____time.shape += (1,)
plot_0_0_0 = __var__task0_____time

__var__task0_____S1 = np.transpose(np.array([sim['[S1]'] for sim in task0]))
if len(__var__task0_____S1.shape) == 1:
     __var__task0_____S1.shape += (1,)
plot_0_0_1 = __var__task0_____S1

sim['time'] for sim in task0 is erroneous for the case when task0 has a single element. Could you post what you get for the translation?

kirichoi commented 8 years ago

I think this might have something to do with roadrunner update that I am not aware of. I will test it out.

kirichoi commented 8 years ago

Confirmed that it works in the develop version of roadrunner. Sorry for confusion

matthiaskoenig commented 8 years ago

Yes, was the returning of the steadyState results as NamedArrays.

I needed it for the implementation because it made it much easier to handle timeCourse and steadyState simulations in a similar manner (steadyState being handled as a "timeCourse" with only one dataPoint, similar to oneStep).

On Wed, Mar 30, 2016 at 1:25 AM, Kiri Choi notifications@github.com wrote:

Closed #117 https://github.com/sys-bio/tellurium/issues/117.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/sys-bio/tellurium/issues/117#event-607485281

Matthias König Junior Group Leader LiSym - Systems Medicine of the Liver Humboldt-University Berlin, Institute for Theoretical Biology https://www.livermetabolism.com konigmatt@googlemail.com Tel: +49 30 20938450 Tel: +49 176 81168480