-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd7-protocols.py
executable file
·86 lines (77 loc) · 3.03 KB
/
d7-protocols.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
#!/usr/bin/env python3
#
# Calculates statistics about the means reported in the midpoints data.
#
import numpy as np
import base
nooocytes = True
qand = ' and cell != "Oocyte" group by pub'
# Query db
with base.connect() as con:
c = con.cursor()
def g(x):
q = f'select {x} from midpoints_wt where {x} is not null {qand}'
return np.array([row[x] for row in c.execute(q)])
ah, alo, da, ahi = g('pah'), g('palo'), g('pad'), g('pahi')
ih, ilo, di, ihi, it = g('pih'), g('pilo'), g('pid'), g('pihi'), g('pit')
def occs(name, x):
v, c = np.unique(x, return_counts=True)
print(f'{name:<9}'
+ ' '.join([f'{x:^4}' for x in v]) + '\n' + ' '*9
+ ' '.join([f'{x:^4}' for x in c]))
return v[np.argmax(c)]
# Calculate
print('Activation protocol')
a = occs('V hold', ah)
b = occs('V low', alo)
c = occs('V step', da)
d = occs('V high', ahi)
print(f'Modal protocol: hold at {a}, step from {b} to {d} in {c}mV steps')
with base.connect() as con:
r = con.cursor()
q = (f'select pah from midpoints_wt where pah == {a} and palo == {b} and'
f' pad == {c} and pahi == {d} {qand}')
n = len([row for row in r.execute(q)])
print(f' exact modal occurs: {n} times')
q = (f'select palo from midpoints_wt where palo == {b} and pahi == {d}'
f' and pad == {c} {qand}')
n = len([row for row in r.execute(q)])
print(f' low/high/step combo occurs: {n} times')
q = (f'select pub from midpoints_wt where palo == {b} and pahi == {d}'
f' {qand}')
rows = [row['pub'] for row in r.execute(q)]
print(f' low/high combo occurs: {len(rows)} times:')
for r in rows:
print(f' {r}')
print('Inactivation protocol')
a = occs('V hold', ih)
b = occs('V low', ilo)
c = occs('V step', di)
d = occs('V high', ihi)
e = occs('V test', it)
print(f'Modal protocol: hold at {a}, step from {b} to {d} in {c}mV steps,'
f' test at {e}mV')
with base.connect() as con:
r = con.cursor()
q = (f'select pih from midpoints_wt where pih == {a} and pilo == {b} and'
f' pid == {c} and pihi == {d} and pit == {e} {qand}')
n = len([row for row in r.execute(q)])
print(f' exact modal occurs: {n} times')
q = (f'select pih from midpoints_wt where pilo == {b} and pihi == {d} and'
f' pid == {c} and pit == {e} {qand}')
n = len([row for row in r.execute(q)])
print(f' low/high/step/test combo occurs: {n} times')
q = (f'select pih from midpoints_wt where pilo == {b} and pihi == {d} and'
f' pid == {c} {qand}')
n = len([row for row in r.execute(q)])
print(f' low/high/step combo occurs: {n} times')
q = (f'select pih from midpoints_wt where pilo == {b} and pihi == {d} and'
f' pit == {e} {qand}')
n = len([row for row in r.execute(q)])
print(f' low/high/test combo occurs: {n} times')
q = (f'select pub from midpoints_wt where pilo == {b} and pihi == {d}'
f' {qand}')
rows = [row['pub'] for row in r.execute(q)]
print(f' low/high combo occurs: {len(rows)} times:')
for r in rows:
print(f' {r}')