Python实现DNA序列互补、反向、反向互补

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def complement(sequence):
sequence = sequence.upper()
sequence = sequence.replace('A', 't')
sequence = sequence.replace('T', 'a')
sequence = sequence.replace('C', 'g')
sequence = sequence.replace('G', 'c')
return sequence.upper()

def reverse(sequence):
sequence = sequence.upper()
return sequence[::-1]

def complement_reverse(sequence):
return complement(reverse(sequence))