Skip to content

Commit

Permalink
feat: updated to BioSimulators-utils 0.1.104
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Aug 17, 2021
1 parent fb584fc commit 97e7aa6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
9 changes: 8 additions & 1 deletion biosimulators_cobrapy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from ._version import __version__ # noqa: F401
# :obj:`str`: version

from .core import exec_sedml_docs_in_combine_archive # noqa: F401
from .core import exec_sed_task, exec_sedml_docs_in_combine_archive # noqa: F401

import cobra

__all__ = [
'__version__',
'get_simulator_version',
'exec_sed_task',
'exec_sedml_docs_in_combine_archive',
]


def get_simulator_version():
""" Get the version of COBRApy
Expand Down
34 changes: 24 additions & 10 deletions biosimulators_cobrapy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
from .utils import (get_active_objective_sbml_fbc_id, set_simulation_method_arg,
apply_variables_to_simulation_method_args, validate_variables, get_results_of_variables)
from biosimulators_utils.combine.exec import exec_sedml_docs_in_archive
from biosimulators_utils.config import get_config
from biosimulators_utils.log.data_model import CombineArchiveLog, TaskLog # noqa: F401
from biosimulators_utils.viz.data_model import VizFormat # noqa: F401
from biosimulators_utils.report.data_model import ReportFormat, VariableResults # noqa: F401
from biosimulators_utils.report.data_model import ReportFormat, VariableResults, SedDocumentResults # noqa: F401
from biosimulators_utils.sedml.data_model import (Task, ModelLanguage, SteadyStateSimulation, # noqa: F401
Variable)
from biosimulators_utils.sedml import validation
Expand All @@ -34,8 +35,10 @@


def exec_sedml_docs_in_combine_archive(archive_filename, out_dir,
return_results=False,
report_formats=None, plot_formats=None,
bundle_outputs=None, keep_individual_outputs=None):
bundle_outputs=None, keep_individual_outputs=None,
raise_exceptions=True):
""" Execute the SED tasks defined in a COMBINE/OMEX archive and save the outputs
Args:
Expand All @@ -47,21 +50,28 @@ def exec_sedml_docs_in_combine_archive(archive_filename, out_dir,
* 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
return_results (:obj:`bool`, optional): whether to return the result of each output of each SED-ML file
report_formats (:obj:`list` of :obj:`ReportFormat`, optional): report format (e.g., csv or h5)
plot_formats (:obj:`list` of :obj:`VizFormat`, optional): report format (e.g., pdf)
bundle_outputs (:obj:`bool`, optional): if :obj:`True`, bundle outputs into archives for reports and plots
keep_individual_outputs (:obj:`bool`, optional): if :obj:`True`, keep individual output files
raise_exceptions (:obj:`bool`, optional): whether to raise exceptions
Returns:
:obj:`CombineArchiveLog`: log
:obj:`tuple`:
* :obj:`SedDocumentResults`: results
* :obj:`CombineArchiveLog`: log
"""
sed_doc_executer = functools.partial(exec_sed_doc, exec_sed_task)
return exec_sedml_docs_in_archive(sed_doc_executer, archive_filename, out_dir,
apply_xml_model_changes=True,
return_results=return_results,
report_formats=report_formats,
plot_formats=plot_formats,
bundle_outputs=bundle_outputs,
keep_individual_outputs=keep_individual_outputs)
keep_individual_outputs=keep_individual_outputs,
raise_exceptions=raise_exceptions)


def exec_sed_task(task, variables, log=None):
Expand All @@ -83,17 +93,21 @@ def exec_sed_task(task, variables, log=None):
could not be recorded
:obj:`NotImplementedError`: if the task is not of a supported type or involves an unsuported feature
'''
config = get_config()

log = log or TaskLog()

model = task.model
sim = task.simulation

raise_errors_warnings(validation.validate_model_language(task.model.language, ModelLanguage.SBML),
error_summary='Language for model `{}` is not supported.'.format(model.id))
raise_errors_warnings(validation.validate_model_change_types(task.model.changes, ()),
error_summary='Changes for model `{}` are not supported.'.format(model.id))
raise_errors_warnings(validation.validate_simulation_type(task.simulation, (SteadyStateSimulation, )),
error_summary='{} `{}` is not supported.'.format(sim.__class__.__name__, sim.id))
if config.VALIDATE_SEDML:
raise_errors_warnings(validation.validate_model_language(task.model.language, ModelLanguage.SBML),
error_summary='Language for model `{}` is not supported.'.format(model.id))
raise_errors_warnings(validation.validate_model_change_types(task.model.changes, ()),
error_summary='Changes for model `{}` are not supported.'.format(model.id))
raise_errors_warnings(validation.validate_simulation_type(task.simulation, (SteadyStateSimulation, )),
error_summary='{} `{}` is not supported.'.format(sim.__class__.__name__, sim.id))

target_x_paths_ids = validation.validate_variable_xpaths(
variables, task.model.source, attr='id')
namespaces = get_namespaces_for_xml_doc(etree.parse(task.model.source))
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
biosimulators_utils[logging] >= 0.1.96
biosimulators_utils[logging] >= 0.1.104
cobra
kisao
lxml
Expand Down

0 comments on commit 97e7aa6

Please sign in to comment.