Skip to content

Instantly share code, notes, and snippets.

@wulab
Last active August 29, 2015 14:05
Show Gist options
  • Save wulab/fff1b37da295c778728a to your computer and use it in GitHub Desktop.
Save wulab/fff1b37da295c778728a to your computer and use it in GitHub Desktop.
class String
def translate(from_str, to_str)
IO.popen(["python", "-c", <<-CMD.gsub(/^\s{6}/,"")]) { |f| f.read.chomp }
import string
print '#{self}'.translate(string.maketrans('#{from_str}','#{to_str}'))
CMD
end
end
class Complement
def self.of_dna(dna)
dna.translate('GCTA','CGAU')
end
def self.of_rna(rna)
rna.translate('CGAU','GCTA')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment