diff --git a/biosimulators_masspy/core.py b/biosimulators_masspy/core.py index fe1af79..8b972a0 100644 --- a/biosimulators_masspy/core.py +++ b/biosimulators_masspy/core.py @@ -198,14 +198,21 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None else: sbml_id = variable_target_sbml_id_map[variable.target] - if sbml_id.startswith('M_'): - if sbml_id[2:] in met_concs: - variable_results[variable.id] = met_concs[sbml_id[2:]][-(sim.number_of_points + 1):] - else: - variable_results[variable.id] = numpy.full((sim.number_of_points + 1,), met_ics[sbml_id[2:]]) - - else: + if sbml_id in met_concs: + variable_results[variable.id] = met_concs[sbml_id][-(sim.number_of_points + 1):] + elif sbml_id[2:] in met_concs: + variable_results[variable.id] = met_concs[sbml_id[2:]][-(sim.number_of_points + 1):] + elif sbml_id in met_ics: + variable_results[variable.id] = numpy.full((sim.number_of_points + 1,), met_ics[sbml_id]) + elif sbml_id[2:] in met_ics: + variable_results[variable.id] = numpy.full((sim.number_of_points + 1,), met_ics[sbml_id[2:]]) + elif sbml_id in rxn_fluxes: + 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):] + else: + raise_errors_warnings(validation.validate_task(task), + error_summary='Unable to find variable `{}` in output.'.format(sbml_id)) # log action if config.LOG: @@ -272,8 +279,10 @@ def preprocess_sed_task(task, variables, config=None): doc.setLevelAndVersion(3, 1) sbml = libsbml.writeSBMLToString(doc) mass_model = mass.io.sbml.read_sbml_model(sbml) - met_ids = ['M_' + mass_met.id for mass_met in mass_model.metabolites] - rxn_ids = ['R_' + mass_rxn.id for mass_rxn in mass_model.reactions] + met_ids = [mass_met.id for mass_met in mass_model.metabolites] + met_ids = met_ids + ['M_' + mass_met.id for mass_met in mass_model.metabolites] + rxn_ids = [mass_rxn.id for mass_rxn in mass_model.reactions] + rxn_ids = rxn_ids + ['R_' + mass_rxn.id for mass_rxn in mass_model.reactions] # validate model changes model_change_target_mass_map = {} @@ -352,11 +361,9 @@ def preprocess_sed_task(task, variables, config=None): raise NotImplementedError(msg) if invalid_targets: - valid_targets = [] - for mass_met in mass_model.metabolites: - valid_targets.append("/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='M_{}']".format(mass_met.id)) - for mass_rxn in mass_model.reactions: - valid_targets.append("/sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id='R_{}']".format(mass_rxn.id)) + valid_targets = met_ids + valid_targets += rxn_ids + valid_targets += list(custom_parameters.keys()) msg = ( 'The following targets are not supported:\n - {}' diff --git a/tests/fixtures/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex b/tests/fixtures/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex new file mode 100644 index 0000000..365e83b Binary files /dev/null and b/tests/fixtures/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex differ diff --git a/tests/test_core_main.py b/tests/test_core_main.py index 9d3d42d..2e70195 100644 --- a/tests/test_core_main.py +++ b/tests/test_core_main.py @@ -645,3 +645,15 @@ def test_exec_sedml_docs_in_combine_archive_with_docker_image(self): archive_filename, out_dir, docker_image, environment=env, pull_docker_image=False) self._assert_combine_archive_outputs(doc, out_dir) + + def test_exec_sedml_docs_in_combine_archive(self): + # with reports + archive_filename = 'fixtures/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex' + + dirname = os.path.join(self.dirname, 'reports') + _, log = core.exec_sedml_docs_in_combine_archive(archive_filename, dirname) + if log.exception: + raise log.exception + +if __name__ == "__main__": + unittest.main()