-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-overlapping-chunks.py
More file actions
79 lines (64 loc) · 1.68 KB
/
Copy pathget-overlapping-chunks.py
File metadata and controls
79 lines (64 loc) · 1.68 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
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
import sys
ref='/home/jmkidd/links/kidd-lab/genomes/UU_Cfam_GSD_1.0/ref-Y/UU_Cfam_GSD_1.0_ROSY.fa'
refFAI = ref + '.fai'
chromLens = {}
inFile = open(refFAI,'r')
for line in inFile:
line = line.rstrip()
line = line.split()
c = line[0]
l = int(line[1])
chromLens[c] = l
inFile.close()
chromNames = []
for i in range(1,39):
c = 'chr' + str(i)
chromNames.append(c)
windowSize = 1000000
overLapSize = 2000
outFile = open('auto.overlap.chunks.txt','w')
for c in chromNames:
cLen = chromLens[c]
print(c,cLen)
ws = 1
we = ws + windowSize -1
while True:
if we >= cLen:
we = cLen
outFile.write('%s\t%i\t%i\n' % (c,ws,we))
break
else:
outFile.write('%s\t%i\t%i\n' % (c,ws,we))
ws = we - overLapSize
we = ws + overLapSize + windowSize
for c in ['chrX']:
cLen = 6605250
print(c,cLen)
ws = 1
we = ws + windowSize -1
while True:
if we >= cLen:
we = cLen
outFile.write('%s\t%i\t%i\n' % (c,ws,we))
break
else:
outFile.write('%s\t%i\t%i\n' % (c,ws,we))
ws = we - overLapSize
we = ws + overLapSize + windowSize
outFile.close()
outFile = open('chrX.overlap.chunks.txt','w')
for c in ['chrX']:
cLen = chromLens[c]
print(c,cLen)
ws = 6605251
we = ws + windowSize -1
while True:
if we >= cLen:
we = cLen
outFile.write('%s\t%i\t%i\n' % (c,ws,we))
break
else:
outFile.write('%s\t%i\t%i\n' % (c,ws,we))
ws = we - overLapSize
we = ws + overLapSize + windowSize
outFile.close()