def test_metabolite_summary_to_table_previous_solution(model, opt_solver, met): """Test metabolite summary._to_table() of previous solution.""" model.solver = opt_solver solution = pfba(model) expected_entry = [ 'PRODUCING CYTBD 100 43.6 2.0 h_c + 0.5 o2_c + ' 'q8h2_c --> h2o_c + 2.0 h_' ] with captured_output() as (out, _): print(model.metabolites.get_by_id(met).summary(solution)) check_in_line(out.getvalue(), expected_entry)
def test_metabolite_summary_to_table_with_fva(model, opt_solver, fraction, met): """Test metabolite summary._to_table() (using FVA).""" # pytest.xfail("FVA currently buggy") model.solver = opt_solver model.optimize() expected_entry = [ 'PRODUCING PFK 100 7.48 6.17 9.26 ' 'atp_c + f6p_c --> adp_c + fdp_c + h_c' ] with captured_output() as (out, _): print(model.metabolites.get_by_id(met).summary(fva=fraction)) check_line(out.getvalue(), expected_entry)
def test_model_summary_to_table_previous_solution(model, opt_solver, names): """Test Summary._to_table() of previous solution.""" model.solver = opt_solver solution = model.optimize() rxn_test = model.exchanges[0] if names: met_test = list(rxn_test.metabolites.keys())[0].name else: met_test = list(rxn_test.metabolites.keys())[0].id solution.fluxes[rxn_test.id] = 321 with captured_output() as (out, _): print(model.summary(solution, names=names)) check_in_line(out.getvalue(), [met_test + '321'])
def test_reaction_summary_to_table(model, rxn, names): """Test reaction summary._to_table().""" if names: expected_entry = [ ' adhE ' 'Coenzyme A -1 c ' ] else: expected_entry = [ ' accoa_c ' '1 c ' ] with captured_output() as (out, _): print(model.reactions.get_by_id(rxn).summary(names=names)) check_in_line(out.getvalue(), expected_entry)
def test_model_summary_to_table_with_fva(model, opt_solver, fraction): """Test model summary._to_table() (using FVA).""" if opt_solver == "optlang-gurobi": pytest.xfail("FVA currently buggy") # test non-fva version (these should be fixed for textbook model) expected_entry = [ ' o2_e 21.8 19.9 23.7 h2o_e ' '29.2 25 30.7 Biomass_Ecoli_core ' '0.874 ' ] model.solver = opt_solver solution = model.optimize() with captured_output() as (out, _): print(model.summary(solution, fva=fraction)) check_in_line(out.getvalue(), expected_entry)
def test_metabolite_summary_to_table(model, opt_solver, met, names): """Test metabolite summary._to_table().""" model.solver = opt_solver model.optimize() if names: expected_entry = [ 'PRODUCING cytochrome oxidase bd ' '(ubiquinol-8: 2 protons) 100 43.6 ' '2.0 H+ + 0.5 O2 + Ubiquinol-8 --> H2O + 2.0 H+' ] else: expected_entry = [ 'PRODUCING CYTBD 100 43.6 2.0 h_c + ' '0.5 o2_c + q8h2_c --> h2o_c + 2.0 h_' ] with captured_output() as (out, _): print(model.metabolites.get_by_id(met).summary(names=names)) check_in_line(out.getvalue(), expected_entry)
def test_model_summary_to_table(model, opt_solver, names): """Test model.summary()._to_table().""" model.solver = opt_solver # test non-fva version (these should be fixed for textbook model) if names: expected_entry = [ ' O2 21.8 H2O 29.2 ' 'Biomass Objective Function with GAM 0.874 ' ] else: expected_entry = [ ' o2_e 21.8 h2o_e 29.2 ' 'Biomass_Ecoli_core 0.874 ' ] model.optimize() with captured_output() as (out, _): print(model.summary(names=names)) check_in_line(out.getvalue(), expected_entry)