biosimulators_copasi package

biosimulators_copasi.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 or str) – SED document or a path to SED-ML file which defines a SED document

  • working_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 to base_out_path to store the outputs

  • apply_xml_model_changes (bool, optional) – if True, apply any model changes specified in the SED-ML file before calling task_executer.

  • log (SedDocumentLog, optional) – log of the document

  • indent (int, optional) – degree to indent status messages

  • pretty_print_modified_xml_models (bool, optional) – if True, pretty print modified XML models

  • log_level (StandardOutputErrorCapturerLevel, optional) – level at which to log output

  • config (Config, optional) – BioSimulators common configuration

  • simulator_config (SimulatorConfig, optional) – tellurium configuration

Returns

  • ReportResults: results of each report

  • SedDocumentLog: log of the document

Return type

tuple

biosimulators_copasi.exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None)[source]

Execute a task and save its results

Parameters
  • task (Task) – task

  • variables (list of Variable) – variables that should be recorded

  • preprocessed_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 task

  • config (Config, optional) – BioSimulators common configuration

Returns

VariableResults: results of variables TaskLog: 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_copasi.exec_sedml_docs_in_combine_archive(archive_filename, out_dir, config=None, fix_copasi_generated_combine_archive=None)[source]

Execute the SED tasks defined in a COMBINE/OMEX archive and save the outputs

Parameters
  • archive_filename (str) – path to COMBINE/OMEX archive

  • out_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

  • fix_copasi_generated_combine_archive (bool, optional) – Whether to make COPASI-generated COMBINE archives compatible with the specifications of the OMEX manifest and SED-ML standards

Returns

  • SedDocumentResults: results

  • CombineArchiveLog: log

Return type

tuple

biosimulators_copasi.get_simulator_version()[source]

Get the version of COPASI

Returns

version

Return type

str

biosimulators_copasi.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) – task

  • variables (list of Variable) – variables that should be recorded

  • config (Config, optional) – BioSimulators common configuration

Returns

preprocessed information about the task

Return type

dict

Submodules

biosimulators_copasi.core module

Methods for executing SED tasks in COMBINE archives and saving their outputs

Author

Jonathan Karr <karr@mssm.edu>

Author

Akhil Marupilla <akhilmteja@gmail.com>

Date

2020-11-17

Copyright

2020, Center for Reproducible Biomedical Modeling

License

MIT

biosimulators_copasi.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 or str) – SED document or a path to SED-ML file which defines a SED document

  • working_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 to base_out_path to store the outputs

  • apply_xml_model_changes (bool, optional) – if True, apply any model changes specified in the SED-ML file before calling task_executer.

  • log (SedDocumentLog, optional) – log of the document

  • indent (int, optional) – degree to indent status messages

  • pretty_print_modified_xml_models (bool, optional) – if True, pretty print modified XML models

  • log_level (StandardOutputErrorCapturerLevel, optional) – level at which to log output

  • config (Config, optional) – BioSimulators common configuration

  • simulator_config (SimulatorConfig, optional) – tellurium configuration

Returns

  • ReportResults: results of each report

  • SedDocumentLog: log of the document

Return type

tuple

biosimulators_copasi.core.exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None)[source]

Execute a task and save its results

Parameters
  • task (Task) – task

  • variables (list of Variable) – variables that should be recorded

  • preprocessed_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 task

  • config (Config, optional) – BioSimulators common configuration

Returns

VariableResults: results of variables TaskLog: 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_copasi.core.exec_sedml_docs_in_combine_archive(archive_filename, out_dir, config=None, fix_copasi_generated_combine_archive=None)[source]

Execute the SED tasks defined in a COMBINE/OMEX archive and save the outputs

Parameters
  • archive_filename (str) – path to COMBINE/OMEX archive

  • out_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

  • fix_copasi_generated_combine_archive (bool, optional) – Whether to make COPASI-generated COMBINE archives compatible with the specifications of the OMEX manifest and SED-ML standards

Returns

  • SedDocumentResults: results

  • CombineArchiveLog: log

Return type

tuple

biosimulators_copasi.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) – task

  • variables (list of Variable) – variables that should be recorded

  • config (Config, optional) – BioSimulators common configuration

Returns

preprocessed information about the task

Return type

dict

biosimulators_copasi.data_model module

Data model for maps from KiSAO terms to COPASI algorithms and their arguments

Author

Jonathan Karr <karr@mssm.edu>

Date

2020-12-13

Copyright

2020, BioSimulators Team

License

MIT

class biosimulators_copasi.data_model.Units(value)[source]

Bases: str, enum.Enum

Function for getting simulation results

continuous = 'continuous'[source]
discrete = 'discrete'[source]

biosimulators_copasi.utils module

Utilities for working with the maps from KiSAO ids to COPASI methods and their arguments

Author

Jonathan Karr <karr@mssm.edu>

Date

2020-12-13

Copyright

2020, BioSimulators Team

License

MIT

biosimulators_copasi.utils.fix_copasi_generated_combine_archive(in_filename, out_filename, config=None)[source]

Utility function that corrects COMBINE/OMEX archives generated by COPASI so they are compatible with other tools.

All currently released versions of COPASI export COMBINE archive files. However, these archives presently diverge from the specifications of the SED-ML format.

  • Format in OMEX manifests is not a valid PURL media type URI

  • SED-ML files lack namespaces for SBML

Parameters
  • in_filename (str) – path to a COMBINE archive to correct

  • out_filename (str) – path to save correctd COMBINE archive

  • config (Config, optional) – BioSimulators-utils configuration

biosimulators_copasi.utils.get_algorithm_id(kisao_id, events=False, config=None)[source]

Get the COPASI id for an algorithm

Parameters
  • kisao_id (str) – KiSAO algorithm id

  • events (bool, optional) – whether an algorithm that supports events is needed

  • config (Config, optional) – configuration

Returns

  • str: KiSAO id of algorithm to execute

  • int: COPASI id for algorithm

Return type

tuple

biosimulators_copasi.utils.get_copasi_model_obj_sbml_ids(model)[source]

Get the SBML id of each object of a COPASI model

Parameters

model (COPASI.CModel) – model

Returns

obj:`str: SBML id of each object of the model

Return type

list of

biosimulators_copasi.utils.get_copasi_model_object_by_sbml_id(model, id, units)[source]

Get a COPASI model object by its SBML id

Parameters
  • model (COPASI.CModel) – model

  • id (str) – SBML id

  • units (Units) – desired units for the object

Returns

model object

Return type

COPASI.CCompartment, COPASI.CMetab, COPASI.CModelValue, or COPASI.CReaction

biosimulators_copasi.utils.set_algorithm_parameter_value(algorithm_kisao_id, algorithm_function, parameter_kisao_id, value)[source]

Set a parameter of a COPASI simulation function

Parameters
  • algorithm_kisao_id (str) – KiSAO algorithm id

  • algorithm_function (types.FunctionType) – algorithm function

  • parameter_kisao_id (str) – KiSAO parameter id

  • value (string) – parameter value

Returns

names of the COPASI parameters that were set and their values

Return type

dict