forked from petercombs/dicty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnyCoverageBedgraph.py
46 lines (43 loc) · 1.43 KB
/
AnyCoverageBedgraph.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
from sys import argv
if __name__ == "__main__":
# Stuff here
current_chrom = ""
left = 0
on_current_chrom = []
current_segment_chroms = []
current_segment_ends = []
current_segement_depths = []
while True:
right = min(
end
for end, working in zip(current_segment_ends, on_current_chrom)
if working
)
any_depth = (
sum(
depth > 0
for end, working in zip(current_segment_ends, on_current_chrom)
if working
),
)
print(current_chrom, left, right, any_depth, sep="\t")
left = right
for i in range(len(input_files)):
if left == current_segment_ends[i]:
try:
while True:
line = next(input_files[i])
line = line.strip().split()
line_chr = line[0]
line_left = int(line[1])
line_right = int(line[2])
line_depth = int(line[3])
if line_depth > 0:
break
if line_chr != current_chrom:
on_current_chrom[i] = False
except StopIteration:
line_chr = ""
line_left = -1
line_right = -1
line_depth = -1