From dda35bb2762ea3b14ffbcf6573d6ad86cca96008 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Tue, 29 Oct 2024 15:44:55 -0700 Subject: [PATCH] Fix tests, naming scheme. Since the sbml ids can have two forms, the index might be off. Also, fix the name of the test file. --- biosimulators_masspy/core.py | 6 +++++- tests/test_core_main.py | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/biosimulators_masspy/core.py b/biosimulators_masspy/core.py index 471344a..98f986c 100644 --- a/biosimulators_masspy/core.py +++ b/biosimulators_masspy/core.py @@ -314,7 +314,11 @@ def preprocess_sed_task(task, variables, config=None): invalid_changes = [] for target, sbml_id in model_change_target_sbml_id_map.items(): if sbml_id in met_ids: - model_change_target_mass_map[target] = (mass_model.metabolites[met_ids.index(sbml_id)], 'ic') + try: + model_change_target_mass_map[target] = (mass_model.metabolites[met_ids.index(sbml_id)], 'ic') + except: + #If the id has a "M_" in front of it: + model_change_target_mass_map[target] = (mass_model.metabolites[met_ids.index(sbml_id) - len(mass_model.metabolites)], 'ic') elif sbml_id in sbml_id_mass_parameter_map: model_change_target_mass_map[target] = sbml_id_mass_parameter_map[sbml_id] diff --git a/tests/test_core_main.py b/tests/test_core_main.py index 2e70195..2592e0b 100644 --- a/tests/test_core_main.py +++ b/tests/test_core_main.py @@ -648,10 +648,11 @@ def test_exec_sedml_docs_in_combine_archive_with_docker_image(self): def test_exec_sedml_docs_in_combine_archive(self): # with reports - archive_filename = 'fixtures/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex' + archive_filename = 'Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.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(archive_filename, dirname) + _, log = core.exec_sedml_docs_in_combine_archive(str(archive_filename), dirname) if log.exception: raise log.exception