biosimulators_bionetgen package

biosimulators_bionetgen.get_simulator_version()[source]

Get the version of BioNetGen

Returns

version

Return type

str

Submodules

biosimulators_bionetgen.config module

Configuration for BioSimulators-BioNetGen

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-01-05

Copyright

2020-2021, Center for Reproducible Biomedical Modeling

License

MIT

class biosimulators_bionetgen.config.Config[source]

Bases: object

Configuration

bionetgen_path[source]

path to BioNetGen executable

Type

str

biosimulators_bionetgen.core module

BioSimulators-compliant command-line interface to the BioNetGen simulation program.

Author

Jonathan Karr <karr@mssm.edu>

Author

Ali Sinan Saglam <als251@pitt.edu>

Date

2021-01-05

Copyright

2020-2021, Center for Reproducible Biomedical Modeling

License

MIT

biosimulators_bionetgen.core.exec_sed_doc(doc, working_dir, base_out_path, rel_out_path=None, apply_xml_model_changes=False, 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_bionetgen.core.exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None)[source]

Execute a task and save its results

Parameters
  • task (Task) – SED 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

biosimulators_bionetgen.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 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

Returns

  • SedDocumentResults: results

  • CombineArchiveLog: log

Return type

tuple

biosimulators_bionetgen.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_bionetgen.data_model module

Data structures for representing BNGL models

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-01-05

Copyright

2020-2021, Center for Reproducible Biomedical Modeling

License

MIT

class biosimulators_bionetgen.data_model.Model[source]

Bases: collections.OrderedDict

A BNGL model: a collection of model blocks

is_equal(other)[source]

Determine whether two models are semantically equivalent

Parameters

other (Model) – second model

Returns

whether the models are semantically equivalent

Return type

bool

class biosimulators_bionetgen.data_model.ModelBlock(iterable=(), /)[source]

Bases: list

A “block” or section of a model such as parameters or ‘molecule types’

is_equal(other)[source]

Determine whether two model blocks are semantically equivalent

Parameters

other (ModelBlock) – second model block

Returns

whether the model blocks are semantically equivalent

Return type

bool

class biosimulators_bionetgen.data_model.Task(model=None, actions=None)[source]

Bases: object

A BNGL task

Attributes

model (Model): model actions (list of str): actions such as simulations

is_equal(other)[source]

Determine whether two model blocks are semantically equivalent

Parameters

other (ModelBlock) – second model block

Returns

whether the model blocks are semantically equivalent

Return type

bool

biosimulators_bionetgen.io module

Methods for reading BNGL models

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-01-05

Copyright

2020-2021, Center for Reproducible Biomedical Modeling

License

MIT

biosimulators_bionetgen.io.read_simulation_results(filename)[source]

Read the predicted time courses of the observables of a simulation

Parameters

filename (str) – path to simulation results in BioNetGen’s gdat format

Returns

predicted time courses of the observables

Return type

pandas.DataFrame

biosimulators_bionetgen.io.read_task(filename)[source]

Read a BNGL task from a file.

Parameters

filename (str) – path to the task

Returns

task

Return type

Task

Raises

ValueError – if the file is invalid

biosimulators_bionetgen.io.write_task(task, filename)[source]

Write a BNGL task to a file

Parameters
  • task (Task) – task

  • filename (str) – path to save the model

biosimulators_bionetgen.utils module

Utilities for working with BioNetGen

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-01-05

Copyright

2020-2021, Center for Reproducible Biomedical Modeling

License

MIT

biosimulators_bionetgen.utils.add_model_attribute_change_to_task(task, change, preprocessed_change=None)[source]

Encode SED model attribute changes into a BioNetGen task

  • Compartment sizes: targets should follow the pattern compartments.<compartment_id>.size

  • Function expressions: targets should follow the pattern functions.<function_id>.expression

  • Initial species counts: targets should follow the pattern species.<species_id>.count

  • Parameter values: targets should follow the pattern parameters.<parameter_id>.value

Parameters
  • task (Task) – BioNetGen task

  • change (ModelAttributeChange) – model attribute change

  • preprocessed_change (dict) – preprocessed information about the change

Raises

ValueError – if a target of a change is not valid

biosimulators_bionetgen.utils.add_variables_to_model(model, variables)[source]

Encode SED variables into observables in a BioNetGen task

Parameters
  • model (Model) – model

  • variables (list of Variable) – desired variables

Raises

NotImplementedError – if BioNetGen doesn’t support the symbol or target of a variable

biosimulators_bionetgen.utils.create_actions_for_simulation(simulation, config=None)[source]

Create BioNetGen actions for a SED simulation

Parameters
  • simulation (UniformTimeCourseSimulation) – SED simulation

  • config (Config, optional) – configuration

Raises

NotImplementedError – if BioNetGen doesn’t support the request algorithm or algorithm parameters

Returns

  • list of str: actions for SED simulation

  • str: KiSAO id of the algorithm that will be executed

Return type

tuple

biosimulators_bionetgen.utils.exec_bionetgen_task(task, verbose=True)[source]

Execute a task and return the predicted values of the observables

Parameters
  • task (Task) – task

  • verbose (bool, optional) – whether to display diagnostic information

Returns

predicted values of the observables

Return type

pandas.DataFrame

Raises

Exception – if the task fails

biosimulators_bionetgen.utils.get_variables_results_from_observable_results(observable_results, variables)[source]

Get the predicted values of the desired variables

Parameters
  • observable_results (pandas.DataFrame) – predicted values of the observables of a simulation

  • variables (list of Variable) – desired variables

Returns

predicted values of the desired variables

Return type

VariableResults

Raises
  • NotImplementedError – if an unsupported symbol is requested

  • ValueError – if an undefined target is requested

biosimulators_bionetgen.utils.preprocess_model_attribute_change(task, change)[source]

Process a model change

  • Compartment sizes: targets should follow the pattern compartments.<compartment_id>.size

  • Function expressions: targets should follow the pattern functions.<function_id>.expression

  • Initial species counts: targets should follow the pattern species.<species_id>.count

  • Parameter values: targets should follow the pattern parameters.<parameter_id>.value

Parameters
  • task (Task) – BioNetGen task

  • change (ModelAttributeChange) – model attribute change

Returns

processed information about the model change

Return type

dict

Raises

ValueError – if a target of a change is not valid

biosimulators_bionetgen.warnings module

Warnings

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-01-05

Copyright

2020-2021, Center for Reproducible Biomedical Modeling

License

MIT

exception biosimulators_bionetgen.warnings.BioNetGenWarning[source]

Bases: UserWarning

Base class for warnings

exception biosimulators_bionetgen.warnings.IgnoredBnglFileContentWarning[source]

Bases: biosimulators_bionetgen.warnings.BioNetGenWarning

Warning for content of a BNGL file that is ignored