-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_all_tran_new.py
116 lines (102 loc) · 4.45 KB
/
run_all_tran_new.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import json
from math import floor
import sys, time, ast
import DSGRN
from dsgrn_utilities.parameter_building import construct_parameter
import multiprocessing as mp
from functools import partial
def param_constructer(param, network):
orders = []
hex_code = []
for j in range(network.size()):
hex_code.append(param.logic()[j].hex())
orders.append(ast.literal_eval(str(param.order()[j])))
hex_code[3] = '00'
new_param_OFF = construct_parameter(network, hex_code, orders)
hex_code[3] = '3F'
new_param_ON = construct_parameter(network, hex_code, orders)
return (new_param_OFF, new_param_ON)
def FP_check(k, pgraph):
label = []
p = pgraph.parameter(k)
dg = DSGRN.DomainGraph(p)
mg = DSGRN.MorseGraph(dg)
for k in range(mg.poset().size()):
a = ast.literal_eval(str(mg.annotation(k).stringify()))
if a[0].startswith('FP '):
label.append(a)
return label
def make_intersection(xcs,network,pgraph,N,enum_fc):
n, fc_list = enum_fc
clb2_off = 0
clb2_on = 0
for k in fc_list:
param = pgraph.parameter(k)
new_param_OFF, new_param_ON = param_constructer(param, network)
if pgraph.index(new_param_OFF) in xcs:
clb2_off += 1
if pgraph.index(new_param_ON) in xcs:
clb2_on +=1
print("{} of {}".format(n+1,N))
sys.stdout.flush()
return clb2_off,clb2_on
def main_FC_XC(net,num_divisions=100):
print("FC to XC transition starting")
with open('FC_query.json', 'r') as f:
FC_query = json.load(f)
with open('XC_query.json', 'r') as f:
XC_query = json.load(f)
# CLB ON/OFF can't have FCs, use that fact to make the XC list smaller
XC_query = set(XC_query).difference(FC_query)
network = DSGRN.Network(net)
pg = DSGRN.ParameterGraph(network)
chunk = floor(len(FC_query)/num_divisions)
workinglist = [FC_query[k:k + chunk] for k in range(0, len(FC_query), chunk)]
working_func = partial(make_intersection,XC_query,network,pg,len(workinglist))
pool = mp.Pool()
output = list(pool.map(working_func, enumerate(workinglist)))
clb2_off_FC_XC = sum([o[0] for o in output])
clb2_on_FC_XC = sum([o[1] for o in output])
print("OFF clb2 FC to XC complete, {} mutant OFF params".format(clb2_off_FC_XC))
print("ON clb2 FC to XC complete, {} mutant ON params".format(clb2_on_FC_XC))
def main_monoFC_monoXC(net,num_divisions=100):
print("Monostable FC to monostable XC transition starting")
with open('monostable_FC_query.json', 'r') as f:
mono_FC = json.load(f)
with open('monostable_XC_query.json', 'r') as f:
mono_XC = json.load(f)
mono_XC = set(mono_XC).difference(mono_FC)
network = DSGRN.Network(net)
pg = DSGRN.ParameterGraph(network)
chunk = floor(len(mono_FC)/num_divisions)
workinglist = [mono_FC[k:k + chunk] for k in range(0, len(mono_FC), chunk)]
working_func = partial(make_intersection, mono_XC, network,pg, len(workinglist))
pool = mp.Pool()
output = list(pool.map(working_func, enumerate(workinglist)))
clb2_off_mono_FC_XC = sum([o[0] for o in output])
clb2_on_mono_FC_XC = sum([o[1] for o in output])
print("OFF clb2 mono FC to XC complete, {} mutant OFF params".format(clb2_off_mono_FC_XC))
print("ON clb2 mono FC to XC complete, {} mutant ON params".format(clb2_on_mono_FC_XC))
def main_biFC_biXC(net,num_divisions=100):
print("Bistable FC/FP to Bistable XC/FP transition starting")
with open('bistable_FC_FP_query.json', 'r') as f:
bi_FC = json.load(f)
with open('bistable_XC_FP_query.json', 'r') as f:
bi_XC = json.load(f)
bi_XC = set(bi_XC).difference(bi_FC)
network = DSGRN.Network(net)
pg = DSGRN.ParameterGraph(network)
chunk = floor(len(bi_FC)/num_divisions)
workinglist = [bi_FC[k:k + chunk] for k in range(0, len(bi_FC), chunk)]
working_func = partial(make_intersection, bi_XC, network,pg, len(workinglist))
pool = mp.Pool()
output = list(pool.map(working_func, enumerate(workinglist)))
clb2_off_bi_FC_XC = sum([o[0] for o in output])
clb2_on_bi_FC_XC = sum([o[1] for o in output])
print("OFF clb2 bi FC/FP to XC/FP complete, {} mutant OFF params".format(clb2_off_bi_FC_XC))
print("ON clb2 bi FC/FP to XC/FP complete, {} mutant ON params".format(clb2_on_bi_FC_XC))
if __name__ == '__main__':
net = sys.argv[1]
main_FC_XC(net,num_divisions=100)
main_monoFC_monoXC(net,num_divisions=100)
main_biFC_biXC(net, num_divisions=100)