def test_standard_noInput(self):
        fba = FluxBalanceAnalysis(**_testStandard)

        self.assertEqual(fba.getBiomassReactionFlux(), 0)

        for moleculeID, change in zip(fba.getOutputMoleculeIDs(),
                                      fba.getOutputMoleculeLevelsChange()):
            if moleculeID == "B":
                self.assertAlmostEqual(0, change)

            elif moleculeID == "C":
                self.assertAlmostEqual(0, change)

            elif moleculeID == "E":
                self.assertAlmostEqual(0, change)
def testModel(toyModelReactionStoich=toyModelReactionStoich, biomassReactionStoich=biomassReactionStoich, transportLimits=transportLimits, reactionEnzymes=reactionEnzymes, enzymeConcentrations=enzymeConcentrations):
	fba = FluxBalanceAnalysis(
		reactionStoich=toyModelReactionStoich,
		externalExchangedMolecules=transportLimits.keys(),
		objective=biomassReactionStoich["v_biomass"],
		objectiveType="standard",
		solver="glpk",
	)
	exchangeMolecules = fba.getExternalMoleculeIDs()
	fba.setExternalMoleculeLevels([transportLimits[molID] for molID in exchangeMolecules])

	for reactionID in toyModelReactionStoich:
		if reactionID in reactionEnzymes:
			enzymeID = reactionEnzymes[reactionID]
			if enzymeID in enzymeConcentrations:
				fba.setMaxReactionFlux(reactionID, KCAT_MAX * enzymeConcentrations[enzymeID])

	return fba.getBiomassReactionFlux()[0]
    def test_standard(self):
        fba = FluxBalanceAnalysis(**_testStandard)

        externalMoleculeLevels = {"A": 50, "D": 20}

        fba.setExternalMoleculeLevels([
            externalMoleculeLevels[moleculeID]
            for moleculeID in fba.getExternalMoleculeIDs()
        ])

        self.assertEqual(fba.getBiomassReactionFlux(), 1.0)

        for moleculeID, change in zip(fba.getOutputMoleculeIDs(),
                                      fba.getOutputMoleculeLevelsChange()):
            if moleculeID == "B":
                self.assertAlmostEqual(10, change)

            elif moleculeID == "C":
                self.assertAlmostEqual(10, change)

            elif moleculeID == "E":
                self.assertAlmostEqual(20, change)
Exemple #4
0
        "ATP": 1
    },
}

biomassReactionStoich = {"v_biomass": {"C": 1, "F": 1, "H": 1, "ATP": 10}}

transportLimits = {
    "A": 21.0,
    "F": 5.0,
    "D": -12.0,
    "E": -12.0,
    "H": 5.0,
    "O2": 15.0,
}

fba = FluxBalanceAnalysis(
    reactionStoich=toyModelReactionStoich,
    externalExchangedMolecules=transportLimits.keys(),
    objective=biomassReactionStoich["v_biomass"],
    objectiveType="standard",
    solver="glpk",
)

exchangeMolecules = fba.getExternalMoleculeIDs()

fba.setExternalMoleculeLevels(
    [transportLimits[molID] for molID in exchangeMolecules])

biomassReactionFlux = fba.getBiomassReactionFlux()[0]

print biomassReactionFlux
Exemple #5
0
    fba_moma.setExternalMoleculeLevels(
        [transportLimits[molID] for molID in exchangeMolecules])
    return fba_moma.errorFluxes(), fba_moma.errorAdjustedReactionFluxes()


fba = FluxBalanceAnalysis(
    reactionStoich=toyModelReactionStoich,
    externalExchangedMolecules=transportLimits.keys(),
    objective=biomassReactionStoich["v_biomass"],
    objectiveType="standard",
    solver="glpk",
)
exchangeMolecules = fba.getExternalMoleculeIDs()
fba.setExternalMoleculeLevels(
    [transportLimits[molID] for molID in exchangeMolecules])
wildtypeBiomassFlux = fba.getBiomassReactionFlux()

# Adjust kcats
targetFluxes = {}
for reactionID, enzymeID in reactionEnzymes.iteritems():
    targetFluxes[
        reactionID] = enzymeConcentrations[enzymeID] * enzymeKcats[enzymeID]
targetFluxes["v_biomass"] = wildtypeBiomassFlux

errors, rates = checkErrors(targetFluxes)

errors_dict = dict(zip(enzymeKcats, errors))

kcat_adjustments = {
    enzymeID: error / enzymeConcentrations[enzymeID]
    for enzymeID, error in errors_dict.iteritems()