<jupyter_start><jupyter_text>Reactions using Urea<jupyter_code>mcaps.metabolites.urea_p.reactions
mcaps.reactions.DADK.gene_reaction_rule
for rxn in mcaps.metabolites.urea_c.reactions:
    print (rxn.id, rxn.gene_reaction_rule)
mcaps.medium<jupyter_output><empty_output><jupyter_text>Results Collection<jupyter_code>df = pd.DataFrame(index=["Methane UTR","Oxygen UTR", "CO2 UTR", "NH4 UTR", "N2 UTR",
                         "NO3 UTR", "Uphill Electron Transfer Flux", "Growth Rate" ,
                         "Growth Yield", "O2/CH4 Ratio", "NH4/CH4 Ratio", "N2/CH4 Ratio",
                         "NO3/CH4 Ratio", "ATP/CH4 Ratio", "CCE"])
def df_record(solution, df, column):
    gr = solution.fluxes.BIOMASS_Mcapsulatus
    bc = carbon_in_biomass(mcaps.reactions.BIOMASS_Mcapsulatus)["C"]
    yx = gr/(abs((solution.fluxes.EX_ch4_e/1000)*16.04))
    data = [solution.fluxes.EX_ch4_e, solution.fluxes.EX_o2_e, solution.fluxes.EX_co2_e, solution.fluxes.EX_nh4_e,
            solution.fluxes.EX_n2_e, solution.fluxes.EX_no3_e, solution.fluxes.CYOR_q8ppi, gr, yx, 
            solution.fluxes.EX_o2_e/solution.fluxes.EX_ch4_e, solution.fluxes.EX_nh4_e/solution.fluxes.EX_ch4_e,
            solution.fluxes.EX_n2_e/solution.fluxes.EX_ch4_e, solution.fluxes.EX_no3_e/solution.fluxes.EX_ch4_e,
            solution.fluxes.ATPSipp/abs(solution.fluxes.EX_ch4_e), ((gr * bc)/ solution.fluxes.EX_ch4_e)*100]
    df[column] = data
    return df
mcaps.reactions.EX_n2_e.bounds = 0, 1000
mcaps.reactions.ATPSNaipp.bounds = 0, 0
mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
def carbon_in_biomass(biomass_rxn):
    total_biomass_formula = {}
    for met, stoich in biomass_rxn.metabolites.items():
        elements = {key: value*stoich for (key, value) in met.elements.items()}
        for key, value in elements.items():
            if key not in total_biomass_formula:
                total_biomass_formula[key] = value
            else:
                total_biomass_formula[key] += value
    return total_biomass_formula
def summary(model, solution):
    metabolites = {m for r in model.exchanges for m in r.metabolites}
    index = sorted(metabolites, key=attrgetter('id'))
    metabolite_fluxes = pd.DataFrame({'id': [m for m in index],'flux': zeros(len(index), dtype=float)}, index=[m.id for m in index])
    for rxn in model.exchanges:
        for met, stoich in iteritems(rxn.metabolites):
            metabolite_fluxes.at[met.id, 'flux'] += stoich * solution[rxn.id]
    print ("IN")
    print ("----------")
    for x,y in metabolite_fluxes["flux"].items():
        if round(y, 4) > 0:
            print (x,round(y, 4))
    print ("OUT")
    print ("----------")
    for x,y in metabolite_fluxes["flux"].items():
        if round(y, 4) < 0:
            print (x,round(-y, 4))
    print ("Growth Rate")
    print ("----------")
    print (solution.fluxes.BIOMASS_Mcapsulatus)<jupyter_output><empty_output><jupyter_text>Redox-Arm Only Carbon-Limited, NO3, pMMO, Redox-Arm Only<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    solution = pfba(mcaps)
    
    summary(mcaps, solution)

df = df_record(solution, df, 'NO3, pMMO, Redox-Arm Only')<jupyter_output>IN
----------
ca2_e 0.0124
ch4_e 18.46
cl_e 0.0382
cu2_e 0.0003
fe2_e 0.0011
h_e 1.4581
k_e 0.0314
mg2_e 0.022
na1_e 0.007
no3_e 1.4586
o2_e 27.8071
pi_e 0.098
so4_e 0.03
zn2_e 0.0002
OUT
----------
co2_e 12.468
h2o_e 32.9602
Growth Rate
----------
0.17804211751424018<jupyter_text>Carbon-Limited, NO3, sMMO, Redox-Arm Only<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    solution = pfba(mcaps)
    
    summary(mcaps, solution)

df = df_record(solution, df, 'NO3, sMMO, Redox-Arm Only')<jupyter_output>IN
----------
ca2_e 0.0124
ch4_e 18.46
cl_e 0.0382
cu2_e 0.0003
fe2_e 0.0011
h_e 1.4584
k_e 0.0314
mg2_e 0.022
na1_e 0.007
no3_e 1.4587
o2_e 27.807
pi_e 0.0981
so4_e 0.03
zn2_e 0.0002
OUT
----------
co2_e 12.4681
h2o_e 32.9606
Growth Rate
----------
0.17800416560102383<jupyter_text>Carbon-Limited, NH3, pMMO, Redox-Arm Only<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH3, pMMO, Redox-Arm Only')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, sMMO, Redox-Arm Only<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH3, sMMO, Redox-Arm Only')<jupyter_output><empty_output><jupyter_text>Redox-Arm Parameter Exploration<jupyter_code>mcaps.reactions.ATPSipp.metabolites<jupyter_output><empty_output><jupyter_text>NO3<jupyter_code>for r in np.arange(0,2,0.2):
    with mcaps:
        mcaps.reactions.EX_no3_e.bounds = -1000, 0
        mcaps.reactions.GLNS.bounds = 0, 1000
        mcaps.reactions.ALAD_L.bounds = 0, 1000
        mcaps.reactions.ATPSipp.add_metabolites(
            {mcaps.metabolites.adp_c: -1.0, 
             mcaps.metabolites.atp_c: 1.0,
             mcaps.metabolites.h2o_c: 1.0,
             mcaps.metabolites.h_c: (3.0-r),
             mcaps.metabolites.h_p: -(4.0-r), 
             mcaps.metabolites.pi_c: -1.0}, combine=False)
        solution = pfba(mcaps)
#         print(mcaps.reactions.ATPSipp)
#         print(solution.fluxes.ATPSipp)

    df = df_record(solution, df, 'NO3, pMMO, Redox-Arm, H/ATP {}'.format(3-r))<jupyter_output><empty_output><jupyter_text>NH4<jupyter_code>for r in np.arange(0,2,0.2):
    with mcaps:
        mcaps.reactions.EX_nh4_e.bounds = -1000, 0
        mcaps.reactions.GLNS.bounds = 0, 0
        mcaps.reactions.ALAD_L.bounds = 0, 1000
        mcaps.reactions.ATPSipp.add_metabolites(
            {mcaps.metabolites.adp_c: -1.0, 
             mcaps.metabolites.atp_c: 1.0,
             mcaps.metabolites.h2o_c: 1.0,
             mcaps.metabolites.h_c: (3.0-r),
             mcaps.metabolites.h_p: -(4.0-r), 
             mcaps.metabolites.pi_c: -1.0}, combine=False)
        solution = pfba(mcaps)
#         print(mcaps.reactions.ATPSipp)
#         print(solution.fluxes.ATPSipp)

    df = df_record(solution, df, 'NH4, pMMO, Redox-Arm, H/ATP {}'.format(3-r))<jupyter_output><empty_output><jupyter_text>Direct Coupling Exploration Carbon-Limited, NO3, pMMODC<jupyter_code>for r in np.arange(0,6.5,0.5):
    with mcaps:
        mcaps.reactions.EX_no3_e.bounds = -1000, 0
        mcaps.reactions.PMMOipp.bounds = 0, 1000
        mcaps.reactions.PMMODCipp.bounds = 0, 1000
        mcaps.reactions.GLNS.bounds = 0, 1000
        mcaps.reactions.ALAD_L.bounds = 0, 1000
        c3 = mcaps.problem.Constraint(
                mcaps.reactions.PMMOipp.flux_expression - 
                r* mcaps.reactions.PMMODCipp.flux_expression, lb=0, ub=0, name='c3')
        mcaps.add_cons_vars(c3)
        solution = pfba(mcaps)
        print(solution.fluxes.MEOHDHipp,solution.fluxes.PMMODCipp, solution.fluxes.PMMOipp)

    df = df_record(solution, df, 'NO3, pMMODC, RedEff {}'.format(r))<jupyter_output>18.46 18.46 0.0
18.46 12.306666666666667 6.153333333333333
18.46 9.23 9.23
18.46 7.384000000000001 11.076000000000002
18.460000000000008 6.153333333333337 12.306666666666674
18.459999999999567 5.274285714285593 13.185714285713983
18.460000000000264 4.615000000000066 13.845000000000198
18.460000000000036 4.102222222222232 14.35777777777781
18.460000000000093 3.692000000000018 14.768000000000072
18.459999999999983 3.3563636363636338 15.103636363636351
18.459998126449538 3.076666354408257 15.383331772041283
18.459999999999887 2.8399999999999825 15.619999999999903
18.459999999999766 2.637142857142824 15.822857142856945<jupyter_text>Carbon-Limited, NH4, pMMODC<jupyter_code>for r in np.arange(0,6.5,0.5):
    with mcaps:
        mcaps.reactions.EX_nh4_e.bounds = -1000, 0
        mcaps.reactions.PMMOipp.bounds = 0, 1000
        mcaps.reactions.PMMODCipp.bounds = 0, 1000
        mcaps.reactions.GLNS.bounds = 0, 0
        mcaps.reactions.ALAD_L.bounds = 0, 1000
        c3 = mcaps.problem.Constraint(
                mcaps.reactions.PMMOipp.flux_expression - 
                r* mcaps.reactions.PMMODCipp.flux_expression, lb=0, ub=0, name='c3')
        mcaps.add_cons_vars(c3)
        solution = pfba(mcaps)
        print(solution.fluxes.MEOHDHipp,solution.fluxes.PMMODCipp, solution.fluxes.PMMOipp)

    df = df_record(solution, df, 'NH4, pMMODC, RedEff {}'.format(r))<jupyter_output>18.46 18.46 0.0
18.46 12.306666666666667 6.153333333333333
18.46 9.23 9.23
18.46 7.384000000000001 11.076000000000002
18.46 6.153333333333333 12.306666666666667
18.46000000000013 5.274285714285752 13.185714285714381
18.459999999999994 4.614999999999998 13.844999999999995
18.459999999999944 4.102222222222212 14.357777777777741
18.459999999999923 3.6919999999999846 14.767999999999939
18.459999999999827 3.356363636363605 15.103636363636221
18.459999999999983 3.0766666666666636 15.383333333333317
18.460000000000026 2.840000000000004 15.62000000000002
18.45999999999993 2.6371428571428477 15.822857142857085<jupyter_text>Uphill ET Parameter Exploration Carbon-Limited, NO3, pMMO, Range (-5 - 0)<jupyter_code>for r in np.arange(-5,0,0.2):
    with mcaps:
        mcaps.reactions.CYOR_q8ppi.bounds = r, 1000
        mcaps.reactions.EX_no3_e.bounds = -1000, 0
        mcaps.reactions.GLNS.bounds = 0, 1000
        mcaps.reactions.ALAD_L.bounds = 0, 1000
        solution = pfba(mcaps)

    df = df_record(solution, df, 'NO3, pMMO, Uphill ET, {}'.format(r))<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, pMMO, Range (-5 - 0)<jupyter_code>for r in np.arange(-5,0,0.2):
    with mcaps:
        mcaps.reactions.CYOR_q8ppi.bounds = r, 1000
        mcaps.reactions.EX_nh4_e.bounds = -1000, 0
        mcaps.reactions.GLNS.bounds = 0, 0
        solution = pfba(mcaps)

    df = df_record(solution, df, 'NH3, pMMO, Uphill ET, {}'.format(r))<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NO3, pMMO, Uphill Unconstrained<jupyter_code>with mcaps:
    mcaps.reactions.CYOR_q8ppi.bounds = -1000, 1000
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NO3, pMMO, Uphill Unconstrained')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH4, pMMO, Uphill Unconstrained<jupyter_code>with mcaps:
    mcaps.reactions.CYOR_q8ppi.bounds = -1000, 1000
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.GLNS.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH3, pMMO, Uphill Unconstrained')
df<jupyter_output><empty_output><jupyter_text>'Turning on' the uphill electron transferUsing the value that was fit above<jupyter_code>mcaps.reactions.CYOR_q8ppi.bounds = -2.8, 1000<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NO3, sMMO<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NO3, sMMO')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NO3, pMMO<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NO3, pMMO')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, sMMO<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH3, sMMO')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, pMMO<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH3, pMMO')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, N2, sMMO<jupyter_code>with mcaps:
    mcaps.reactions.EX_n2_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0    
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'N2, sMMO')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, N2, pMMO<jupyter_code>with mcaps:
    mcaps.reactions.EX_n2_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0    
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'N2, pMMO')<jupyter_output><empty_output><jupyter_text>Direct Coupling  Carbon-Limited, NO3, pMMODC<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.PMMODCipp.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NO3, pMMODC')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, pMMODC<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.PMMODCipp.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 0
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH4, pMMODC')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, N2, pMMODC<jupyter_code>with mcaps:
    mcaps.reactions.EX_n2_e.bounds = -1000, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.PMMODCipp.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 0
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'N2, pMMODC')<jupyter_output><empty_output><jupyter_text>Effect of NH3 oxidation Carbon-Limited, NH3, pMMO, NO2<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 1000
    c3 = mcaps.problem.Constraint(
    mcaps.reactions.EX_nh4_e.flux_expression + 2* mcaps.reactions.EX_no2_e.flux_expression, lb=0, ub=0, name='c3')
    mcaps.add_cons_vars(c3)
    mcaps.reactions.GLNS.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH3, pMMO, 1/2*NO2')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, pMMO, NO2, Range(0-5)<jupyter_code>np.arange(1,4.2,0.2)
for r in np.arange(1,4.2,0.2):
    with mcaps:
        mcaps.reactions.EX_nh4_e.bounds = -1000, 0
        mcaps.reactions.EX_no3_e.bounds = 0, 0
        mcaps.reactions.PMMOipp.bounds = 0, 1000
        c3 = mcaps.problem.Constraint(
        mcaps.reactions.EX_nh4_e.flux_expression + r* mcaps.reactions.EX_no2_e.flux_expression, lb=0, ub=0, name='c3')
        mcaps.add_cons_vars(c3)
        mcaps.reactions.GLNS.bounds = 0, 0
        solution = pfba(mcaps)

    df = df_record(solution, df, 'NH3, pMMO, 1/{}*NO2'.format(r))<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NO3, pMMO, NO2<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.EX_nh4_e.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 1000
    c3 = mcaps.problem.Constraint(
    mcaps.reactions.EX_nh4_e.flux_expression + 2* mcaps.reactions.EX_no2_e.flux_expression, lb=0, ub=0, name='c3')
    mcaps.add_cons_vars(c3)
    mcaps.reactions.GLNS.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NO3, pMMO, 1/2*NO2')<jupyter_output><empty_output><jupyter_text>O2-Limited, NH3, pMMO, 0.29<jupyter_code>with mcaps:
    mcaps.objective = mcaps.reactions.EX_o2_e
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.PMMOipp.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 0
    mcaps.reactions.BIOMASS_Mcapsulatus.bounds = 0.291, 0.291
    solution = pfba(mcaps)

df = df_record(solution, df, 'O2-Limited, NH3, pMMO, 0.29')<jupyter_output><empty_output><jupyter_text>'Turning on' the fit reduced efficiency direct coupling.<jupyter_code>mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
c3 = mcaps.problem.Constraint(
                mcaps.reactions.PMMOipp.flux_expression - 
                5.5* mcaps.reactions.PMMODCipp.flux_expression, lb=0, ub=0, name='c3')
mcaps.add_cons_vars(c3)<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NO3, pMMODC RedEf<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.PMMOipp.bounds = 0, 1000
    mcaps.reactions.PMMODCipp.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NO3, pMMODC RedEf')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, pMMODC RedEf<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 1000
    mcaps.reactions.PMMODCipp.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 0
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH4, pMMODC RedEf')<jupyter_output><empty_output><jupyter_text>Carbon-Limited, NH3, pMMODC RedEf, NO2<jupyter_code>with mcaps:
    mcaps.reactions.EX_nh4_e.bounds = -1000, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 1000
    mcaps.reactions.PMMODCipp.bounds = 0, 1000
    c4 = mcaps.problem.Constraint(
    mcaps.reactions.EX_nh4_e.flux_expression + 2* mcaps.reactions.EX_no2_e.flux_expression, lb=0, ub=0, name='c4')
    mcaps.add_cons_vars(c4)
    mcaps.reactions.GLNS.bounds = 0, 0
    solution = pfba(mcaps)

df = df_record(solution, df, 'NH3, pMMODC RedEf, 1/2*NO2')
with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.EX_nh4_e.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 1000
    mcaps.reactions.PMMODCipp.bounds = 0, 1000
    c4 = mcaps.problem.Constraint(
    mcaps.reactions.EX_nh4_e.flux_expression + 2* mcaps.reactions.EX_no2_e.flux_expression, lb=0, ub=0, name='c4')
    mcaps.add_cons_vars(c4)
    mcaps.reactions.GLNS.bounds = 0, 1000
    solution = pfba(mcaps)

df = df_record(solution, df, 'NO3, pMMODC RedEf, 1/2*NO2')
df.round(2)
df.to_csv("../ComplementaryData/SupplementTable2.csv")
df[['NO3, sMMO', 'NO3, pMMO', 'NO3, pMMO, 1/2*NO2', 
    'NO3, pMMODC, RedEff 5.5', 'NO3, pMMODC RedEf, 1/2*NO2', 
     'NH3, sMMO','NH3, pMMO', 'NH3, pMMO, 1/2*NO2', 
    'NH4, pMMODC RedEf', 'NH3, pMMODC RedEf, 1/2*NO2']]<jupyter_output><empty_output><jupyter_text>The results for reduced-efficiency uphill electron transfer and reduced-efficiency direct-coupling are identical. Hence, either modes are possible at least in theory. Growth on other carbon sources<jupyter_code>def open_bounds():
    for met in mcaps.metabolites:
        if met.id not in ['na1_c', 'ca2_c', 'h_c', 'cl_c']:
            rxn_id = "TEST_" + met.id
            rxn = mcaps.add_boundary(met, reaction_id=rxn_id, type="custom", ub=1000, lb=0)
df2 = pd.DataFrame(index=["Methane UTR","Oxygen UTR", "CO2 UTR", "NH4 UTR", "N2 UTR",
                         "NO3 UTR", "Uphill Electron Transfer Flux", "Growth Rate" ,
                         "Growth Yield", "O2/CH4 Ratio", "NH4/CH4 Ratio", "N2/CH4 Ratio",
                         "NO3/CH4 Ratio", "ATP/CH4 Ratio", "CCE"])<jupyter_output><empty_output><jupyter_text>Acetate<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.SMMOi.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    mcaps.reactions.CYOR_q8ppi.bounds = -2.8, 1000
    mcaps.add_boundary(mcaps.metabolites.ac_c, lb=-1000)
    solution = pfba(mcaps)

df2 = df_record(solution, df2, 'NO3, Acetate')<jupyter_output><empty_output><jupyter_text>EtOH<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.SMMOi.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 0
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    mcaps.add_boundary(mcaps.metabolites.etoh_c, lb=-1000)
    solution = pfba(mcaps)

df2 = df_record(solution, df2, 'NO3, EtOH')<jupyter_output>/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:4 [1;31mRuntimeWarning[0m: invalid value encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:7 [1;31mRuntimeWarning[0m: divide by zero encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:7 [1;31mRuntimeWarning[0m: invalid value encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:8 [1;31mRuntimeWarning[0m: invalid value encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:9 [1;31mRuntimeWarning[0m: divide by zero encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:9 [1;31mRuntimeWarning[0m: invalid value encountered in double_scalars<jupyter_text>Formaldehyde<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 1000
    mcaps.reactions.SMMOi.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 0
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    mcaps.reactions.EX_fald_e.bounds = -1000, 1000
    solution = pfba(mcaps)

df2 = df_record(solution, df2, 'NO3, Fald')<jupyter_output>/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:4 [1;31mRuntimeWarning[0m: divide by zero encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:7 [1;31mRuntimeWarning[0m: divide by zero encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:7 [1;31mRuntimeWarning[0m: invalid value encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:8 [1;31mRuntimeWarning[0m: invalid value encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:8 [1;31mRuntimeWarning[0m: divide by zero encountered in double_scalars
/anaconda/envs/efpro2_rev/lib/python3.6/site-packages/ipykernel_launcher.py:9 [1;31mRuntimeWarning[0m: divide by zero encountered in double_scalars<jupyter_text>CO2<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 1000
    mcaps.reactions.SMMOi.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 0
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    mcaps.reactions.EX_co2_e.bounds = -1000, 1000
    solution = pfba(mcaps)
    print (solution.fluxes.BIOMASS_Mcapsulatus)

df2 = df_record(solution, df2, 'NO3, CO2')<jupyter_output><empty_output><jupyter_text>Methanol<jupyter_code>with mcaps:
    mcaps.reactions.EX_no3_e.bounds = -1000, 0
    mcaps.reactions.SMMOi.bounds = 0, 0
    mcaps.reactions.PMMOipp.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 0
    mcaps.reactions.CYOR_q8ppi.bounds = 0, 1000
    mcaps.reactions.EX_meoh_e.bounds = -1000, 1000
    solution = pfba(mcaps)
    print (solution.fluxes.BIOMASS_Mcapsulatus)
    
df2 = df_record(solution, df2, 'NO3, Methanol')
df2
# NO3 - Reference

with mcaps:
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.EX_no3_e.bounds = -10, 0
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    solution = pfba(mcaps)
    summary(mcaps, solution)
    flux_map = Builder(map_json="../MetabolicMap/MethylococcusCapsulatusMetabolismMap.json", model=model, reaction_data=solution.fluxes.to_dict())
    flux_map.display_in_notebook()
# NH4 - Reference

with mcaps:
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.EX_co2_e.bounds = 0, 1000
    mcaps.reactions.EX_nh4_e.bounds = -10, 0
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.GLNS.bounds = 0, 0
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    c4 = mcaps.problem.Constraint(
    mcaps.reactions.EX_nh4_e.flux_expression + 2* mcaps.reactions.EX_no2_e.flux_expression, lb=0, ub=0, name='c4')
    mcaps.add_cons_vars(c4)
    solution = pfba(mcaps)
    summary(mcaps, solution)
    flux_map = Builder(map_json="../MetabolicMap/MethylococcusCapsulatusMetabolismMap.json", model=model, reaction_data=solution.fluxes.to_dict())
    flux_map.display_in_notebook()
# L-Alanine 

with mcaps:
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SK_ala__L_c.bounds = -10, 0
    solution = pfba(mcaps)
    summary(mcaps, solution)
#     visualize_fluxes(mcaps, solution)
# L-Aspartic acid
with mcaps:
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.EX_asp__L_e.bounds = -10, 0
    solution = pfba(mcaps)
    
    summary(mcaps, solution)
# L-Asparagine
with mcaps:
    mcaps.reactions.SMMOi.bounds = 0, 1000
    open_bounds()
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SK_asn__L_c.bounds = -10, 0
    solution = pfba(mcaps)
    
    summary(mcaps, solution)
# L-Cysteine
with mcaps:
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    mcaps.reactions.SK_cys__L_c.bounds = -10, 0
    solution = pfba(mcaps)
    summary(mcaps, solution)
# L-Glutamic acid
with mcaps:
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    mcaps.reactions.SK_glu__L_c.bounds = -10, 0
    solution = pfba(mcaps)
    
    summary(mcaps, solution)
# L-Glutamine
with mcaps:
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    mcaps.reactions.SK_gln__L_c.bounds = -10, 0
    solution = pfba(mcaps)
    
    summary(mcaps, solution)
# L-Valine
with mcaps:
    mcaps.reactions.EX_no3_e.bounds = 0, 0
    mcaps.reactions.SMMOi.bounds = 0, 1000
    mcaps.reactions.GLNS.bounds = 0, 1000
    mcaps.reactions.ALAD_L.bounds = 0, 1000
    mcaps.reactions.SK_val__L_c.bounds = -10, 0
    solution = pfba(mcaps)
    summary(mcaps, solution)<jupyter_output>IN
----------
ca2_e 0.0303
ch4_e 18.46
cl_e 0.0928
cu2_e 0.0007
fe2_e 0.0027
k_e 0.0764
mg2_e 0.0535
na1_e 0.017
o2_e 28.6928
pi_e 0.2388
so4_e 0.0731
zn2_e 0.0004
OUT
----------
co2_e 5.5608
h2o_e 32.1789
h_e 3.2136
nh4_e 6.4511
Growth Rate
----------
0.43307768823714643
{'fraction_non_alphanumeric': 0.12683294997124783, 'fraction_numerical': 0.09915899942495687, 'mean_word_length': 3.7265160523186682, 'pattern_counts': {'":': 0, '<': 151, '<?xml version=': 0, '>': 151, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 46, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '39', 'dir': 'jupyter-structured-clean-dedup', 'id': '148133', 'license': '0BSD', 'n_tokens_mistral': 13649, 'n_tokens_neox': 11540, 'n_words': 1846, 'path': 'ComplementaryScripts/Model 15 Calculations.ipynb', 'repo_name': 'ChristianLieven/memote-m-capsulatus', 'size': '27824'}