Hello all,
I have the following code:
pos = 100
cigar = [(0, 50), (3, 50), (0, 100), (3, 200), (0, 50)]
result=list()
for i in cigar:
end = pos + i[1]
#print i[1]
item = [i[0], pos, end]
result.append(item)
pos=end
matches=list()
for i in result:
if i[0]<1:
matches.append([i[1], i[2]])
print matches
This gives me the expected output. However, I want to modify this such that it should work for list of pos and cigar for example:
pos = [125, 130, 142]
cigar = [[(0, 150), (3, 50), (0, 130), (3, 270), (0, 750)], [(0, 250), (3, 250), (0, 160), (3, 270), (0, 750)], [(0, 150), (3, 150), (0, 130), (3, 250), (0, 950)]]
I am trying to use for loop to iterate through it. However, I am not able to multiloop it. Could someone help me here?
Thank you very much in advance.
I could run this using a function. However, in the out put:
[[125, 275], [325, 455], [725, 1475]]
[[125, 275], [325, 455], [725, 1475], [130, 380], [630, 790], [1060, 1810]]
[[125, 275], [325, 455], [725, 1475], [130, 380], [630, 790], [1060, 1810], [142, 292], [442, 572], [822, 1772]]
It is repeating the first list and then continuing. Could someone help me identifying why this is happing so?
You need to make sure that the list
matches
is only created once. Create it outside of the function.Thank you very much. this worked perfectly.