def test_homeostatic_singleAboveObjective(self):
        fba = FluxBalanceAnalysis(**_testTargetMolecules)

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

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

        internalMoleculeLevels = {
            "B": 15,
            "C": 10,
            "E": 20,
        }

        fba.setInternalMoleculeLevels([
            internalMoleculeLevels[moleculeID]
            for moleculeID in fba.getInternalMoleculeIDs()
        ])

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

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

            elif moleculeID == "E":
                self.assertAlmostEqual(0, change)
Ejemplo n.º 2
0
def checkErrors(targetFluxes,
                fixedReactionNames=["v_biomass"],
                reactionStoichiometry=toyModelReactionStoichWithBiomass,
                transportLimits=transportLimits):
    fba_moma = FluxBalanceAnalysis(
        reactionStoich=reactionStoichiometry,
        externalExchangedMolecules=transportLimits.keys(),
        objective=targetFluxes,
        objectiveType="moma",
        objectiveParameters={"fixedReactionNames": fixedReactionNames},
        solver="glpk",
    )
    exchangeMolecules = fba_moma.getExternalMoleculeIDs()
    fba_moma.setExternalMoleculeLevels(
        [transportLimits[molID] for molID in exchangeMolecules])
    return fba_moma.errorFluxes(), fba_moma.errorAdjustedReactionFluxes()
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)
Ejemplo n.º 5
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
Ejemplo n.º 6
0
for reactionIndex, reaction in enumerate(reactionIDs):

    # Set upper bound constraint according to transport rates
    if reaction in transportRates:
        maxReactionFluxes[reactionIndex] = transportRates[reaction]

fba.setMinReactionFluxes(reactionIDs, np.zeros(nReactions))
fba.setMaxReactionFluxes(reactionIDs, maxReactionFluxes)

# Describe external molecule levels
moleculeIDs = fba.getInternalMoleculeIDs()
nMolecules = len(moleculeIDs)

externalMoleculeLevels = np.inf * np.ones(nExternalExchangedMolecules)
fba.setExternalMoleculeLevels(externalMoleculeLevels)

# Describe internal molecule levels
moleculeCountsInit = np.zeros(nMolecules)
internalMoleculeLevels = moleculeCountsInit

# Perform simulation
nTimesteps = 15
moleculeCounts = []
moleculeCounts.append(internalMoleculeLevels)

foods = ["ATP"]
foodUnit = 2

for timestep in np.arange(nTimesteps - 1):
    deltaMolecules = runFBA(internalMoleculeLevels)
Ejemplo n.º 7
0
    "O2": 10,
    "NADH": 25,
    "ATP": 50
}
metaboliteConcentrations = [objective[x] for x in sorted(objective.keys())]

step = 1
while step <= 12:
    print "\nStep %i" % (step)
    fba = FluxBalanceAnalysis(reactions,
                              externalMolecules,
                              objective,
                              objectiveType="homeostatic",
                              solver="glpk")

    fba.setInternalMoleculeLevels(metaboliteConcentrations)
    fba.setExternalMoleculeLevels(
        [externalMolecules[x] for x in externalMolecules])
    metaboliteConcentrations += fba.getOutputMoleculeLevelsChange()

    print "Metabolite changes:\n%s" % (fba.getOutputMoleculeLevelsChange())
    print "Metabolite conc:\n%s" % (metaboliteConcentrations)
    # print "Objective value: %f" % (fba.objectiveValue())

    # consume some metabolites
    metaboliteConcentrations *= 0.5
    # consume all of ATP
    # metaboliteConcentrations[1] = 0

    step += 1