<jupyter_start><jupyter_text>Execute a minimal model  Define the arbitrary model<jupyter_code>from cobra import Metabolite, Reaction, Model

# define metabolites
ACP_c = Metabolite(
    'ACP_c',
    formula='C11H21N2O7PRS',
    name='acyl-carrier-protein',
    compartment='c')
omrsACP_c = Metabolite(
    'M3omrsACP_c',
    formula='C25H45N2O9PRS',
    name='3-Oxotetradecanoyl-acyl-carrier-protein',
    compartment='c')
co2_c = Metabolite('co2_c', formula='CO2', name='CO2', compartment='c')
malACP_c = Metabolite(
    'malACP_c',
    formula='C14H22N2O10PRS',
    name='Malonyl-acyl-carrier-protein',
    compartment='c')
h_c = Metabolite('h_c', formula='H', name='H', compartment='c')
ddcaACP_c = Metabolite(
    'ddcaACP_c',
    formula='C23H43N2O8PRS',
    name='Dodecanoyl-ACP-n-C120ACP',
    compartment='c')

# define reactions, with the metabolites
reaction = Reaction('R_3OAS140')
reaction.name = 'R_3OAS140'
reaction.add_metabolites({
    malACP_c: -1.0,
    h_c: -1.0,
    ddcaACP_c: -1.0,
    co2_c: 1.0,
    ACP_c: 1.0,
    omrsACP_c: 1.0
})

reaction2 = Reaction('rxn2')
reaction2.add_metabolites({
    malACP_c: -1.0,
    h_c: 1.0,
    ddcaACP_c: -1.0,
    co2_c: -1.0,
    ACP_c: 1.0
})
reaction2.name = 'rxn2'

# define the model, with the reactions
model = Model('test')
model.add_reactions([reaction, reaction2])
model.objective = reaction.flux_expression

for reaction in model.reactions:
    print(reaction)<jupyter_output>R_3OAS140: ddcaACP_c + h_c + malACP_c --> ACP_c + M3omrsACP_c + co2_c
rxn2: co2_c + ddcaACP_c + malACP_c --> ACP_c + h_c<jupyter_text>Execute the arbitrary model<jupyter_code>%run ../../modelseedpy/fbapkg/dynamicfbapkg.py

# define in the initial conditions
initial_concentrations = {"Dodecanoyl-ACP-n-C120ACP":200, 'Malonyl-acyl-carrier-protein':22, 'CO2': 12, 'H': 14}

# define arbitrary enzyme kinetics and rate equations
reaction_kinetics = {
    'R_3OAS140': {
        'SubstitutedRateLaw': '(68.0*A*B)/(50.0*0.34*C+360.0*B+0.34*A+A*B*C)',
        'parameters': {
            'A': 'Dodecanoyl-ACP-n-C120ACP',
            'B': 'H',
            'C': 'malACP_c'
        }
    },
    'rxn2': {
        'SubstitutedRateLaw': '(A*B)/(50.0*0.34*C+3*B+0.34*A+C)',
        'parameters': {
            'A': 'Dodecanoyl-ACP-n-C120ACP',
            'B': 'CO2',
            'C': 'Malonyl-acyl-carrier-protein'
        }
    }
}

total_time = 5
timestep = 1
dfba = dynamicFBAPkg(model, total_time, timestep, initial_concentrations, reaction_kinetics, verbose = False)
fluxes_df, concentrations_df, solutions = dfba.simulate(source = 'custom')<jupyter_output>enzyme R_3OAS140 kinetic_flux 37.27486296006265
enzyme rxn2 kinetic_flux 4.8

objective value for timestep 1:  228.4491777603759 


enzyme R_3OAS140 kinetic_flux 36.51305870564769
enzyme rxn2 kinetic_flux 3.5350933676754672

objective value for timestep 2:  222.6134456015616 


enzyme R_3OAS140 kinetic_flux 29.612511799945977
enzyme rxn2 kinetic_flux -26.194023844380848

objective value for timestep 3:  151.48104695529503 


enzyme R_3OAS140 kinetic_flux 28.719553351552936
enzyme rxn2 kinetic_flux -109.29321791350002

objective value for timestep 4:  546.4660895675 


enzyme R_3OAS140 kinetic_flux 43.926550644105234
enzyme rxn2 kinetic_flux 30.91221396073179

objective value for timestep 5:  294.4715178253632 




Kinetically-constrained reaction fluxes
 ==================================================
                1 (min)    2 (min)    3 (min)     4 (min)    5 (min)
Enzyme names                                                        
R_3OAS140     37.274863  36.513059  29.612512 [...]<jupyter_text>Execute SABIO-RK kinetics data<jupyter_code>%run ../../modelseedpy/fbapkg/dynamicfbapkg.py
import cobra 
model = cobra.io.read_sbml_model('../iSB619.xml')

# define in the initial conditions
initial_concentrations = {"ATP":200, "ADP":100}

# import enzyme kinetics and rate equations
with open('../sabio_proccessed.json', 'rb') as f:
    reaction_kinetics = json.load(f)

# execute the package
total_time = 5
timestep = 1
dfba = dynamicFBAPkg(model, total_time, timestep, initial_concentrations, reaction_kinetics, verbose = False)
fluxes_df, concentrations_df, solutions = dfba.simulate()<jupyter_output>--> ERROR: The (E*1278.0*A)/(2.13+A) rate law is not solvable.
--> ERROR: The (E*37.0*A)/(7.0+A) rate law is not solvable.
--> ERROR: The (E*2.7*A)/(5.0+A) rate law is not solvable.
--> ERROR: The (E*23.0*A)/(3.2+A) rate law is not solvable.
--> ERROR: The (E*107.0*A)/(4.3+A) rate law is not solvable.
--> ERROR: The (E*422.0*A)/(4.5+A) rate law is not solvable.
--> ERROR: The (E*191.0*A)/(6.8+A) rate law is not solvable.
--> ERROR: The (E*92.0*A)/(7.3+A) rate law is not solvable.
--> ERROR: The (E*414.0*A)/(3.7+A) rate law is not solvable.
--> ERROR: The (E*143.0*A)/(5.8+A) rate law is not solvable.
--> ERROR: The (E*425.0*A)/(3.62+A) rate law is not solvable.
--> ERROR: The (E*0.59*A)/(3.1+A) rate law is not solvable.
--> ERROR: The (E*0.39*A)/(5.2+A) rate law is not solvable.
--> ERROR: The (E*1.46*A)/(5.0+A) rate law is not solvable.
--> ERROR: The (E*1125.0*A)/(3.0+A) rate law is not solvable.
--> ERROR: The (E*11.4*A)/(7.7+A) rate law is not solvable.
--> ERROR: The (E*1056.0*B)/([...]<jupyter_text>Execute custom kinetics data<jupyter_code>%run ../../modelseedpy/fbapkg/dynamicfbapkg.py
import cobra 
model = cobra.io.read_sbml_model('../iSB619.xml')

# define in the initial conditions
initial_concentrations = {"ADP":200, 'Acetate':22, "Acetyl phosphate":100, 'Phosphoenolpyruvate':54}

# define arbitrary enzyme kinetics and rate equations
reaction_kinetics = {
    'acetate kinase': {
        'SubstitutedRateLaw': '(68.0*A*B)/(50.0*0.34+360.0*B+0.34*A+A*B)',
        'parameters': {
            'A': 'ADP',
            'B': 'Acetyl phosphate'
        }
    },
    'alkaline phosphatase': {
        'SubstitutedRateLaw': '0.0113*S/(1.0E-5+S)',
        'parameters': {
            'S': 'Phosphoenolpyruvate'
        }
    }
}

# execute the package
total_time = 5
timestep = 1
dfba = dynamicFBAPkg(model, total_time, timestep, initial_concentrations, reaction_kinetics, verbose = False)
fluxes_df, concentrations_df, solutions = dfba.simulate(source = 'custom')<jupyter_output>enzyme Alkaline phosphatase kinetic_flux 0.011299997907407794
enzyme Acetate kinase kinetic_flux 24.248907907640188

objective value for timestep 1:  0.1580502916027904 


enzyme Alkaline phosphatase kinetic_flux 0.011300000121766204
enzyme Acetate kinase kinetic_flux 0.0

objective value for timestep 2:  0.15805029160279352 


enzyme Alkaline phosphatase kinetic_flux 0.011300000121766202
enzyme Acetate kinase kinetic_flux 0.0

objective value for timestep 3:  0.15805029160279352 


enzyme Alkaline phosphatase kinetic_flux 0.011300000121766202
enzyme Acetate kinase kinetic_flux 0.0

objective value for timestep 4:  0.15805029160279352 


enzyme Alkaline phosphatase kinetic_flux 0.011300000121766202
enzyme Acetate kinase kinetic_flux 0.0

objective value for timestep 5:  0.15805029160279352 




Kinetically-constrained reaction fluxes
 ==================================================
                        1 (min) 2 (min) 3 (min) 4 (min) 5 (min)
Enzyme names                          [...]
{'fraction_non_alphanumeric': 0.14653383146533833, 'fraction_numerical': 0.10945067109450671, 'mean_word_length': 3.7087947882736154, 'pattern_counts': {'":': 5, '<': 13, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '533563', 'license': 'MIT', 'n_tokens_mistral': 3432, 'n_tokens_neox': 2727, 'n_words': 602, 'path': 'examples/Flux Analysis/DynamicFBA.ipynb', 'repo_name': 'freiburgermsu/ModelSEEDpy', 'size': '7227'}