def test_run_fba_cobra(self): print('\n\nThis test fails under Linux.\n\n') cmod = cbmpy.readCOBRASBML('L2CBR_iJR904.glc.xml', work_dir=MDIR,\ output_dir=self.CDIR, delete_intermediate=True) cmod2 = cbmpy.readSBML3FBC('L3FBCV1_iJR904.glc.xml', work_dir=MDIR, xoptions={'validate': True}) fba1 = cbmpy.doFBA(cmod) fba2 = cbmpy.doFBA(cmod2) del cmod, cmod2 assert_almost_equal(fba1, fba2)
f.replace('.correct.xml', '.noinf_r.columns.txt')), 'r') for l in F: L = l.split(',') print(L) if len(L) == 2: idmap[L[1].strip()] = int(L[0]) + 1 F.close() print(idmap) if sbml_level == 3: print('Trying level 3') submod = CBRead.readSBML3FBC(f, work_dir=sbml_dir) else: submod = CBRead.readSBML2FBA(f, work_dir=sbml_dir) if submod is not None: cbmpy.doFBA(submod) a, b = cbmpy.doFVA(submod) output = {} for r in submod.reactions: span = abs(r.fva_max - r.fva_min) rtype = 'VARIABLE' if span < 1e-10: rtype = 'FIXED' if numpy.isinf( float(r.fva_max) ): #EvP changed because of numpy.inf is not rational fva_max = float(999999) else: fva_max = r.fva_max S = 'x{} : {} : {} -- {}'.format(idmap[r.getId()], r.fva_min, fva_max, rtype)
import os, time, numpy cDir = os.path.dirname(os.path.abspath(os.sys.argv[0])) import cbmpy as cbm model_name = 'iAF692.xml' cmod = cbm.readSBML3FBC(os.path.join(cDir, 'models', model_name)) cmodS = cmod.clone() cbm.doFBA(cmod) fva, fvan = cbm.CBMultiCore.runMultiCoreFVA(cmod, procs=4) cbm.CBWrite.writeFVAtoCSV(fva, fvan, model_name.replace('.xml', ''), fbaObj=cmod) cbm.writeModelToExcel97(cmod, model_name.replace('.xml', '')) exch_reactions = cmod.getReactionIds('R_EX_') dump = [] # reactions are defined back to front so fwd is "o" and and backward is "i" for xr_ in exch_reactions: dump.append(cbm.CBTools.splitSingleReversibleReaction(cmodS, xr_, xr_.replace('R_EX_', 'R_EXo_'),\ xr_.replace('R_EX_', 'R_EXi_'))) cbm.doFBA(cmodS) fva, fvan = cbm.CBMultiCore.runMultiCoreFVA(cmodS, procs=4) cbm.CBWrite.writeFVAtoCSV(fva, fvan, model_name.replace('.xml', '.split'), fbaObj=cmodS) cbm.writeSBML3FBC(cmodS, model_name.replace('.xml', '.split.xml')) cbm.CBWrite.writeModelToExcel97(cmodS, model_name.replace('.xml', '.split'))
print '\nconstraintFiles' print constraintFiles # ok now lets set up our model # let's set up the base model # 20130628 fixed Mac unicode insanity sbmlF = str(os.path.join(cDir, 'models', modelFile)) if USE_SBML3: cmodBase = cbm.CBRead.readSBML3FBC(sbmlF) else: cmodBase = cbm.CBRead.readSBML2FBA(sbmlF) # cbm.CBTools.processSBMLAnnotationNotes(cmodBase, annotation_key='note') cbm.doFBA(cmodBase) # here we define a function that will read the constraint files def readBounds(filename, delimiter=','): """ Give the name of a bounds file and it returns a list of tuples: (Rid,lb,ub) """ F = file(filename, 'r') bounds = [] for L in F: l = L.split(delimiter) #print l if l[0].strip().replace('"', '') == 'Reaction ID': pass
def test_run_L3FBCV2_iJR904(self): m = 'L3FBCV2_iJR904.glc.xml' cmod = self.m[m].clone() res = cbmpy.doFBA(cmod) del cmod assert_almost_equal(DATA[m]['FBA'], res)
def test_run_BIGG2_iAF1260(self): m = 'BIGG2_iAF1260.xml' cmod = self.m[m].clone() res = cbmpy.doFBA(cmod) del cmod assert_almost_equal(DATA[m]['FBA'], res)
def main(): model = cbm.CBRead.readSBML3FBC('models/Y7.xml') vmod = Vmod('metabolic_maps/Yeast_7.svg', model) cbm.doFBA(model) cbm.doFBAMinSum(model) vmod.mapFBA(absminval=1e-5, out_file='metabolic_maps/Y7_fba_default.svg') model.setReactionLowerBound('r_0659', 0.0) cbm.doFBA(model) cbm.doFBAMinSum(model) vmod.mapFBA(absminval=1e-5, out_file='metabolic_maps/Y7_fba_irreversible_IDH.svg') FVA = cbm.doFVA(model) vmod.mapFVA(FVA, absminval=1e-5, minspan=1e-5, out_file='metabolic_maps/Y7_fva.svg') gene_ids = ['YER081W', 'YIL074C', 'YKL141W'] for gene_id in gene_ids: model.setGeneInactive(gene_id) model.updateNetwork() cbm.doFBA(model) cbm.doFBAMinSum(model) vmod.mapFBA(absminval=1e-5, out_file='metabolic_maps/Y7_fba_Otero_2013_succinate.svg') # delft stratagy model = cbm.CBRead.readSBML3FBC('models/Y7.xml') vmod = Vmod('metabolic_maps/Yeast_7.svg', model) model.createObjectiveFunction('r_2056') cbm.doFBA(model) cbm.doFBAMinSum(model) vmod.mapFBA(absminval=1e-5, out_file='metabolic_maps/Y7_fba_succinate_obj_default.svg') vmod = Vmod('metabolic_maps/Yeast_7delft.svg', model) model.setReactionLowerBound('r_0659', 0) model.setReactionBounds('r_0959', 0, 0) # knock out pyruvate decarboxylase model.createReaction('r_FRDc', name='cytosolic fumarate reductase') model.createReactionReagent('r_FRDc', 's_0725', -1) # fumarate model.createReactionReagent('r_FRDc', 's_1203', -1) # NADH model.createReactionReagent('r_FRDc', 's_1458', 1) # succinate model.createReactionReagent('r_FRDc', 's_1198', 1) # NAD model.createReaction('r_PDHc', name='bacterial PDH') model.createReactionReagent('r_PDHc', 's_1399', -1) # pyruvate model.createReactionReagent('r_PDHc', 's_1198', -1) # NAD model.createReactionReagent('r_PDHc', 's_0529', -1) # CoA model.createReactionReagent('r_PDHc', 's_0373', 1) # Acetyl-CoA model.createReactionReagent('r_PDHc', 's_1203', 1) # NADH model.createReactionReagent('r_PDHc', 's_0456', 1) # CO2 model.setReactionLowerBound('r_PDHc', 0) vmod.mapFBA(absminval=1e-5, out_file='metabolic_maps/Y7_fba_succinate_obj_delft.svg') FVA = cbm.doFVA(model) vmod.mapFVA(FVA, absminval=1e-5, minspan=1e-5, out_file='metabolic_maps/Y7_fva_succinate_obj_delft.svg.svg')