Skip to content

Commit

Permalink
Merge pull request #213 from CovertLab/metabolism-redux
Browse files Browse the repository at this point in the history
Test for division with new metabolism
  • Loading branch information
cyrus-bio authored Oct 2, 2023
2 parents 26c8eca + 48bc9c6 commit add65c9
Show file tree
Hide file tree
Showing 9 changed files with 10,392 additions and 3,114 deletions.
1 change: 1 addition & 0 deletions data/met_division_test_state.json

Large diffs are not rendered by default.

73 changes: 26 additions & 47 deletions ecoli/experiments/metabolism_redux_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,18 @@ def run_ecoli_with_metabolism_redux(
folder = f'out/fbagd/{name}_{total_time}_{datetime.date.today()}/'
# save_sim_output(folder, query, sim, save_model=True)


# disables growth rate control
def run_ecoli_with_metabolism_redux_classic(
filename='metabolism_redux_classic',
total_time=4,
total_time=10,
divide=True,
initial_state_file='wcecoli_t0',
initial_state_file='met_division_test_state',
progress_bar=True,
log_updates=False,
emitter='timeseries',
name='metabolism-redux-classic',
raw_output=False,
save=False,
# save_times=4,
save=True,
):
# filename = 'default'
sim = EcoliSim.from_file(CONFIG_DIR_PATH + filename + '.json')
Expand All @@ -74,7 +73,9 @@ def run_ecoli_with_metabolism_redux_classic(
sim.initial_state = get_state_from_file(path=f'data/{initial_state_file}.json')
sim.raw_output = raw_output
sim.save = save
# sim.save_times = [4]
sim.save_times = [10]
sim.initial_state = get_state_from_file(path=f'data/{initial_state_file}.json')


# # simplify working with uptake
# sim.initial_state['environment']['exchange_data']['constrained'] = {}
Expand All @@ -84,13 +85,19 @@ def run_ecoli_with_metabolism_redux_classic(
# sim.initial_state['environment']['exchange_data']['unconstrained'].remove('GLC[p]')
# sim.initial_state['environment']['exchange_data']['unconstrained'].add('FRU[p]')

# this means that sims will not create conflicting random indices
if initial_state_file == 'wcecoli_t0':
sim.seed += 1
else:
sim.seed += int(sim.initial_state['agents']['0']['global_time'])

sim.build_ecoli()

sim.run()

query = []
folder = f'out/fbagd/{name}_{total_time}_{datetime.date.today()}/'
# save_sim_output(folder, query, sim, save_model=True)
save_sim_output(folder, query, sim, save_model=True)


@pytest.mark.slow
Expand All @@ -113,13 +120,6 @@ def test_ecoli_with_metabolism_redux(
# run simulation and add asserts to output
sim.run()

# assert 'ecoli-metabolism-gradient-descent' in sim.ecoli['processes']
# assert 'ecoli-metabolism' not in sim.ecoli['processes']
# assert 'ecoli-metabolism-gradient-descent' in sim.ecoli['topology']
# assert 'ecoli-metabolism' not in sim.ecoli['topology']



@pytest.mark.slow
def test_ecoli_with_metabolism_redux_div(
filename='metabolism_redux',
Expand All @@ -135,12 +135,7 @@ def test_ecoli_with_metabolism_redux_div(
sim.build_ecoli()

sim.run()

# # assert that the processes were swapped
# assert 'ecoli-metabolism-gradient-descent' in sim.processes
# assert 'ecoli-metabolism' not in sim.processes
# assert 'ecoli-metabolism-gradient-descent' in sim.processes
# assert 'ecoli-metabolism' not in sim.processes


query = []
agents = sim.query()['agents'].keys()
Expand Down Expand Up @@ -174,44 +169,32 @@ def test_ecoli_with_metabolism_classic(
# run simulation and add asserts to output
sim.run()

# assert 'ecoli-metabolism-gradient-descent' in sim.ecoli['processes']
# assert 'ecoli-metabolism' not in sim.ecoli['processes']
# assert 'ecoli-metabolism-gradient-descent' in sim.ecoli['topology']
# assert 'ecoli-metabolism' not in sim.ecoli['topology']


@pytest.mark.slow
def test_ecoli_with_metabolism_classic_div(
filename='metabolism_redux_classic',
total_time=4,
total_time=10,
divide=True,
emitter='timeseries',
initial_state_file='met_division_test_state',
):
# TODO (Cyrus) - Add test that affirms structure of output query.
sim = EcoliSim.from_file(CONFIG_DIR_PATH + filename + '.json')
sim.total_time = total_time
sim.initial_state = get_state_from_file(path=f'data/{initial_state_file}.json')

sim.divide = divide
sim.emitter = emitter
sim.build_ecoli()

sim.run()
# this means that sims will not create conflicting random indices
sim.seed += int(sim.initial_state['agents']['0']['global_time'])

# # assert that the processes were swapped
# assert 'ecoli-metabolism-gradient-descent' in sim.processes
# assert 'ecoli-metabolism' not in sim.processes
# assert 'ecoli-metabolism-gradient-descent' in sim.processes
# assert 'ecoli-metabolism' not in sim.processes
sim.build_ecoli()

query = []
agents = sim.query()['agents'].keys()
for agent in agents:
query.extend([('agents', agent, 'listeners', 'fba_results'),
('agents', agent, 'listeners', 'mass'),
('agents', agent, 'bulk')])
output = sim.query(query)
sim.run()

# test that water is being used (model is running)
assert sum(output['agents'][agent]['listeners']['fba_results']['estimated_exchange_dmdt']['WATER[p]']) != 0
# assert division occured
assert len(sim.query()['agents']) == 3, "Cell did not divide in metabolism division test"

def run_ecoli_with_default_metabolism(
filename='default',
Expand Down Expand Up @@ -263,12 +246,8 @@ def save_sim_output(folder, query, sim, save_model=False):
np.save(folder + 'output.npy', output)

if save_model:
f = open(folder + 'agent_processes.pkl', 'wb')
dill.dump(sim.ecoli['processes']['agents'][agent], f)
f.close()

f = open(folder + 'agent_steps.pkl', 'wb')
dill.dump(sim.ecoli['steps']['agents'][agent], f)
dill.dump(sim.ecoli_experiment.steps['agents'][agent], f)
f.close()

# run experiments with command line arguments: python ecoli/experiments/metabolism_redux_sim.py -n exp_id
Expand Down
119 changes: 57 additions & 62 deletions notebooks/cofactors/cofactors_data_fetching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 1,
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2023-08-21T18:24:08.559258Z",
"start_time": "2023-08-21T18:24:08.552787Z"
"end_time": "2023-09-11T19:41:20.221995Z",
"start_time": "2023-09-11T19:41:20.177783Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -63,28 +63,28 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 2,
"outputs": [],
"source": [
"password = input(\"Enter Password: \")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-08-21T18:24:12.063486Z",
"start_time": "2023-08-21T18:24:09.730893Z"
"end_time": "2023-09-11T19:41:25.918221Z",
"start_time": "2023-09-11T19:41:20.222781Z"
}
}
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 3,
"outputs": [
{
"data": {
"text/plain": "<Response [200]>"
},
"execution_count": 28,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -97,8 +97,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-08-21T18:24:14.506907Z",
"start_time": "2023-08-21T18:24:14.213162Z"
"end_time": "2023-09-11T19:41:29.034510Z",
"start_time": "2023-09-11T19:41:28.670370Z"
}
}
},
Expand All @@ -113,7 +113,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 5,
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -354,40 +354,37 @@
" 'suggests that the complex contains only one '\n",
" 'binding site located in subunit I (CyoB) '\n",
" '[<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/7961841\">Welter, '\n",
" '1994</a>; <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/11017202\">Abramson, '\n",
" '2000</a>; <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/20416270\">Yap, '\n",
" '2010</a>; <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/28235459\">Choi, '\n",
" '2017</a>; <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/28538096\">Choi, '\n",
" '2017a</a>]. \\n'\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/7961841\">Welter94</a>, '\n",
" '<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/11017202\">Abramson00</a>, '\n",
" '<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/20416270\">Yap10</a>, '\n",
" '<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/28235459\">Choi17</a>, '\n",
" '<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/28538096\">Choi17a</a>]. \\n'\n",
" '<p>\\n'\n",
" 'CyoA consists of two domains - an N '\n",
" 'terminal domain containing two '\n",
" 'transmembrane helices and a large '\n",
" 'C-terminal domain located in the periplasm '\n",
" '[<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/2165491\">Chepuri, '\n",
" '1990</a>; <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/11017202\">Abramson, '\n",
" '2000</a>]. CyoA is a lipoprotein; during '\n",
" 'maturation, the protein is modified by '\n",
" 'attachment of fatty acids and protease '\n",
" 'cleavage at C25. The addition of '\n",
" '[14C]palmitic acid to the growth medium '\n",
" 'results in covalent labeling of CyoA with '\n",
" 'the fatty acid. A C25A mutation blocks '\n",
" 'lipoprotein processing but the protein '\n",
" 'retains oxidase activity suggesting that '\n",
" 'posttranslational modification is not '\n",
" 'essential for assembly or activity of the '\n",
" 'cytochrome <i>bo</i> terminal oxidase '\n",
" 'complex [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/9298948\">Ma, '\n",
" '1997</a>]. \\n'\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/2165491\">Chepuri90</a>, '\n",
" '<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/11017202\">Abramson00</a>]. '\n",
" 'CyoA is a lipoprotein; during maturation, '\n",
" 'the protein is modified by attachment of '\n",
" 'fatty acids and protease cleavage at C25. '\n",
" 'The addition of [14C]palmitic acid to the '\n",
" 'growth medium results in covalent labeling '\n",
" 'of CyoA with the fatty acid. A C25A '\n",
" 'mutation blocks lipoprotein processing but '\n",
" 'the protein retains oxidase activity '\n",
" 'suggesting that posttranslational '\n",
" 'modification is not essential for assembly '\n",
" 'or activity of the cytochrome <i>bo</i> '\n",
" 'terminal oxidase complex [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/9298948\">Ma97a</a>]. \\n'\n",
" '<p>\\n'\n",
" '<a '\n",
" 'href=\"/gene?orgid=ECOLI&id=YIDC\">YidC</a>, '\n",
Expand All @@ -397,10 +394,9 @@
" 'href=\"/gene?orgid=ECOLI&id=SECA\">SecA</a> '\n",
" 'are required for efficient insertion of '\n",
" 'cyoA into proteoliposomes [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/16513637\">du '\n",
" 'Plessis, 2006</a>]. Efficient targeting and '\n",
" 'assembly of CyoA <i>in vivo</i> requires '\n",
" 'the <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/16513637\">duPlessis06</a>]. '\n",
" 'Efficient targeting and assembly of CyoA '\n",
" '<i>in vivo</i> requires the <a '\n",
" 'href=\"/ECOLI/NEW-IMAGE?type=ENZYME&object=SRP-CPLX\">SRP</a>, '\n",
" 'SecYEG, SecA and YidC. Insertion of the '\n",
" 'large periplasmic C-terminal segment '\n",
Expand All @@ -411,16 +407,14 @@
" 'SecYEG translocase operates downstream of '\n",
" 'YidC during the membrane assembly of CyoA '\n",
" '[<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/16481320\">van '\n",
" 'Bloois, 2006</a>] [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/18155041\">Celebi, '\n",
" '2008</a>]. Membrane insertion of the CyoA '\n",
" 'protein is independent of the proton-motive '\n",
" 'force [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/16488430\">Celebi, '\n",
" '2006</a>; <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/18155041\">Celebi, '\n",
" '2008</a>].\\n'\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/16481320\">vanBloois06</a>] '\n",
" '[<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/18155041\">Celebi08</a>]. '\n",
" 'Membrane insertion of the CyoA protein is '\n",
" 'independent of the proton-motive force [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/16488430\">Celebi06</a>, '\n",
" '<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/18155041\">Celebi08</a>].\\n'\n",
" '<p>\\n'\n",
" 'The C-terminal periplasmic domain of CyoA '\n",
" 'contains an 11 stranded anti-parallel '\n",
Expand All @@ -429,16 +423,14 @@
" 'a dinuclear copper center (Cu<sub>A</sub>) '\n",
" 'that is characteristic of the cytochrome c '\n",
" 'oxidase family [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/8433374\">van '\n",
" 'der Oost, 1993</a>; <a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/8618822\">Wilmanns, '\n",
" '1995</a>]. \\n'\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/8433374\">vanderOost93</a>, '\n",
" '<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/8618822\">Wilmanns95</a>]. \\n'\n",
" '<p>\\n'\n",
" '<i>cyoA</i> belongs to a network of genes '\n",
" 'which facilitate stress-induced mutagenesis '\n",
" '(SIM) in <i>E. coli</i> K-12 [<a '\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/23224554\">Al, '\n",
" '2012</a>].',\n",
" 'href=\"http://www.ncbi.nlm.nih.gov/pubmed/23224554\">Al12</a>].',\n",
" '@datatype': 'string'},\n",
" 'common-name': {'#text': 'cytochrome <i>bo</i><sub>3</sub> '\n",
" 'subunit 2',\n",
Expand Down Expand Up @@ -963,6 +955,9 @@
" 'with': {...}},\n",
" {'Evidence-Code': {...},\n",
" 'Publication': {...},\n",
" 'with': {...}},\n",
" {'Evidence-Code': {...},\n",
" 'Publication': {...},\n",
" 'with': {...}}]},\n",
" {'GO-Term': {'@class': 'true',\n",
" '@frameid': 'GO:0009319',\n",
Expand Down Expand Up @@ -1107,7 +1102,7 @@
" 'oxidase subunit II',\n",
" '@datatype': 'string'}]},\n",
" 'metadata': {'PGDB': {'@orgid': 'ECOLI',\n",
" '@version': '27.0',\n",
" '@version': '27.1',\n",
" 'dblink': {'dblink-URL': 'http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=511145',\n",
" 'dblink-db': 'NCBI-TAXONOMY-DB',\n",
" 'dblink-oid': '511145',\n",
Expand Down Expand Up @@ -1139,8 +1134,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-08-21T18:43:20.866792Z",
"start_time": "2023-08-21T18:43:20.462074Z"
"end_time": "2023-09-11T19:42:17.065960Z",
"start_time": "2023-09-11T19:42:16.751785Z"
}
}
},
Expand Down
Loading

0 comments on commit add65c9

Please sign in to comment.