Skip to content

Commit

Permalink
new get_relative_coords function
Browse files Browse the repository at this point in the history
  • Loading branch information
mbowcut2 committed Mar 22, 2024
1 parent ffc8c32 commit 9756e4a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion CRISPResso2/CRISPRessoShared.py
Original file line number Diff line number Diff line change
Expand Up @@ -1679,8 +1679,36 @@ def set_guide_array(vals, guides, property_name):
ret_array[idx] = int(val)
return ret_array


def get_relative_coordinates(to_sequence, from_sequence):

s1inds_gap_left = []
s1inds_gap_right = []
left_val = -1
gap_length = 0

for i in range(len(to_sequence)):
if to_sequence[i] == '-':
s1inds_gap_left.append(left_val)
gap_length += 1

elif from_sequence[i] == '-':
continue

else:
s1inds_gap_right.extend([i]*(gap_length+1))
gap_length = 0

left_val = i
s1inds_gap_left.append(left_val)

return s1inds_gap_left, s1inds_gap_right






def old_get_relative_coordinates(to_sequence, from_sequence):
"""Given an alignment, get the relative coordinates of the second sequence to the first.
For example, from_sequence[i] matches to to_sequence[inds[i]]. A `-1`
Expand Down

0 comments on commit 9756e4a

Please sign in to comment.