Given: A DNA string of length at most 1 kbp in FASTA format.
Return: The position and length of every reverse palindrome in the string having length between 4 and 12.
Return: The position and length of every reverse palindrome in the string having length between 4 and 12.
s = input() def complementary(a, b): if (a == 'A' and b == 'T') or (a == 'T' and b == 'A') or (a == 'G' and b == 'C') or (a == 'C' and b == 'G'): return True else: return False res = [] for i in range(1, 6): if complementary(s[i - 1], s[i]): j = 1 while j < i: if complementary(s[i - 1 - j], s[i + j]): res.append([i-j, 2 * (j+1)]) j += 1 else: breakfor i in range(6, len(s)-5): if complementary(s[i - 1], s[i]): j = 1 while j < 6: if complementary(s[i - 1 - j], s[i + j]): res.append([i - j, 2 * (j+1)]) j += 1 else: breakfor i in range(len(s)-5, len(s)-1): if complementary(s[i - 1], s[i]): j = 1 while j < len(s)-i: if complementary(s[i - 1 - j], s[i + j]): res.append([i - j, 2 * (j+1)]) j += 1 else: breakfor r in res: print(''.join(str(r[0])) + ' ' + ''.join(str(r[1])))
Комментариев нет:
Отправить комментарий