I want to replace some characters in a string using a pythonic approach.
A -> T
C -> G
G -> C
T -> A
Example:
AAATCGATTGAT
will transform into
TTTAGCTAACTA
What I did:
def swap(string):
string = re.sub('A', 'aux', string)
string = re.sub('T', 'A', string)
string = re.sub('aux', 'T', string)
string = re.sub('C', 'aux', string)
string = re.sub('G', 'C', string)
string = re.sub('aux', 'G', string)
return string
It worked great, but i'm looking for a more pythonic way to reach that.