API Documentation
JavaScript
- class COPASI(Module)
COPASI
This class wraps all the functions exported from emscripten and provides a more convenient interface.
Constructs a new COPASI instance from the WASM module
- Arguments:
Module – the WASM module
- COPASI.TC
type: string
TC
enum for method names
- COPASI.boundarySpeciesConcentrations
- COPASI.boundarySpeciesIds
- COPASI.boundarySpeciesNames
- COPASI.compartmentIds
- COPASI.compartmentNames
- COPASI.compartmentSizes
- COPASI.eigenValues2D
- COPASI.eigenValuesReduced2D
- COPASI.floatingSpeciesConcentrations
- COPASI.floatingSpeciesIds
- COPASI.floatingSpeciesNames
- COPASI.globalParameterIds
- COPASI.globalParameterNames
- COPASI.globalParameterValues
- COPASI.jacobian
- COPASI.jacobian2D
- COPASI.localParameterNames
- COPASI.localParameterValues
- COPASI.modelInfo
- COPASI.ratesOfChange
- COPASI.reactionIds
- COPASI.reactionNames
- COPASI.reactionRates
- COPASI.reducedJacobian
- COPASI.reducedJacobian2D
- COPASI.selectedValues
- COPASI.selectionList
- COPASI.timeCourseSettings
- COPASI.version
Examples:
var copasi = new COPASI(Module); console.log(copasi.version); // prints something like: // 4.32.284
- COPASI.getConcentrationControlCoefficients(scaled)
Retrieves the concentration control coefficients for the model
Note that computeMca must be called before this method
- Arguments:
scaled (bool) – indicating whether the scaled (true) or unscaled coefficients should be returned
- Returns:
object – the concentration control coefficients as object
- COPASI.getConcentrationControlCoefficients2D(scaled)
Retrieves the concentration control coefficients for the model as 2d array
- Arguments:
scaled (bool) – indicating whether the scaled (true) or unscaled coefficients should be returned
- Returns:
Array.<Array.<number>> – the concentration control coefficients as 2D array
- COPASI.getElasticities(scaled)
Retrieves the elasticities
- Arguments:
scaled (bool) – indicating whether the scaled (true) or unscaled coefficients should be returned
- Returns:
object – the elasticites as object
- COPASI.getElasticities2D(scaled)
Retrieves the elasticities
- Arguments:
scaled (bool) – indicating whether the scaled (true) or unscaled coefficients should be returned
- Returns:
Array.<Array.<number>> – the elasticities as 2D array
- COPASI.getFluxControlCoefficients(scaled)
Retrieves the flux control coefficients for the model
Note that computeMca must be called before this method
- Arguments:
scaled (bool) – indicating whether the scaled (true) or unscaled coefficients should be returned
- Returns:
object – the flux control coefficients as object
- COPASI.getFluxControlCoefficients2D(scaled)
Retrieves the flux control coefficients for the model as 2d array
- Arguments:
scaled (bool) – indicating whether the scaled (true) or unscaled coefficients should be returned
- Returns:
Array.<Array.<number>> – the flux control coefficients as 2D array
- COPASI.loadExample(path)
loads an example (if the WASM module was compiled with FS support)
- Arguments:
path (string)
- Returns:
model information as an object
- COPASI.loadModel(modelCode)
Loads a model from a string containing the model in SBML or COPASI format.
- Arguments:
modelCode (string) – in SBML or COPASI format
- Returns:
model information as an object
- COPASI.reset()
resets the model
after loading the model, its state was saved as parameterset, calling reset will apply that parameter set.
- COPASI.simulate()
simulates the currently loaded model with its current time course settings.
- Returns:
object – simulation results as object
- COPASI.simulate2D()
simulates the currently loaded model with its current time course settings.
- Returns:
Array.<Array.<number>> – simulation results as 2D array
- COPASI.simulateEx(startTime, endTime, numPoints)
simulates the currently loaded model from startTime to endTime with numPoints points.
- Arguments:
startTime (number)
endTime (number)
numPoints (number)
- Returns:
object – simulation results as object
- COPASI.simulateEx2D(startTime, endTime, numPoints)
simulates the currently loaded model from startTime to endTime with numPoints points.
- Arguments:
startTime (number)
endTime (number)
numPoints (number)
- Returns:
Array.<Array.<number>> – simulation results as 2D array
- COPASI.simulateYaml(yamlProcessingOptions)
simulates the currently loaded model after applying the processing instructions:
- Arguments:
yamlProcessingOptions (object|string)
- Returns:
object – simulation results as object
- COPASI.simulateYaml2D(yamlProcessingOptions)
simulates the currently loaded model after applying the processing instructions:
- Arguments:
yamlProcessingOptions (object|string)
- Returns:
Array.<Array.<number>> – simulation results as 2D array
C++
- file copasijs.h
- #include <copasi/CopasiTypes.h>#include <copasi/utilities/CVersion.h>#include <copasi/utilities/CCopasiException.h>#include <copasi/report/CDataHandler.h>#include “json.hpp”#include <sstream>
Functions
-
std::string getVersion()
returns the version of the COPASI library
-
std::string getMessages(int start = 0, const std::string &filter = "")
returns all messages from the COPASI library
- Parameters:
start – the start index of the messages (default 0)
filter – a filter to apply to the messages (messages containing this string will be skipped) (default “” = no message will be skipped)
- Returns:
the messages as string
-
void setSelectionList(const std::vector<std::string> &selectionList)
sets the selection list
The selection list controlls which values are returned by the simulation.
See also
getSelectionList, getSelectionValues
- Parameters:
selectionList – the selection list
-
std::vector<std::string> getSelectionList()
gets the selection list
- Returns:
the current selection list
-
std::vector<double> getSelectionValues()
- Returns:
the current selected values
-
nlohmann::ordered_json buildModelInfo()
builds a model info object
The info object will be in the following format:
{ "species": [ { "compartment": "compartment", "concentration": 2.9999959316797846, "id": "", "initial_concentration": 2.9999959316797846, "initial_particle_number": 1.80664e+21, "name": "X", "particle_number": 1.80664e+21, "type": "reactions" }, ... ], "compartments": [ { "id": "", "name": "compartment", "size": 1.0, "type": "fixed" }, ... ], "reactions": [ { "id": "", "local_parameters": [ { "name": "k1", "value": 1.0 } ], "name": "R1", "reversible": false, "scheme": "A -> X" }, ... ], "global_parameters": [], "time": 0.0, "model": { "name": "The Brusselator", "notes": "" } "status": "success", "messages": "" }
- Returns:
the model info as json object
-
std::string getModelInfo()
gets the model info object as string
See also
buildModelInfo
-
std::string loadFromFile(const std::string &modelFile)
loads a model from a file
- Parameters:
modelFile – the file to load
- Returns:
the model info as string
-
std::string loadModel(const std::string &modelString)
loads a model from a string
- Parameters:
modelString – the model as string can be sbml or copasi format
- Returns:
the model info as string
-
void reset()
resets the model
This function resets the models floating species and entities with ODEs back to their initial values.
-
void resetAll()
resets the model completely
This function resets the model to the state after loading the model.
-
void applyYaml(nlohmann::ordered_json &yaml)
applies a yaml string to the model
The problem / method options as returned by
{ "initial_values": { "name": value, ... } }
See also
getTimeCourseSettings To change initial condictions you would use:
where
namewould be the display name of the element to change. If no specific reference is used, the initial concentration will be changed for species, and initial values for all other model entities.The syntax to use for specific references would be:
[A]_0for the initial concentration of speciesA,Values[t].InitialValuefor the initial value of a global parameter or(r1).kfor the local parameterkof reactionr1.- Parameters:
yaml – the yaml string to apply
-
std::vector<std::vector<double>> getSimulationResults2D()
returns the last simulation result from the time series object as 2D double vector
-
double steadyState()
runs the steady state task and returns the closeness to steady state as result.
- Returns:
the closeness to steady state
-
bool computeMca(bool performSteadyState = true)
performs metabolic control analysis
To retrieve the results use the following functions:
See also
getFluxControlCoefficients(bool scaled)
See also
getConcentrationControlCoefficients(bool scaled)
See also
getElasticities(bool scaled)
- Parameters:
performSteadyState – param indicating, whether the steady state should be computed before the MCA computations
- Returns:
boolean indicating success
-
std::string simulateYaml(const std::string &processingYaml)
runs a simulation and returns the result as json string
{ "num_variables": 3, "recorded_steps": 11, "titles": [ "Time", ... ], "columns": [ [ 0.0, 1.0, ... ], ... ] }
See also
applyYaml
- Parameters:
yaml – the yaml string with the simulation settings and possibly changed initial values the format is the same as
- Returns:
the result as json string in the following format
-
std::string simulate()
runs a simulation and returns the result as json string
This function uses the current model state and the current time course settings
{ "num_variables": 3, "recorded_steps": 11, "titles": [ "Time", ... ], "columns": [ [ 0.0, 1.0, ... ], ... ] }
See also
getTimeCourseSettings
- Returns:
the result as json string in the following format
-
std::string simulateEx(double timeStart, double timeEnd, int numPoints)
runs a simulation and returns the result as json string
{ "num_variables": 3, "recorded_steps": 11, "titles": [ "Time", ... ], "columns": [ [ 0.0, 1.0, ... ], ... ] }
- Parameters:
timeStart – the start time of the simulation
timeEnd – the end time of the simulation
numPoints – the number of points to calculate
- Returns:
the result as json string in the following format
-
double oneStep(double startTime, double stepSize)
runs a simulation for one outputstep
This is just a convenience function equivalent of running simulateEx(startTime, startTime + stepSize, 1)
- Returns:
the end time of the simulation
-
std::string getTimeCourseSettings()
returns the time course settings as json string
{ "problem": { "AutomaticStepSize": false, "StepNumber": 200, "StepSize": 0.5, "Duration": 100.0, "TimeSeriesRequested": true, "OutputStartTime": 2.0, "Output Event": false, "Start in Steady State": false, "Use Values": false, "Values": "", "Continue on Simultaneous Events": false }, "method": { "Integrate Reduced Model": true, "Relative Tolerance": 1e-06, "Absolute Tolerance": 1e-12, "Max Internal Steps": 10000, "Max Internal Step Size": 0.0, "name": "Deterministic (LSODA)" }
- Returns:
the json string with the following format
-
void setTimeCourseSettings(const std::string &settings)
sets the time course settings from a json string
See also
getTimeCourseSettings
- Parameters:
settings – the json string with the same format as
-
std::vector<std::string> getReactionNames()
- Returns:
the name of all reactions in the model
-
std::vector<std::string> getReactionIds()
- Returns:
the sbml ids of all reactions if defined
-
std::vector<double> getReactionRates()
- Returns:
the reaction rates
-
std::vector<std::string> getFloatingSpeciesNames()
- Returns:
the names of all floating species
-
std::vector<std::string> getFloatingSpeciesIds()
- Returns:
the sbml ids of all floating species if defined
-
std::vector<double> getFloatingSpeciesConcentrations()
- Returns:
the concentrations of all floating species
-
std::vector<double> getRatesOfChange()
- Returns:
the rates of change of all floating species
-
std::vector<std::string> getBoundarySpeciesNames()
- Returns:
the names of all boundary species
-
std::vector<std::string> getBoundarySpeciesIds()
- Returns:
the sbml ids of all boundary species if defined
-
std::vector<double> getBoundarySpeciesConcentrations()
- Returns:
the concentrations of all boundary species
-
std::vector<std::string> getCompartmentNames()
- Returns:
the names of all compartments
-
std::vector<std::string> getCompartmentIds()
- Returns:
the sbml ids of all compartments if defined
-
std::vector<double> getCompartmentSizes()
- Returns:
the sizes of all compartments
-
std::vector<std::string> getGlobalParameterNames()
- Returns:
the names of all global parameters
-
std::vector<std::string> getGlobalParameterIds()
- Returns:
the the sbml ids of all global parameters if defined
-
std::vector<double> getGlobalParameterValues()
- Returns:
the values of all global parameters
-
std::vector<std::string> getLocalParameterNames()
returns local paramters names
The local parameter names will be (reaction name).(local parameter name)
- Returns:
the names of all local parameters
-
std::vector<double> getLocalParameterValues()
- Returns:
local paramters values
-
double getValue(const std::string &nameOrId)
- Parameters:
nameOrId – the symbol to look up (name or sbml id)
- Returns:
the value of the selected symbol (lookup via name or sbml id)
-
void setValue(const std::string &nameOrId, double value)
sets the value of the selected symbol
- Parameters:
nameOrId – the symbol to set (name or sbml id)
value – the value to set
-
void setValueByName(const std::string &name, double value)
sets the value by display name
-
std::string getJacobian()
returns the Jacobian at steady state as JSON string
{ "rows": ["X", "Y", ...], "columns": ["X", "Y", ...], "values": [ [1.0, 0.0, ...], [0.0, 1.0, ...], ... ] }
- Returns:
the Jacobian as JSON string in the following format
-
std::vector<std::vector<double>> getJacobian2D()
returns the Jacobian at steady state as 2D double vector
-
std::vector<std::vector<double>> getEigenValues2D()
returns the eigenvalues of the Jacobian at steady state as 2D double vector
-
std::string getJacobianReduced()
returns the reduced Jacobian at steady state as JSON string
{ "rows": ["X", "Y", ...], "columns": ["X", "Y", ...], "values": [ [1.0, 0.0, ...], [0.0, 1.0, ...], ... ] }
- Returns:
the Jacobian as JSON string in the following format
-
std::vector<std::vector<double>> getJacobianReduced2D()
returns the reduced Jacobian at steady state as 2D double vector
-
std::vector<std::vector<double>> getEigenValuesReduced2D()
returns the reduced eigenvalues of the Jacobian at steady state as 2D double vector
-
std::string getFluxControlCoefficients(bool scaled)
returns the flux control coefficients as JSON string
- Parameters:
scaled – if true the scaled coefficients are returned
-
std::vector<std::vector<double>> getFluxControlCoefficients2D(bool scaled)
returns the flux control coefficients as 2D double vector
- Parameters:
scaled – if true the scaled coefficients are returned
-
std::string getConcentrationControlCoefficients(bool scaled)
returns the concentration control coefficients as JSON string
- Parameters:
scaled – if true the scaled coefficients are returned
-
std::vector<std::vector<double>> getConcentrationControlCoefficients2D(bool scaled)
returns the concentration control coefficients as 2D double vector
- Parameters:
scaled – if true the scaled coefficients are returned
-
std::string getElasticities(bool scaled)
returns the elasticities as JSON string
- Parameters:
scaled – if true the scaled elasticities are returned
-
std::vector<std::vector<double>> getElasticities2D(bool scaled)
returns the elasticities as 2D double vector
- Parameters:
scaled – if true the scaled elasticities are returned
-
void cpsFree(char *ptr)
frees a pointer allocated by the COPASI library
-
int initCps()
initializes the COPASI library
This function also ensures that a data model exists
- Returns:
true if successful
-
void destroyAPI()
destroys the API, datamodel and root container
-
void ensureModel()
ensures that a data model exists This will call
See also
initCps if necessary
-
nlohmann::ordered_json convertGroupToJson(CCopasiParameterGroup *pGroup, bool basicOnly = true)
this function converts a parameter group to a json object
- Parameters:
pGroup – the parameter group to convert
basicOnly – if true (default) only the basic information is converted
- Returns:
an ordered json object
-
void setGroupFromJson(CCopasiParameterGroup *pGroup, nlohmann::ordered_json &settings)
this function sets a parameter group from a json object
- Parameters:
pGroup – the parameter group to change
settings – the json object with values to change
-
nlohmann::ordered_json convertDataHandlerToJSON(const CDataHandler &dh)
converts a data handler to a json object
-
nlohmann::ordered_json convertTimeSeriesToJSON(const CTimeSeries &ts)
converts a time series to a json object
-
void fillStream(const CTimeSeries &ts, std::stringstream &str)
fills a stream with the data from a time series This generates Data in the form of a table (might not be needded anymore)
-
void loadCommon()
helper method after loading from file / string constructs a parameter set for the initial state, that is
-
std::string simulateJSON(nlohmann::ordered_json &yaml)
runs a simulation and returns the result as json string
{ "num_variables": 3, "recorded_steps": 11, "titles": [ "Time", ... ], "columns": [ [ 0.0, 1.0, ... ], ... ] }
See also
applyYaml
- Parameters:
yaml – the yaml object with the simulation settings and possibly changed initial values the format is the same as
- Returns:
the result as json string in the following format
-
CDataObject *resolveMcaObject(const std::string &item)
-
std::string getVersion()
- dir /home/docs/checkouts/readthedocs.org/user_builds/copasijs/checkouts/latest/src