-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathis_repetitive.py
executable file
·42 lines (38 loc) · 1.04 KB
/
is_repetitive.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
from Bio import SeqIO
import sys
genome = SeqIO.to_dict(SeqIO.parse(sys.argv[1], "fasta"))
def get_len(line):
start_pos = line.find("SVLEN")
ans = ""
start_pos += 6
while line[start_pos].isdigit():
ans += line[start_pos]
start_pos += 1
return int(ans)
def get_popins_len(line):
start_pos = line.find("length_")
ans = ""
start_pos += 7
while line[start_pos].isdigit():
ans += line[start_pos]
start_pos += 1
return int(ans) - 55
def get_my_len(s):
return len(s.split("\t")[4])
is_repeat = 0
non_repeat = 0
with open("../results/chm13/novelx_80.vcf", "r") as my_vcf:
for r in my_vcf.readlines():
if r.startswith("#"):
continue
if get_my_len(r) < 300:
continue
chrom = r.split("\t")[0]
pos = int(r.split("\t")[1])
s = genome[chrom][pos - 300 : pos + 300].seq
if all(s[i].islower() for i in range(len(s))):
is_repeat += 1
else:
non_repeat += 1
print(is_repeat)
print(non_repeat)