forked from jensenlab/BacterAI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol_run_expt_gen.py
More file actions
44 lines (30 loc) · 1004 Bytes
/
control_run_expt_gen.py
File metadata and controls
44 lines (30 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np
import csv
import global_vars
import utils
SEED = 0
NP_RAND_STATE = utils.seed_numpy_state(SEED)
def main(n=1120, out_name=f"control_run_randoms_SGO_seed{SEED}.csv"):
choice_map = {i: ingred for i, ingred in enumerate(global_vars.AA_NAMES_TEMPEST)}
chosen = set()
skipped_count = 0
mapped_chosen = []
while len(chosen) < n:
new = tuple(NP_RAND_STATE.choice([0, 1], size=20, replace=True).tolist())
if new not in chosen:
chosen.add(new)
media = []
for i, x in enumerate(new):
if x == 1:
media.append(choice_map[i])
mapped_chosen.append(media)
else:
skipped_count += 1
print(f"{skipped_count=}")
with open(out_name, "w") as f:
writer = csv.writer(f, delimiter=",")
for row in mapped_chosen:
writer.writerow(sorted(row))
print(f"File saved to: {out_name}")
if __name__ == "__main__":
main()