I have set of patterns
ATGCG GCATG CATGC AGGCA GGCAT
which I need to find the overlap between them. I'm using this function and it works correctly:
def get_overlap(patterns):
n = len(patterns[0])-1
return [(left,right) for left,right in product(patterns,patterns) if left != right and left.endswith(right[:n])]
My question is: why it doesn't loop through all the patterns when I am using the ordinary for loop form?
for left, right in product(patterns, patterns):
if left != right and left.endswith(right[:n]):
return [left, right]
it prints the last item only