comparison range2tag.py @ 3:e66e151e07ab draft

planemo upload for repository https://github.com/gpovysil/galaxy/tools/range2tag commit 2daa6a8b7af02ed7a80381e21dd4dfb25619c39f
author gpovysil
date Wed, 16 May 2018 09:33:29 -0400
parents 7d4ec8f51253
children e2ccee720583
comparison
equal deleted inserted replaced
2:7d4ec8f51253 3:e66e151e07ab
50 range_array = np.genfromtxt(regs, skip_header=0, delimiter='\t', comments='#') 50 range_array = np.genfromtxt(regs, skip_header=0, delimiter='\t', comments='#')
51 51
52 start_posList = range_array[:,0].astype(int) 52 start_posList = range_array[:,0].astype(int)
53 stop_posList = range_array[:,1].astype(int) 53 stop_posList = range_array[:,1].astype(int)
54 54
55 print(start_posList)
56 print(stop_posList)
57
58 if len(start_posList) == 0: 55 if len(start_posList) == 0:
59 print("Error: start_positions is empty") 56 print("Error: start_positions is empty")
60 exit(2) 57 exit(2)
61 58
62 if len(stop_posList) == 0: 59 if len(stop_posList) == 0:
82 for start_pos, stop_pos in zip(start_posList, stop_posList): 79 for start_pos, stop_pos in zip(start_posList, stop_posList):
83 start_pos = start_pos - 3 80 start_pos = start_pos - 3
84 stop_pos = stop_pos + 3 81 stop_pos = stop_pos + 3
85 mut_tags = None 82 mut_tags = None
86 for t in range(0, len(tags)): 83 for t in range(0, len(tags)):
87 c_split = re.split('([A-Z])', cigar[t]) 84 if cigar[t] != "*":
88 print(c_split) 85 c_split = re.split('([A-Z])', cigar[t])
89 cigar_long = None 86 print(c_split)
87 cigar_long = None
90 88
91 for i in range(1, len(c_split), 2): 89 for i in range(1, len(c_split), 2):
92 if cigar_long is None: 90 if cigar_long is None:
93 cigar_long = np.repeat(c_split[i], c_split[i - 1]) 91 cigar_long = np.repeat(c_split[i], c_split[i - 1])
94 else: 92 else:
95 cigar_long = np.concatenate((cigar_long, np.repeat(c_split[i], c_split[i - 1])), axis=0) 93 cigar_long = np.concatenate((cigar_long, np.repeat(c_split[i], c_split[i - 1])), axis=0)
96 94
97 pos = ref_pos[t] 95 pos = ref_pos[t]
98 seq_pos = 0 96 seq_pos = 0
99 # print(pos) 97 # print(pos)
100 if pos < stop_pos: 98 if pos < stop_pos:
101 for j in range(0, len(cigar_long)): 99 for j in range(0, len(cigar_long)):
102 if pos >= stop_pos: 100 if pos >= stop_pos:
103 break 101 break
104 if cigar_long[j] in ("M", "D", "N"): 102 if cigar_long[j] in ("M", "D", "N"):
105 pos += 1 103 pos += 1
106 # print(pos) 104 # print(pos)
107 if pos > start_pos: 105 if pos > start_pos:
108 if mut_tags is None: 106 if mut_tags is None:
109 mut_tags = np.array((tags[t])) 107 mut_tags = np.array((tags[t]))
110 else: 108 else:
111 mut_tags = np.vstack((mut_tags, np.array(tags[t]))) 109 mut_tags = np.vstack((mut_tags, np.array(tags[t])))
112 110
113 index = np.repeat("{}_{}".format(start_pos, stop_pos), len(mut_tags)) 111 index = np.repeat("{}_{}".format(start_pos, stop_pos), len(mut_tags))
114 ind.append(index) 112 ind.append(index)
115 lst.append(mut_tags) 113 lst.append(mut_tags)
116 114