biosimulators_utils.combine package#
Submodules#
biosimulators_utils.combine.data_model module#
Data model for COMBINE/OMEX archives
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- class biosimulators_utils.combine.data_model.CombineArchive(contents=None)[source]#
Bases:
CombineArchiveBase
A COMBINE/OMEX archive
- contents[source]#
contents of the archive
- Type:
list
ofCombineArchiveContent
- get_master_content()[source]#
Get the master content of an archive
- Returns:
master content
- Return type:
list
ofCombineArchiveContent
- is_equal(other)[source]#
Determine if two content items are equal
- Parameters:
other (
CombineArchiveContent
) – another content item- Returns:
True
, if two archives are equal- Return type:
bool
- class biosimulators_utils.combine.data_model.CombineArchiveBase[source]#
Bases:
ABC
A COMBINE/OMEX archive
- class biosimulators_utils.combine.data_model.CombineArchiveContent(location=None, format=None, master=False)[source]#
Bases:
CombineArchiveBase
A content item (e.g., file) in a COMBINE/OMEX archive
- is_equal(other)[source]#
Determine if two content items are equal
- Parameters:
other (
CombineArchiveContent
) – another content item- Returns:
True
, if two content items are equal- Return type:
bool
- class biosimulators_utils.combine.data_model.CombineArchiveContentFormat(value)[source]#
Bases:
str
,Enum
Format for the content of COMBINE/OMEX archives
- DOCX = 'http://purl.org/NET/mediatypes/application/vnd.openxmlformats-officedocument.wordprocessingml.document'[source]#
- MATHEMATICA_NOTEBOOK = 'http://purl.org/NET/mediatypes/application/vnd.wolfram.mathematica'[source]#
- PPTX = 'http://purl.org/NET/mediatypes/application/vnd.openxmlformats-officedocument.presentationml.presentation'[source]#
- XLSX = 'http://purl.org/NET/mediatypes/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'[source]#
- class biosimulators_utils.combine.data_model.CombineArchiveContentFormatPattern(value)[source]#
Bases:
str
,Enum
Format for the content of COMBINE/OMEX archives
- ADOBE_FLASH = '^https?://purl\\.org/NET/mediatypes/(application/x-shockwave-flash|application/vnd\\.adobe\\.flash-movie)$'[source]#
- DLL = '^https?://purl\\.org/NET/mediatypes/application/vnd\\.microsoft\\.portable-executable$'[source]#
- DOCX = '^https?://purl\\.org/NET/mediatypes/application/vnd\\.openxmlformats-officedocument\\.wordprocessingml\\.document$'[source]#
- EPS = '^https?://purl\\.org/NET/mediatypes/(application/postscript|application/eps|application/x-eps|image/eps|image/x-eps)$'[source]#
- GRAPHML = '^https?://purl\\.org/NET/mediatypes/(application/graphml\\+xml|application/x-graphml\\+xml)$'[source]#
- JAVASCRIPT = '^https?://purl\\.org/NET/mediatypes/(text/javascript|text/x-javascript|application/javascript|application/x-javascript)$'[source]#
- JAVA_ARCHIVE = '^https?://purl\\.org/NET/mediatypes/(application/java-archive|application/x-java-archive|application/jar|application/x-jar)$'[source]#
- JAVA_CLASS = '^https?://purl\\.org/NET/mediatypes/(application/java-vm|application/x-java-vm|application/java|application/x-java)$'[source]#
- MATHEMATICA_NOTEBOOK = '^https?://purl\\.org/NET/mediatypes/application/vnd\\.wolfram\\.mathematica$'[source]#
- OMEX_MANIFEST = '^https?://identifiers\\.org/combine\\.specifications/omex-manifest($|\\.)'[source]#
- OMEX_METADATA = '^https?://identifiers\\.org/combine\\.specifications/omex-metadata($|\\.)'[source]#
- PHP = '^https?://purl\\.org/NET/mediatypes/(application/x-httpd-php|application/x-httpd-php-source|application/x-php|text/x-php)$'[source]#
- PPTX = '^https?://purl\\.org/NET/mediatypes/application/vnd\\.openxmlformats-officedocument\\.presentationml\\.presentation$'[source]#
- PSD = '^https?://purl\\.org/NET/mediatypes/(image/vnd\\.adobe\\.photoshop|image/psd|image/x-psd|application/photoshop|application/x-photoshop|application/psd|application/x-psd)$'[source]#
- SHOCKWAVE_FLASH = '^https?://purl\\.org/NET/mediatypes/(application/x-shockwave-flash|application/vnd\\.adobe\\.flash-movie)$'[source]#
- XLSX = '^https?://purl\\.org/NET/mediatypes/application/vnd\\.openxmlformats-officedocument\\.spreadsheetml\\.sheet$'[source]#
biosimulators_utils.combine.exceptions module#
Exceptions for COMBINE/OMEX archives
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2021-01-12
- Copyright:
2021, Center for Reproducible Biomedical Modeling
- License:
MIT
- exception biosimulators_utils.combine.exceptions.CombineArchiveExecutionError[source]#
Bases:
BioSimulatorsException
Error that a SED document could not be executed
- exception biosimulators_utils.combine.exceptions.NoSedmlError[source]#
Bases:
BioSimulatorsException
Error that a COMBINE/OMEX archive does not contain any SED-ML files
biosimulators_utils.combine.exec module#
Utilities for executing tasks in SED-ML files in COMBINE/OMEX archives
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.combine.exec.exec_sedml_docs_in_archive(sed_doc_executer, archive_filename, out_dir, apply_xml_model_changes=False, sed_doc_executer_supported_features=(<class 'biosimulators_utils.sedml.data_model.Task'>, <class 'biosimulators_utils.sedml.data_model.Report'>, <class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Plot2D'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Plot3D'>, <class 'biosimulators_utils.sedml.data_model.Surface'>), sed_doc_executer_logged_features=(<class 'biosimulators_utils.sedml.data_model.Task'>, <class 'biosimulators_utils.sedml.data_model.Report'>, <class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Plot2D'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Plot3D'>, <class 'biosimulators_utils.sedml.data_model.Surface'>), log_level=StandardOutputErrorCapturerLevel.c, config=None)[source]#
Execute the SED-ML files in a COMBINE/OMEX archive (execute tasks and save outputs)
- Parameters:
sed_doc_executer (
types.FunctionType
) –function to execute each SED document in the archive. The function must implement the following interface:
def sed_doc_executer(doc, working_dir, base_out_path, rel_out_path=None, apply_xml_model_changes=False, log=None, log_level=StandardOutputErrorCapturerLevel.c, indent=0, config=None): ''' Execute the tasks specified in a SED document and generate the specified outputs Args: doc (:obj:`SedDocument` of :obj:`str`): SED document or a path to SED-ML file which defines a SED document working_dir (:obj:`str`): working directory of the SED document (path relative to which models are located) out_path (:obj:`str`): path to store the outputs * CSV: directory in which to save outputs to files ``{out_path}/{rel_out_path}/{report.id}.csv`` * HDF5: directory in which to save a single HDF5 file (``{out_path}/reports.h5``), with reports at keys ``{rel_out_path}/{report.id}`` within the HDF5 file rel_out_path (:obj:`str`, optional): path relative to :obj:`out_path` to store the outputs apply_xml_model_changes (:obj:`bool`, optional): if :obj:`True`, apply any model changes specified in the SED-ML file log (:obj:`SedDocumentLog`, optional): execution status of document log_level (:obj:`StandardOutputErrorCapturerLevel`, optional): level at which to log output indent (:obj:`int`, optional): degree to indent status messages config (:obj:`Config`, optional): BioSimulators common configuration '''
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
apply_xml_model_changes (
bool
) – ifTrue
, apply any model changes specified in the SED-ML files before callingtask_executer
.sed_doc_executer_supported_features (
list
oftype
, optional) – list of the types of elements that the SED document executer supports. Default: tasks, reports, plots, data sets, curves, and surfaces.sed_doc_executer_logged_features (
list
oftype
, optional) – list of the types fo elements which that the SED document executer logs. Default: tasks, reports, plots, data sets, curves, and surfaces.log_level (
StandardOutputErrorCapturerLevel
, optional) – level at which to log outputconfig (
Config
) – configuration
- Returns:
SedDocumentResults
: resultsCombineArchiveLog
: log
- Return type:
tuple
biosimulators_utils.combine.io module#
Utilities for reading and writing COMBINE/OMEX archives
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- class biosimulators_utils.combine.io.CombineArchiveReader[source]#
Bases:
object
Reader for COMBINE/OMEX archives
- read_manifest(filename, archive_filename=None, config=None)[source]#
Read the contents of an OMEX manifest file
- Parameters:
filename (
str
) – path to OMEX manifest filearchive_filename (
str
, option) – path to COMBINE archiveconfig (
Config
, optional) – configuration
- Returns:
contents of the OMEX manifest file
- Return type:
list
ofCombineArchiveContent
- run(in_file: str, out_dir: str, include_omex_metadata_files: bool = True, config: Config | None = None) CombineArchive [source]#
Read an archive from a file
- Parameters:
in_file (
str
) – path to archiveout_dir (
str
) – directory where the contents of the archive should be unpackedinclude_omex_metadata_files (
bool
, optional) – whether to include the OMEX metadata file as part of the contents of the archiveconfig (
Config
, optional) – configuration
- Returns:
description of archive
- Return type:
CombineArchive
- Raises:
ValueError – archive is invalid
- class biosimulators_utils.combine.io.CombineArchiveWriter[source]#
Bases:
object
Writer for COMBINE/OMEX archives
- run(archive, in_dir, out_file)[source]#
Write an archive to a file
- Parameters:
archive (
CombineArchive
) – description of archivein_dir (
str
) – directory which contains the files in the archiveout_file (
str
) – path to save archive
- Raises:
AssertionError – if files could not be added to the archive or the archive could not be saved
- class biosimulators_utils.combine.io.CombineArchiveZipReader[source]#
Bases:
object
Create a COMBINE/OMEX archive object from a plain zip archive. Set the format of files with the extension
.sedml
toCombineArchiveContentFormat.SED_ML.value
.- classmethod run(in_file, out_dir=None)[source]#
Read an archive from a zip file
- Parameters:
in_file (
str
) – path to archiveout_dir (
str
, optional) – directory where the contents of the archive should be unpacked
- Returns:
description of the archive
- Return type:
CombineArchive
- Raises:
ValueError – archive is invalid
biosimulators_utils.combine.utils module#
Utilities for working with COMBINE/OMEX archives
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.combine.utils.get_sedml_contents(archive, include_all_sed_docs_when_no_sed_doc_is_master=True, always_include_all_sed_docs=False)[source]#
Get the SED-ML files in an archive
- Parameters:
archive (
CombineArchive
) – COMBINE/OMEX archiveinclude_all_sed_docs_when_no_sed_doc_is_master (
bool
, optional) – iftrue
and no SED document hasmaster="true"
, return all SED documents.always_include_all_sed_docs (
bool
, optional) – iftrue
, return all SED documents, regardless of whether they havemaster="true"
or not.
- Returns:
SED-ML files in a COMBINE/OMEX archive
- Return type:
list
ofCombineArchiveContent
- biosimulators_utils.combine.utils.get_summary_sedml_contents(archive, archive_dir, include_all_sed_docs_when_no_sed_doc_is_master=True, always_include_all_sed_docs=False, config=None)[source]#
Get a summary of the SED-ML content in a COMBINE/OMEX archive
- Parameters:
archive (
CombineArchive
) – COMBINE/OMEX archivearchive_dir (
str
) – path where the content of the archive is locatedinclude_all_sed_docs_when_no_sed_doc_is_master (
bool
, optional) – iftrue
and no SED document hasmaster="true"
, return all SED documents.always_include_all_sed_docs (
bool
, optional) – iftrue
, return all SED documents, regardless of whether they havemaster="true"
or not.config (
Config
, optional) – whether to fail on missing includes
- Returns:
summary of the SED-ML content in a COMBINE/OMEX archive
- Return type:
str
biosimulators_utils.combine.validation module#
Methods for validating COMBINE archives
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2021-04-16
- Copyright:
2021, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.combine.validation.validate(archive: CombineArchive, archive_dirname: str, include_all_sed_docs_when_no_sed_doc_is_master: bool = True, always_include_all_sed_docs: bool = False, formats_to_validate: list[CombineArchiveContentFormat] = [CombineArchiveContentFormat.SED_ML], validate_models_with_languages: bool = True, config: Config | None = None)[source]#
Validate a COMBINE/OMEX archive and the SED-ML and model documents it contains
- Parameters:
archive (
CombineArchive
) – COMBINE/OMEX archivearchive_dirname (
str
) – directory with the content of the archiveinclude_all_sed_docs_when_no_sed_doc_is_master (
bool
, optional) – iftrue
and no SED document hasmaster="true"
, return all SED documents.always_include_all_sed_docs (
bool
, optional) – iftrue
, return all SED documents, regardless of whether they havemaster="true"
or not.formats_to_validate (
list
ofCombineArchiveContentFormat
, optional) – list for formats of files to validatevalidate_models_with_languages (
bool
, optional) – ifTrue
, validate modelsconfig (
Config
, optional) – configuration
- Returns:
nested
list
ofstr
: nested list of errors with the archivenested
list
ofstr
: nested list of warnings with the archive
- Return type:
tuple
- biosimulators_utils.combine.validation.validate_content(content, archive_dirname, formats_to_validate=[CombineArchiveContentFormat.SED_ML], validate_models_with_languages=True, config=None)[source]#
Validate an item of a COMBINE/OMEX archive
- Parameters:
content (
CombineArchiveContent
) – item of a COMBINE/OMEX archivearchive_dirname (
str
) – directory with the content of the archiveformats_to_validate (
list
ofCombineArchiveContentFormat
, optional) – list for formats of files to validatevalidate_models_with_languages (
bool
, optional) – ifTrue
, validate modelsconfig (
Config
, optional) – configuration
- Returns:
nested
list
ofstr
: nested list of errors with the archivenested
list
ofstr
: nested list of warnings with the archive
- Return type:
tuple