Skip to content

Instantly share code, notes, and snippets.

@serverwentdown
Created September 16, 2019 04:33
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 serverwentdown/2cec8f77d8cef6c9dade2e236e5c8e0a to your computer and use it in GitHub Desktop.
Save serverwentdown/2cec8f77d8cef6c9dade2e236e5c8e0a to your computer and use it in GitHub Desktop.
s = 'actgactgactggatc'
m = {
'a': 0,
'c': 1,
't': 2,
'g': 3
}
bytestring = []
for b in range(0, len(s), 4):
byte = 0
for p in range(0, 4):
byte += (4**(3-p)) * m[s[b+p]]
bytestring.append(byte)
print(bytes(bytestring))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment