-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFilterOverlaps.py
More file actions
26 lines (24 loc) · 1.04 KB
/
FilterOverlaps.py
File metadata and controls
26 lines (24 loc) · 1.04 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
import re
def Overlap_From_Paf(line):
line = line[:-1].split()
read1 = int(re.search(r'\d+', line[0]).group())
read2 = int(re.search(r'\d+', line[5]).group())
return [read1, read2]
def filter(overlap_file ,overlap_list, labels, outputpath):
outputpath = outputpath + '-newoverlaps.paf'
read_label_dict = dict(zip(overlap_list, labels))
with open(outputpath, 'w') as output:
with open(overlap_file) as ov_file:
for line in ov_file:
reads = Overlap_From_Paf(line)
name = (reads[0], reads[1])
if name in read_label_dict.keys():
if read_label_dict[name] == 0:
output.write(line)
else:
name = (reads[1], reads[0])
if name in read_label_dict.keys():
if read_label_dict[name] == 0:
output.write(line)
else:
output.write(line)