Skip to content

Instantly share code, notes, and snippets.

@szeitlin
Created February 12, 2014 02:51
Show Gist options
  • Save szeitlin/8949162 to your computer and use it in GitHub Desktop.
Save szeitlin/8949162 to your computer and use it in GitHub Desktop.
Rosalind problem: reverse complement strand.
def complementary(s):
'''
(str) -> (str)
Returns the reverse complementary strand of s.
>>>complementary('AAACCCTTTGGG')
CCCAAAGGGTTT
'''
reverse = s[::-1]
old = 'ATCG'
new = 'TAGC'
lookatthis = str.maketrans(old, new)
complement = reverse.translate(lookatthis)
print(complement)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment