-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths2_RecordSplit.py
More file actions
42 lines (37 loc) · 1.28 KB
/
s2_RecordSplit.py
File metadata and controls
42 lines (37 loc) · 1.28 KB
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
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 10 20:06:00 2021
@author: xianglin
"""
#%% read pars from environment
import sys,getopt
opts,args = getopt.getopt(sys.argv[1:],"hi:o:g:")
chroms = ['chr'+str(x) for x in range(1,23)]
for op,val in opts:
if op == '-i':
infile = val
elif op == '-o':
outfile = val
elif op == '-g':
chroms = val.split(',')
elif op == '-h':
print('Usage: python s2_RecordSplit.py -i ./test_ReadsMethyAndMuts.txt -o ./test -g chr1,chr2,chr3,chr4,chr5\n\
i,The path to s1 output. ( end with _ReadsMethyAndMuts.txt);\n\
o,Output prefix;\n\
g,Chromosomes used; (default chromsome 1-22); chromosomes shoud be seperated by comma;\n\
h,Help information')
sys.exit()
if __name__ == '__main__':
for chrom in chroms:
cc = 0
out_tmp = open(outfile +'_ReadsMethyAndMuts_'+chrom+'.txt','w')
with open(infile,'r') as f:
for line in f.readlines():
if cc == 0:
cc = 1
else:
line1 = line.strip().split('\t')
if line1[0] == chrom and len(line1[6] + line1[7]) >= 2:
out_tmp.write(line)
f.close()
out_tmp.close()