def assert_dataframes_equal(df, expected): try: assert_frame_equal(df, expected, check_names=False) return True except AssertionError: return False TESTDIR = os.path.dirname(__file__) REFERENCE_FVA_SOLUTION_ECOLI_CORE = pandas.read_csv(os.path.join(TESTDIR, 'data/REFERENCE_flux_ranges_EcoliCore.csv'), index_col=0) REFERENCE_PPP_o2_EcoliCore = pandas.read_csv(os.path.join(TESTDIR, 'data/REFERENCE_PPP_o2_EcoliCore.csv')) REFERENCE_PPP_o2_glc_EcoliCore = pandas.read_csv(os.path.join(TESTDIR, 'data/REFERENCE_PPP_o2_glc_EcoliCore.csv')) CORE_MODEL = load_model(os.path.join(TESTDIR, 'data/EcoliCore.xml'), sanitize=False) iJO_MODEL = load_model(os.path.join(TESTDIR, 'data/iJO1366.xml'), sanitize=False) iJO_MODEL_COBRAPY = load_model(os.path.join(TESTDIR, 'data/iJO1366.xml'), solver_interface=None, sanitize=False) TOY_MODEL_PAPIN_2004 = load_model(os.path.join(TESTDIR, "data/toy_model_Papin_2003.xml")) class Wrapper: class AbstractTestFindBlockedReactions(unittest.TestCase): def test_find_blocked_reactions(self): self.model.reactions.PGK.knock_out() # there are no blocked reactions in EcoliCore blocked_reactions = find_blocked_reactions(self.model) self.assertEqual(blocked_reactions, [self.model.reactions.GAPD, self.model.reactions.PGK]) class AbstractTestFluxVariabilityAnalysis(unittest.TestCase):
# try: # minho_models = index_models_minho() # except requests.ConnectionError as e: # minho.no_models_available = "Cameo couldn't reach http://darwin.di.uminho.pt/models at initialization time." \ # "Are you connected to the internet?" # logger.debug(e) # except Exception as e: # minho.no_models_available = "Cameo could reach http://darwin.di.uminho.pt/models at initialization time" \ # "but something went wrong while decoding the server response." # logger.debug(e) # else: # model_indices = minho_models.id # model_ids = minho_models.name # for index, id in zip(model_indices, model_ids): # setattr(minho, str_to_valid_variable_name(id), lazy_object_proxy.Proxy(partial(get_model_from_uminho, index))) # # validated_models = minho_models[minho_models.validated] # minho.validated = ModelDB() # model_indices = validated_models.id # model_ids = validated_models.name # for index, id in zip(model_indices, model_ids): # setattr(minho.validated, str_to_valid_variable_name(id), # lazy_object_proxy.Proxy(partial(get_model_from_uminho, index))) if __name__ == "__main__": print(index_models_minho()) from cameo.io import load_model model = load_model(get_sbml_file(2)) print(model.objective)
assert_frame_equal(df, expected, check_names=False) return True except AssertionError: return False TESTDIR = os.path.dirname(__file__) REFERENCE_FVA_SOLUTION_ECOLI_CORE = pandas.read_csv(os.path.join( TESTDIR, 'data/REFERENCE_flux_ranges_EcoliCore.csv'), index_col=0) REFERENCE_PPP_o2_EcoliCore = pandas.read_csv( os.path.join(TESTDIR, 'data/REFERENCE_PPP_o2_EcoliCore.csv')) REFERENCE_PPP_o2_glc_EcoliCore = pandas.read_csv( os.path.join(TESTDIR, 'data/REFERENCE_PPP_o2_glc_EcoliCore.csv')) CORE_MODEL = load_model(os.path.join(TESTDIR, 'data/EcoliCore.xml'), sanitize=False) iJO_MODEL = load_model(os.path.join(TESTDIR, 'data/iJO1366.xml'), sanitize=False) iJO_MODEL_COBRAPY = load_model(os.path.join(TESTDIR, 'data/iJO1366.xml'), solver_interface=None, sanitize=False) TOY_MODEL_PAPIN_2004 = load_model( os.path.join(TESTDIR, "data/toy_model_Papin_2003.xml")) class Wrapper: class AbstractTestFindBlockedReactions(unittest.TestCase): def test_find_blocked_reactions(self): self.model.reactions.PGK.knock_out(
import time from copy import copy from cameo.io import load_model from cameo.basics import flux_variability_analysis, production_envelope from cameo.methods import DifferentialFVA from cameo.config import ViewFacade from multiprocessing import Pool model = load_model('../tests/data/iJO1366.pickle') reference_model = copy(model) reference_model.reactions.get_by_id('Ec_biomass_iJO1366_core_53p95M').lower_bound = 0.9823718127270133 # t1 = time.time() # fva_solution = flux_variability_analysis(model) # t2 = time.time() # print "Execution time: %s" % (t2-t1) # t1 = time.time() # fva_solution = flux_variability_analysis(model, view=ViewFacade()) # t2 = time.time() # print "Execution time: %s" % (t2-t1) # t1 = time.time() # fva_solution = flux_variability_analysis(model, ) # t2 = time.time() # print "Execution time: %s" % (t2-t1) dFVA = DifferentialFVA(design_space_model=model, reference_model=reference_model,
# minho_models = index_models_minho() # except requests.ConnectionError as e: # minho.no_models_available = "Cameo couldn't reach http://darwin.di.uminho.pt/models at initialization time." \ # "Are you connected to the internet?" # logger.debug(e) # except Exception as e: # minho.no_models_available = "Cameo could reach http://darwin.di.uminho.pt/models at initialization time" \ # "but something went wrong while decoding the server response." # logger.debug(e) # else: # model_indices = minho_models.id # model_ids = minho_models.name # for index, id in zip(model_indices, model_ids): # setattr(minho, str_to_valid_variable_name(id), lazy_object_proxy.Proxy(partial(get_model_from_uminho, index))) # # validated_models = minho_models[minho_models.validated] # minho.validated = ModelDB() # model_indices = validated_models.id # model_ids = validated_models.name # for index, id in zip(model_indices, model_ids): # setattr(minho.validated, str_to_valid_variable_name(id), # lazy_object_proxy.Proxy(partial(get_model_from_uminho, index))) if __name__ == "__main__": print(index_models_minho()) from cameo.io import load_model model = load_model(get_sbml_file(2)) print(model.objective)