-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpl3.py
executable file
·63 lines (50 loc) · 1.3 KB
/
expl3.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
#!/usr/bin/env python
import sys
from collections import Counter, defaultdict
import numpy as np
from scipy import stats
#if len(sys.argv) < 2:
# print "Usage: expl.py <HDB>"
# sys.exit(1)
inFn = "D3.txt"
keys = ['00',
'AA',
'AC',
'AG',
'AT',
'CA',
'CC',
'CG',
'CT',
'GA',
'GC',
'GG',
'GT',
'TA',
'TC',
'TG',
'TT']
hom = ['AA','CC','GG','TT']
mFn = 'multiplex.txt'
qFn = 'quads.txt'
M = []
Q = []
D = [M,Q]
for i,f in enumerate([mFn,qFn]):
with open(f) as F:
for l in F:
D[i].append(l.strip("\n\r"))
PF = open(inFn)
CNT = defaultdict()
for l in PF:
cs = l.strip("\n\r").split("\t")
fmId,prId,fId,mId,gender,aff = cs[:6]
CNT[(fmId, prId, mId, gender, aff)] = int(cs[-1])
PF.close()
prb_m = [v for k,v in list(CNT.items()) if k[4] == '1' and k[3] == '1']
prb_f = [v for k,v in list(CNT.items()) if k[4] == '1' and k[3] == '2']
sib_m = [v for k,v in list(CNT.items()) if k[4] == '1' and k[3] == '1' and k[2] == '0']
sib_f = [v for k,v in list(CNT.items()) if k[4] == '1' and k[3] == '2' and k[2] == '0']
prb_M = [v for k,v in list(CNT.items()) if k[4] == '1' and k[3] == '1' and k[0] in M]
prb_Q = [v for k,v in list(CNT.items()) if k[4] == '1' and k[3] == '1' and k[0] in Q]
prb_Qf = [v for k,v in list(CNT.items()) if k[4] == '1' and k[3] == '2' and k[0] in Q]