forked from clinical-genomics-uppsala/CARtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Detailed_generator.py
48 lines (38 loc) · 1.23 KB
/
Detailed_generator.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
47
48
def detail_samtools(Regions, Read_depth):
# create a detailed list with all depth values from the same region in a sub list. From samtools depth calculations
# samtools generates a depth file with: chr, position and coverage depth value
# Regeions comes from the bed file with chr, start, stop, region name
BaseCov_dict = {i[0]+"_"+i[1]:i[2] for i in Read_depth} #chrX_pos:coverge
detailed = []
for roi in Regions:
# import pdb; pdb.set_trace()
BaseCov_Region_temp = []
for pos in range(int(roi[1])+1,int(roi[2])+1,1): #Samtools 0 indexed
keyvalue = roi[0]+"_"+str(pos)
BaseCov_Region_temp.append(BaseCov_dict[keyvalue])
detailed.append(BaseCov_Region_temp)
# detailed =[]
# list_temp=[]
# previous_chr = Read_depth[0][0]
# Region_row = 0
# count=0
# index = 0
# size_list = len(Read_depth)
# import pdb; pdb.set_trace()
#
# for line in Read_depth:
# Region_row = Regions[index]
# if str(line[0]) == str(previous_chr) and (int(line[1])) <= int(Region_row[2]):
# list_temp.append(line[2])
#
# else:
# previous_chr=line[0]
# detailed.append(list_temp)
# list_temp=[]
# list_temp.append(line[2])
# index+=1
#
# count+=1
# if count == size_list:
# detailed.append(list_temp)
return detailed