biosimulators_cobrapy package¶
- biosimulators_cobrapy.exec_sed_doc(doc, working_dir, base_out_path, rel_out_path=None, apply_xml_model_changes=True, log=None, indent=0, pretty_print_modified_xml_models=False, log_level=StandardOutputErrorCapturerLevel.c, config=None)[source]¶
Execute the tasks specified in a SED document and generate the specified outputs
- Parameters
doc (
SedDocument
orstr
) – SED document or a path to SED-ML file which defines a SED documentworking_dir (
str
) – working directory of the SED document (path relative to which models are located)base_out_path (
str
) –path to store the outputs
CSV: directory in which to save outputs to files
{base_out_path}/{rel_out_path}/{report.id}.csv
HDF5: directory in which to save a single HDF5 file (
{base_out_path}/reports.h5
), with reports at keys{rel_out_path}/{report.id}
within the HDF5 file
rel_out_path (
str
, optional) – path relative tobase_out_path
to store the outputsapply_xml_model_changes (
bool
, optional) – ifTrue
, apply any model changes specified in the SED-ML file before callingtask_executer
.log (
SedDocumentLog
, optional) – log of the documentindent (
int
, optional) – degree to indent status messagespretty_print_modified_xml_models (
bool
, optional) – ifTrue
, pretty print modified XML modelslog_level (
StandardOutputErrorCapturerLevel
, optional) – level at which to log outputconfig (
Config
, optional) – BioSimulators common configurationsimulator_config (
SimulatorConfig
, optional) – tellurium configuration
- Returns
ReportResults
: results of each reportSedDocumentLog
: log of the document
- Return type
tuple
- biosimulators_cobrapy.exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None)[source]¶
Execute a task and save its results
- Parameters
task (
Task
) – taskvariables (
list
ofVariable
) – variables that should be recordedpreprocessed_task (
dict
, optional) – preprocessed information about the task, including possible model changes and variables. This can be used to avoid repeatedly executing the same initialization for repeated calls to this method.log (
TaskLog
, optional) – log for the taskconfig (
Config
, optional) – BioSimulators common configuration
- Returns
VariableResults
: results of variablesTaskLog
: log- Return type
tuple
- Raises
ValueError – if the task or an aspect of the task is not valid, or the requested output variables could not be recorded
NotImplementedError – if the task is not of a supported type or involves an unsuported feature
- biosimulators_cobrapy.exec_sedml_docs_in_combine_archive(archive_filename, out_dir, config=None)[source]¶
Execute the SED tasks defined in a COMBINE/OMEX archive and save the outputs
- Parameters
archive_filename (
str
) – path to COMBINE/OMEX archiveout_dir (
str
) –path to store the outputs of the archive
CSV: directory in which to save outputs to files
{ out_dir }/{ relative-path-to-SED-ML-file-within-archive }/{ report.id }.csv
HDF5: directory in which to save a single HDF5 file (
{ out_dir }/reports.h5
), with reports at keys{ relative-path-to-SED-ML-file-within-archive }/{ report.id }
within the HDF5 file
config (
Config
, optional) – BioSimulators common configuration
- Returns
SedDocumentResults
: resultsCombineArchiveLog
: log
- Return type
tuple
- biosimulators_cobrapy.get_simulator_version()[source]¶
Get the version of COBRApy
- Returns
version
- Return type
str
- biosimulators_cobrapy.preprocess_sed_task(task, variables, config=None)[source]¶
Preprocess a SED task, including its possible model changes and variables. This is useful for avoiding repeatedly initializing tasks on repeated calls of
exec_sed_task
.- Parameters
task (
Task
) – taskvariables (
list
ofVariable
) – variables that should be recordedconfig (
Config
, optional) – BioSimulators common configuration
- Returns
preprocessed information about the task
- Return type
dict
Submodules¶
biosimulators_cobrapy.core module¶
Methods for using COBRApy to execute SED tasks in COMBINE archives and save their outputs
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2020-12-31
- Copyright
2020, BioSimulators Team
- License
MIT
- biosimulators_cobrapy.core.exec_sed_doc(doc, working_dir, base_out_path, rel_out_path=None, apply_xml_model_changes=True, log=None, indent=0, pretty_print_modified_xml_models=False, log_level=StandardOutputErrorCapturerLevel.c, config=None)[source]¶
Execute the tasks specified in a SED document and generate the specified outputs
- Parameters
doc (
SedDocument
orstr
) – SED document or a path to SED-ML file which defines a SED documentworking_dir (
str
) – working directory of the SED document (path relative to which models are located)base_out_path (
str
) –path to store the outputs
CSV: directory in which to save outputs to files
{base_out_path}/{rel_out_path}/{report.id}.csv
HDF5: directory in which to save a single HDF5 file (
{base_out_path}/reports.h5
), with reports at keys{rel_out_path}/{report.id}
within the HDF5 file
rel_out_path (
str
, optional) – path relative tobase_out_path
to store the outputsapply_xml_model_changes (
bool
, optional) – ifTrue
, apply any model changes specified in the SED-ML file before callingtask_executer
.log (
SedDocumentLog
, optional) – log of the documentindent (
int
, optional) – degree to indent status messagespretty_print_modified_xml_models (
bool
, optional) – ifTrue
, pretty print modified XML modelslog_level (
StandardOutputErrorCapturerLevel
, optional) – level at which to log outputconfig (
Config
, optional) – BioSimulators common configurationsimulator_config (
SimulatorConfig
, optional) – tellurium configuration
- Returns
ReportResults
: results of each reportSedDocumentLog
: log of the document
- Return type
tuple
- biosimulators_cobrapy.core.exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None)[source]¶
Execute a task and save its results
- Parameters
task (
Task
) – taskvariables (
list
ofVariable
) – variables that should be recordedpreprocessed_task (
dict
, optional) – preprocessed information about the task, including possible model changes and variables. This can be used to avoid repeatedly executing the same initialization for repeated calls to this method.log (
TaskLog
, optional) – log for the taskconfig (
Config
, optional) – BioSimulators common configuration
- Returns
VariableResults
: results of variablesTaskLog
: log- Return type
tuple
- Raises
ValueError – if the task or an aspect of the task is not valid, or the requested output variables could not be recorded
NotImplementedError – if the task is not of a supported type or involves an unsuported feature
- biosimulators_cobrapy.core.exec_sedml_docs_in_combine_archive(archive_filename, out_dir, config=None)[source]¶
Execute the SED tasks defined in a COMBINE/OMEX archive and save the outputs
- Parameters
archive_filename (
str
) – path to COMBINE/OMEX archiveout_dir (
str
) –path to store the outputs of the archive
CSV: directory in which to save outputs to files
{ out_dir }/{ relative-path-to-SED-ML-file-within-archive }/{ report.id }.csv
HDF5: directory in which to save a single HDF5 file (
{ out_dir }/reports.h5
), with reports at keys{ relative-path-to-SED-ML-file-within-archive }/{ report.id }
within the HDF5 file
config (
Config
, optional) – BioSimulators common configuration
- Returns
SedDocumentResults
: resultsCombineArchiveLog
: log
- Return type
tuple
- biosimulators_cobrapy.core.preprocess_sed_task(task, variables, config=None)[source]¶
Preprocess a SED task, including its possible model changes and variables. This is useful for avoiding repeatedly initializing tasks on repeated calls of
exec_sed_task
.- Parameters
task (
Task
) – taskvariables (
list
ofVariable
) – variables that should be recordedconfig (
Config
, optional) – BioSimulators common configuration
- Returns
preprocessed information about the task
- Return type
dict
biosimulators_cobrapy.data_model module¶
Data model for mapping KiSAO terms for algorithms and their parameters to COBRApy methods and their arguments
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2020-12-31
- Copyright
2020, BioSimulators Team
- License
MIT
biosimulators_cobrapy.utils module¶
Utilities for working with COBRApy
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2020-12-31
- Copyright
2020, BioSimulators Team
- License
MIT
- biosimulators_cobrapy.utils.apply_variables_to_simulation_method_args(target_x_paths_ids, method_props, variables, model_method_kw_args)[source]¶
Encode the desired output variables into arguments to simulation methods
- Parameters
target_x_paths_ids (
dict
ofstr
tostr
) – dictionary that maps each XPath to the SBML id of the corresponding model objectmethod_props (
dict
) – properties of the simulation methodvariables (
list
ofVariable
) – variables that should be recordedmodel_method_kw_args (
dict
) – keyword arguments for the simulation method for the model
- biosimulators_cobrapy.utils.get_objective_sbml_fbc_ids(model_source)[source]¶
Get the SBML-FBC id of the active objective
- Parameters
model_source (
str
) – path to model- Returns
str
: SBML-FBC id of the active objectivelist
ofstr
: SBML-FBC id of the objectives
- Return type
tuple
- biosimulators_cobrapy.utils.get_results_of_variables(target_results_path_map, variables, solution)[source]¶
Get the results of the desired variables
- Parameters
target_results_path_map (
dict
) – path to results of desired variablesvariables (
list
ofVariable
) – variables that should be recordedsolution (
cobra.core.solution.Solution
) – solution of method
- Returns
the results of desired variables
- Return type
VariableResults
- biosimulators_cobrapy.utils.get_results_paths_for_variables(model, active_objective_sbml_fbc_id, objective_sbml_fbc_ids, method, variables, target_sbml_id_map, target_sbml_fbc_id_map)[source]¶
Get the path to results for the desired variables
- Parameters
model (
cobra.core.model.Model
) – modelactive_objective_sbml_fbc_id (
str
) – SBML-FBC id of the active objectiveobjective_sbml_fbc_ids (
list
ofstr
) – SBML-FBC id of the objectivesmethod (
dict
) – properties of desired simulation methodvariables (
list
ofVariable
) – variables that should be recordedtarget_sbml_id_map (
dict
ofstr
tostr
) – dictionary that maps each XPath to the SBML id of the corresponding model objecttarget_sbml_fbc_id_map (
dict
ofstr
tostr
) – dictionary that maps each XPath to the SBML-FBC id of the corresponding model object
- Returns
path to results of desired variables
- Return type
dict
- biosimulators_cobrapy.utils.set_simulation_method_arg(method_props, argument_change, model, model_method_kw_args)[source]¶
Set the value of an argument of a simulation method based on a SED algorithm parameter change
- Parameters
method_props (
dict
) – properties of the simulation methodargument_change (
AlgorithmParameterChange
) – algorithm parameter changemodel (
cobra.core.model.Model
) –model_method_kw_args (
dict
) – keyword arguments for the simulation method for the model
- Raises
NotImplementedError – if the simulation method doesn’t support the parameter
ValueError – if the new value is not a valid value of the parameter
- biosimulators_cobrapy.utils.validate_variables(model, active_objective_sbml_fbc_id, objective_sbml_fbc_ids, method, variables, target_sbml_id_map, target_sbml_fbc_id_map, sbml_fbc_uri)[source]¶
Validate the desired output variables of a simulation
- Parameters
model (
cobra.core.model.Model
) – modelactive_objective_sbml_fbc_id (
str
) – SBML-FBC id of the active objectiveobjective_sbml_fbc_ids (
list
ofstr
) – SBML-FBC id of the objectivesmethod (
dict
) – properties of desired simulation methodvariables (
list
ofVariable
) – variables that should be recordedtarget_sbml_id_map (
dict
ofstr
tostr
) – dictionary that maps each XPath to the SBML id of the corresponding model objecttarget_sbml_fbc_id_map (
dict
ofstr
tostr
) – dictionary that maps each XPath to the SBML-FBC id of the corresponding model objectsbml_fbc_uri (
str
) – URI for SBML FBC package