Hello all,
pos = [66905851, 66905852]
cigar = [[(0, 117), (3, 29773), (0, 253), (3, 1325), (0, 145)], [(0, 116), (2, 1), (3, 3419), (0, 327), (3, 21529), (0, 286), (2, 1), (0, 1), (3, 4210), (0, 253), (3, 1325), (0, 145)]]
new = []
for p in cigar:
for k,v in enumerate(p):
for i , j in enumerate(p[:]):
for num in pos:
if v == 0:
new.append(j+num)
I am working on above code. In which pos contains numbers and cigar contains two lists of tuples which are to be used for the two numbers in pos respectively.
I am trying to add the second number of each tuple (for eg 117 in (0,177)) in the first number of pos (for eg 66905851) if a first number of the tuple is zero.
Desired out put: [66905851, 66905851+117]
[66905851+117, 66905851+117+ 29773]
[66905851+117+ 29773, 66905851+117+ 29773+253]
and so on for the first number 66905851. and for 66905852 the code should use values from the second list of the tuple from the cigar list.
[(0, 116), (2, 1), (3, 3419), (0, 327), (3, 21529), (0, 286), (2, 1), (0, 1), (3, 4210), (0, 253), (3, 1325), (0, 145)]
My code is not giving me desired output. Could someone help me here? Thank you in advance.
Kindly add an example of desired output. I am looking for the format you need. I can quickly help
Hello Vijay, I have edited the original post with the desired output. I appreciate your help. Thank you.
Help me in understanding the issue. In OP, pos has two values and cigar is a tuple with two vales for each position. If first value of cigar is 0, then add 2nd value to pos (each pos). Is this correct? In that case, why 29773 is added to pos when first the value is not 0 and that too multiple times, in output expected? copy/pasted from OP:
Based on above logic, my output is as follows:
I have added 29773 because I am trying to get genomic coordinates from iterating through the cigar. The next match found is after 29773 so my next alignment coordinate will be after 29773.