Code Monkey home page Code Monkey logo

Comments (8)

shoops avatar shoops commented on June 17, 2024

from biosimulators_copasi.

jonrkarr avatar jonrkarr commented on June 17, 2024

@shoops thanks for the quick reply.

Here's a more complete example where the time series doesn't include non-constant parameters set via event assignments. Here's the example model: model.xml.zip (BIOMD0000000806). The time series doesn't include d_u, d_m1 or H. I'm using COPASI 4.30.240.

What parameter do I need to set or function do I need to execute to retrieve the values of these parameters? I tried looking through the COPASI examples and documentation; the required syntax wasn't obvious to me.

import COPASI
import libsbml

filename = 'model.xml'

data_model = COPASI.CRootContainer.addDatamodel()
data_model.importSBML(filename)

task = data_model.getTask('Time-Course')
task.setMethodType(COPASI.CTaskEnum.Method_deterministic)
task.setScheduled(True)

model = data_model.getModel()
problem = task.getProblem()
model.setInitialTime(0.)
problem.setOutputStartTime(0.)
problem.setDuration(10.)
problem.setStepNumber(10)
problem.setTimeSeriesRequested(True)
problem.setAutomaticStepSize(False)
problem.setOutputEvent(False)

result = task.process(True)

time_series = task.getTimeSeries()

# get SBML ids of recorded variables
variable_sbml_ids = []
for i_variable in range(time_series.getNumVariables()):
    variable_sbml_ids.append(time_series.getSBMLId(i_variable, data_model))

# print SBML ids of recorded variables
print(variable_sbml_ids)

# check if non-constant SBML parameters were recorded
non_constant_parameter_sbml_ids = set(['d_u', 'd_m1', 'H'])
non_constant_parameter_sbml_ids.intersection(variable_sbml_ids)

# verify that the non-constant SBML parameters are part of the model
sbml_doc = libsbml.readSBMLFromFile(filename)
sbml_model = sbml_doc.getModel()
for sbml_id in non_constant_parameter_sbml_ids:
    sbml_parameter = sbml_model.getParameter(sbml_id)
    assert sbml_parameter is not None
    assert not sbml_parameter.getConstant()

from biosimulators_copasi.

shoops avatar shoops commented on June 17, 2024

Hello Jonathan,

You cannot use the time_series to get those values as they are not state variables of the system. You will have to create a report which contains the observables and variables required from SED-ML file. An exampleson how to proceed can be found at:
https://github.com/copasi/COPASI/blob/develop/copasi/bindings/python/examples/custom_output.py

Stefan

from biosimulators_copasi.

jonrkarr avatar jonrkarr commented on June 17, 2024

Perfect! I would never have been able to guess this myself. I should be able to figure out the rest.

from biosimulators_copasi.

shoops avatar shoops commented on June 17, 2024

Helllo Jonathan,

I think a better approach would be to let COPASI read the SED-ML directly. The problem I see is that if SED-ML asks for plot and you are running CopasiSE tor any language bindings he plot will not be generated. I think I have an idea on how to circumvent that. I will talk with @fbergmann about it.

Stefan

from biosimulators_copasi.

jonrkarr avatar jonrkarr commented on June 17, 2024

I started a new issue for the discussion that @shoops started. See #48.

from biosimulators_copasi.

shoops avatar shoops commented on June 17, 2024

This repository will never be obsolete since it provides functionality which is not part of COPASI's core. However making data specified by SED-ML plots and reports available to the calling process is a general feature desirable for language bindings.

from biosimulators_copasi.

jonrkarr avatar jonrkarr commented on June 17, 2024

Done in 4b9c03a.

from biosimulators_copasi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.