Skip to content

Instantly share code, notes, and snippets.

@kgori
Created April 6, 2018 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgori/eaaa02e8c31fd4fb216d736a0c4be7b1 to your computer and use it in GitHub Desktop.
Save kgori/eaaa02e8c31fd4fb216d736a0c4be7b1 to your computer and use it in GitHub Desktop.
DNA reverse complement
def revcomp(s):
complements = dict(
A='T', C='G', G='C', T='A',
M='K', R='Y', W='W', S='S',
Y='R', K='M', V='B', H='D',
D='H', B='V', N='N'
)
return ''.join(complements[char] for char in s.upper()[::-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment