-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcCnt.py
executable file
·45 lines (37 loc) · 988 Bytes
/
cCnt.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
#!/usr/bin/env python
import os, sys
from famSummary import *
from collections import defaultdict, Counter
import numpy as np
fams = list(cleanFMS.keys())
if len(sys.argv) < 3:
print("Usage cCnt.py <chunk #> <ped file>")
exit()
#pedFn = 'SPARK.30K.snp.SP.ped'
chunk = sys.argv[1]
pedFn = sys.argv[2]
sline = int(chunk)*500
eline = (int(chunk)+1)*500
print(sline, eline, pedFn, "number of fams:", len(fams), file=sys.stderr)
ped = []
n=-1
counts = []
with open(pedFn, 'r') as f:
for l in f:
n +=1
if n < sline:
continue
if n >= eline:
break
cs = l.strip('\n\r').split(' ')
if not cs[0] in fams:
continue
pId = cs[1]
G = cs[6:]
counts.append([cs[0],cs[1],Counter(G)])
#if n > 30:
# break
fn = open('STATS/cCnt-'+chunk+'.npz', 'wb')
np.savez(fn,counts=counts)
fn.close()
print("Done", 'STATS/cCnt-'+str(sline)+'-'+str(eline)+'.npz', file=sys.stderr)