Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active December 14, 2019 07:28
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 havenwood/459942bed833fbc333a00e7ca47c82cd to your computer and use it in GitHub Desktop.
Save havenwood/459942bed833fbc333a00e7ca47c82cd to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
FROM = 'GCTA'
TO = 'CGAU'
HASH = FROM.chars.zip(TO.chars).to_h.freeze
SEQUENCE = 'GATTACA'
SEQUENCE.chars.map(&HASH)
#=> ["C", "U", "A", "A", "U", "G", "U"]
SEQUENCE.tr(FROM, TO).chars
#=> ["C", "U", "A", "A", "U", "G", "U"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment