Skip to content

Commit

Permalink
Allow export of parameters.
Browse files Browse the repository at this point in the history
MassPy seems to have a love-hate relationship with compartments, so those can't be exported, but parameters can.  No idea what actually triggers an element to be stuck in the 'boundary_conditions' list, since putting in a boundary species just puts it on the normal species concentrations list.  But if they put something there at some point, we'll be ready?  I guess?  At any rate, the new test checks for exporting a parameter and a boundary species.
  • Loading branch information
luciansmith committed Oct 30, 2024
1 parent 7196f23 commit e31ebef
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion biosimulators_masspy/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.1'
__version__ = '0.1.2'
10 changes: 9 additions & 1 deletion biosimulators_masspy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None
variable_results[variable.id] = rxn_fluxes[sbml_id][-(sim.number_of_points + 1):]
elif sbml_id[2:] in rxn_fluxes:
variable_results[variable.id] = rxn_fluxes[sbml_id[2:]][-(sim.number_of_points + 1):]
elif sbml_id in mass_model.custom_parameters:
variable_results[variable.id] = numpy.full((sim.number_of_points + 1,), mass_model.custom_parameters[sbml_id])
elif sbml_id in mass_model.boundary_conditions:
variable_results[variable.id] = numpy.full((sim.number_of_points + 1,), mass_model.boundary_conditions[sbml_id])

else:
raise_errors_warnings(validation.validate_task(task),
error_summary='Unable to find variable `{}` in output.'.format(sbml_id))
Expand Down Expand Up @@ -311,6 +316,9 @@ def preprocess_sed_task(task, variables, config=None):
for sbml_id in mass_model.boundary_conditions.keys():
sbml_id_mass_parameter_map[sbml_id] = (mass_model.boundary_conditions, sbml_id)

for sbml_id in mass_model.compartments.keys():
sbml_id_mass_parameter_map[sbml_id] = (mass_model.compartments, sbml_id)

invalid_changes = []
for target, sbml_id in model_change_target_sbml_id_map.items():
if sbml_id in met_ids:
Expand Down Expand Up @@ -349,7 +357,7 @@ def preprocess_sed_task(task, variables, config=None):
else:
sbml_id = variable_target_sbml_id_map.get(variable.target, None)

if not sbml_id or not (sbml_id in met_ids or sbml_id in rxn_ids):
if not sbml_id or not (sbml_id in met_ids or sbml_id in rxn_ids or sbml_id in sbml_id_mass_parameter_map):
invalid_targets.append(variable.target)

if invalid_symbols:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "biosimulators-masspy"
version = "0.1.1"
version = "0.1.2"
description = "BioSimulators-compliant command-line interface to the MassPY simulation program <https://masspy.readthedocs.io/>."
authors = ["Center for Reproducible Biomedical Modeling <[email protected]>"]
license = "MIT"
Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/test_core_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,5 +656,15 @@ def test_exec_sedml_docs_in_combine_archive(self):
if log.exception:
raise log.exception

def test_exec_sedml_docs_in_combine_archive_b(self):
# with reports
archive_filename = 'Cilbarto_with_param_and_boundary.omex'
archive_filename = os.path.join(os.path.dirname(__file__), 'fixtures', archive_filename)

dirname = os.path.join(self.dirname, 'reports')
_, log = core.exec_sedml_docs_in_combine_archive(str(archive_filename), dirname)
if log.exception:
raise log.exception

if __name__ == "__main__":
unittest.main()

0 comments on commit e31ebef

Please sign in to comment.