biosimulators_pyneuroml package

class biosimulators_pyneuroml.Simulator(value)[source]

Bases: str, enum.Enum

A LEMS simulator

brian2 = 'Brian2'[source]
netpyne = 'NetPyNe'[source]
neuron = 'NEURON'[source]
pyneuroml = 'pyNeuroML'[source]
biosimulators_pyneuroml.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, simulator=Simulator.pyneuroml)[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 (Simulator, optional) – simulator

Returns

  • ReportResults: results of each report

  • SedDocumentLog: log of the document

Return type

tuple

biosimulators_pyneuroml.exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None, simulator=Simulator.pyneuroml)[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

  • simulator (Simulator, optional) – simulator

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_pyneuroml.exec_sedml_docs_in_combine_archive(archive_filename, out_dir, config=None, simulator=Simulator.pyneuroml)[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

  • simulator (Simulator, optional) – simulator

  • config (Config, optional) – BioSimulators common configuration

Returns

  • SedDocumentResults: results

  • CombineArchiveLog: log

Return type

tuple

biosimulators_pyneuroml.preprocess_sed_task(task, variables, config=None, simulator=Simulator.pyneuroml)[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

  • simulator (Simulator, optional) – simulator

Returns

preprocessed information about the task

Return type

dict

Submodules

biosimulators_pyneuroml.core module

Methods for using pyNeuroML to execute SED tasks in COMBINE archives and save their outputs

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-05-28

Copyright

2021, Center for Reproducible Biomedical Modeling

License

MIT

biosimulators_pyneuroml.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, simulator=Simulator.pyneuroml)[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 (Simulator, optional) – simulator

Returns

  • ReportResults: results of each report

  • SedDocumentLog: log of the document

Return type

tuple

biosimulators_pyneuroml.core.exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None, simulator=Simulator.pyneuroml)[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

  • simulator (Simulator, optional) – simulator

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_pyneuroml.core.exec_sedml_docs_in_combine_archive(archive_filename, out_dir, config=None, simulator=Simulator.pyneuroml)[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

  • simulator (Simulator, optional) – simulator

  • config (Config, optional) – BioSimulators common configuration

Returns

  • SedDocumentResults: results

  • CombineArchiveLog: log

Return type

tuple

biosimulators_pyneuroml.core.preprocess_sed_task(task, variables, config=None, simulator=Simulator.pyneuroml)[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

  • simulator (Simulator, optional) – simulator

Returns

preprocessed information about the task

Return type

dict

biosimulators_pyneuroml.data_model module

Data model for pyNeuroML algorithms and their parameters

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-06-02

Copyright

2021, Center for Reproducible Biomedical Modeling

License

MIT

class biosimulators_pyneuroml.data_model.RunLemsOptions(paths_to_include=None, num_processors=None, max_memory=None, skip_run=False, no_gui=True, load_saved_data=False, reload_events=False, plot=False, show_plot_already=False, exec_in_dir='.', verbose=False, exit_on_fail=False, cleanup=True, only_generate_scripts=False, compile_mods=True, realtime_output=False)[source]

Bases: object

Options for running a LEMS file

paths_to_include[source]
Type

list of str

num_processors[source]
Type

int

max_memory[source]

maximum memory in bytes

Type

int

skip_run[source]
Type

bool

no_gui[source]
Type

bool

load_saved_data[source]
Type

bool

reload_events[source]
Type

bool

plot[source]
Type

bool

show_plot_already[source]
Type

bool

exec_in_dir[source]
Type

str

verbose[source]
Type

bool

exit_on_fail[source]
Type

bool

cleanup[source]
Type

bool

only_generate_scripts[source]
Type

bool

compile_mods[source]
Type

bool

realtime_output[source]
Type

bool

to_kw_args(simulator)[source]

Format options as keyword arguments for a LEMS run method

Parameters

simulator (Simulator) – simulator

Returns

keyword arguments for a LEMS run method

Return type

dict

class biosimulators_pyneuroml.data_model.Simulator(value)[source]

Bases: str, enum.Enum

A LEMS simulator

brian2 = 'Brian2'[source]
netpyne = 'NetPyNe'[source]
neuron = 'NEURON'[source]
pyneuroml = 'pyNeuroML'[source]

biosimulators_pyneuroml.utils module

Utilities for pyNeuroML

Author

Jonathan Karr <karr@mssm.edu>

Date

2021-06-02

Copyright

2021, Center for Reproducible Biomedical Modeling

License

MIT

biosimulators_pyneuroml.utils.get_available_memory()[source]

Get the amount of memory available

Returns

amount of memory available in bytes

Return type

int

biosimulators_pyneuroml.utils.get_available_processors()[source]

Get the amount of processors available

Returns

amount of processors available

Return type

int

biosimulators_pyneuroml.utils.get_run_lems_options(num_processors=None, max_memory=None, verbose=False)[source]

Get options for running a LEMS document

Parameters
  • num_processors (int, optional) – number of processors to use (only used with NetPyNe)

  • max_memory (int, optional) – maximum memory to use in bytes

  • verbose (bool, optional) – whether to display extra information about simulation runs

Returns

options

Return type

RunLemsOptions

biosimulators_pyneuroml.utils.get_simulator_run_lems_method(simulator)[source]

Get the LEMS run method for a simulator

Parameters

simulator (Simulator) – simulator to run the LEMS document

Returns

run LEMS method

Return type

types.FunctionType

biosimulators_pyneuroml.utils.read_lems_output_files_configuration(xml_root)[source]

Read the configuration of the output files of a LEMS document

Parameters

xml_root (lxml.etree._Element) – LEMS document

Returns

configuration of the output files of a LEMS document

Return type

list of dict

biosimulators_pyneuroml.utils.read_xml_file(filename, remove_blank_text=True)[source]

Read an XML file

Parameters
  • filename (str) – path to an XML file

  • remove_blank_text (bool, optional) – whether to remove formatting so that the file could be exported pretty-printed

Returns

root element for the XML file

Return type

lxml.etree._Element

biosimulators_pyneuroml.utils.run_lems_xml(lems_xml_root, working_dirname='.', lems_filename=None, simulator=Simulator.pyneuroml, num_processors=None, max_memory=None, verbose=False, config=None)[source]

Run a LEMS document with a simulator

Parameters
  • lems_xml_root (lxml.etree._Element) – LEMS document

  • working_dirname (str, optional) – working directory for the LEMS document

  • lems_filename (str, optional) – path to file for the LEMS document

  • simulator (Simulator, optional) – simulator to run the LEMS document

  • num_processors (int, optional) – number of processors to use (only used with NetPyNe)

  • max_memory (int, optional) – maximum memory to use in bytes

  • verbose (bool, optional) – whether to display extra information about simulation runs

  • config (Config, optional) – BioSimulators common configuration

Returns

dictionary that maps the id of each output file

to a Pandas data frame with its value

Return type

dict of str => pandas.DataFrame

biosimulators_pyneuroml.utils.set_sim_in_lems_xml(simulation_xml, task, variables)[source]

Set the simulation in a LEMS document

Parameters
  • simulation_xml (lxml.etree._Element) – LEMS simulation

  • task (Task) – task

  • variables (list of Variable) – variables to record

biosimulators_pyneuroml.utils.validate_lems_document(lems_xml_root)[source]

Validate LEMS document

Parameters

lems_xml_root (lxml.etree._Element) – LEMS document

biosimulators_pyneuroml.utils.validate_task(task, variables, simulator, config=None)[source]

Validate a task

Parameters
  • task (Task) – task

  • variables (list of Variable) – variables

  • simulator (Simulator) – simulator

  • config (Config, optional) – BioSimulators common configuration

Returns

KiSAO id for a possibly alternative simulation algorithm

Return type

str

biosimulators_pyneuroml.utils.write_lems_output_files_configuration(xml_root, output_file_configs)[source]

Read the configuration of the output files of a LEMS document

Parameters
  • xml_root (lxml.etree._Element) – LEMS document

  • output_file_configs (list of dict) – configuration of the output files of a LEMS document

biosimulators_pyneuroml.utils.write_xml_file(root, filename, pretty_print=True)[source]

Write an XML file

Parameters
  • root (lxml.etree._Element) – root element for the XML file

  • filename (str) – path to an XML file

  • pretty_print (bool, optional) – whether to pretty-print the file (required for NeuroML)