CODE CHALLENGE: Solve the Reverse Complement Problem.
Sample Input:
AAAACCCGGT
Sample Output:
ACCGGGTTTT
##надобно: для цепочки ДНК сгенерить комплементарную в обратном направлении (реверснутую)
def reverse_complement(pattern):
reverse_pattern = []
for i in range(len(pattern)):
if pattern[i] == "A":
reverse_pattern.insert(i,"T")
elif pattern[i] == "T":
reverse_pattern.insert(i,"A")
elif pattern[i] == "C":
reverse_pattern.insert(i,"G")
elif pattern[i] == "G":
reverse_pattern.insert(i,"C")
else:
print "error. not DNA nucleotide"
reverse_pattern.reverse()
return "".join(reverse_pattern)
print reverse_complement("AAAACCCGGT")
ай дидит=) коррект!
Немає коментарів:
Дописати коментар