def test_cache(monkeypatch, tmp_path, bigg_models, biomodels): """Test that remote models are properly cached.""" config = Configuration() monkeypatch.setattr(config, "cache_directory", tmp_path) remote_model = load_model("e_coli_core") cached_model = load_model("e_coli_core", repositories=[bigg_models, biomodels]) bigg_models.get_sbml.assert_not_called() biomodels.get_sbml.assert_not_called() assert len(cached_model.metabolites) == len(remote_model.metabolites) assert len(cached_model.reactions) == len(remote_model.reactions)
def build_test_model(): model = load_model("e_coli_core") pH_I_T_dict = { "pH": {"c": 7.5, "e": 7, "p": 7}, "I": {"c": 0.25, "e": 0, "p": 0}, "T": {"c": 298.15, "e": 298.15, "p": 298.15}, } del_psi_dict = { "c": {"c": 0, "e": 0, "p": 150}, "e": {"c": 0, "e": 0, "p": 0}, "p": {"c": -150, "e": 0, "p": 0}, } del_psi = pd.DataFrame.from_dict(data=del_psi_dict) comp_info = pd.DataFrame.from_dict(data=pH_I_T_dict) Excl = [rxn.id for rxn in model.boundary] + [ "BIOMASS_Ecoli_core_w_GAM", "O2t", "H2Ot", ] tfa_model = tmodel( model, Exclude_list=Excl, compartment_info=comp_info, membrane_potential=del_psi ) for met in tfa_model.metabolites: kegg_id = "bigg.metabolite:" + met.id[:-2] met.Kegg_id = kegg_id tfa_model.update() return tfa_model
def test_remote_load(model_id: str, num_metabolites: int, num_reactions: int): """Test that sample models can be loaded from remote repositories (e2e).""" model = load_model(model_id, cache=False) assert len(model.metabolites) == num_metabolites assert len(model.reactions) == num_reactions
def test_unknown_model(): """Expect that a not found error is raised (e2e).""" load_model("MODELWHO?", cache=False)
def test_biomodels_access(biomodels): """Test that SBML would be retrieved from the BioModels repository.""" load_model("BIOMD0000000633", cache=False, repositories=[biomodels]) biomodels.get_sbml.assert_called_once_with(model_id="BIOMD0000000633")
def test_bigg_access(bigg_models): """Test that SBML would be retrieved from the BiGG Models repository.""" load_model("e_coli_core", cache=False, repositories=[bigg_models]) bigg_models.get_sbml.assert_called_once_with(model_id="e_coli_core")