Given 2 strings, each containing a DNA sequence, the function returns a bool to show if a contiguous sub-fragment of length 5 or above exists in string1 that can pair w/ a fragment of str2.
Here is what I tried using the functions "complement" and "reverese_complement" that I created but it doesn't give the right result:
def complement5(sequence1,sequence2):
for i in range(len(sequence1) - 4):
substr1 = sequence1[i:i+5]
if complement(substr1) in sequence2 or reverese_complement(substr1) in sequence2:
print(f'{substr1, complement(substr1), reverese_complement(substr1)} in {sequence2}')
return True
else:
return False
Then when I try: complement5('CAATTCC','CTTAAGG') it gives False instead of True