forked from Axolotl233/Simple_Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Phase.repeat2unrepeat.py
43 lines (36 loc) · 1.01 KB
/
Phase.repeat2unrepeat.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
#! python
import os
import sys
bed_file = (sys.argv[1])
len_file = (sys.argv[2])
len_dict ={}
bed_dict ={}
with open(len_file,"r") as len_object:
for line in len_object:
line=line.strip('\n')
array = []
array = line.split("\t")
len_dict[array[0]] = array[1]
last ="NA";
array2 =[]
with open(bed_file,"r") as bed_object:
for line in bed_object:
line=line.strip('\n')
array = []
array = line.split("\t")
if array[0] != last:
if last != "NA":
bed_dict[last]=array2
last = array[0]
array2 = [array[1],array[2]]
else:
array2.append(array[1])
array2.append(array[2])
last = array[0]
bed_dict[last]=array2
for name in (bed_dict.keys()):
array3 = bed_dict[name]
array3.append(len_dict[name])
array3.insert(0,0)
for i in range(0,len(array3),2):
print("%s\t%d\t%d" %(name,(int(array3[i])),(int(array3[i+1]))))