Skip to content

Instantly share code, notes, and snippets.

@hryk
Created October 2, 2012 18:43
Show Gist options
  • Select an option

  • Save hryk/3822264 to your computer and use it in GitHub Desktop.

Select an option

Save hryk/3822264 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pp'
class Foo
IUPAC_CODE = {
:I => "Ile",
:V => "Val",
:L => "Leu",
:F => "Phe",
:C => "Cys",
:M => "Met",
:A => "Ala",
:G => "Gly",
:T => "Thr",
:W => "Trp",
:S => "Ser",
:Y => "Tyr",
:P => "Pro",
:H => "His",
:E => "Glu",
:Q => "Gln",
:D => "Asp",
:N => "Asn",
:K => "Lys",
:R => "Arg",
:U => "Sec",
:O => "Pyl",
:B => "Asx",
:Z => "Glx",
:X => "Xaa"
}
def original_hash
IUPAC_CODE
end
def update_hash
IUPAC_CODE.update(IUPAC_CODE){|k, v| 0.0 }
end
end
pp Foo.new.update_hash
# ruby-1.9.3-p134
#
# => {:I=>0.0,
# :V=>0.0,
# :L=>0.0,
# :F=>0.0,
# :C=>0.0,
# :M=>0.0,
# :A=>0.0,
# :G=>0.0,
# :T=>0.0,
# :W=>0.0,
# :S=>0.0,
# :Y=>0.0,
# :P=>0.0,
# :H=>0.0,
# :E=>0.0,
# :Q=>0.0,
# :D=>0.0,
# :N=>0.0,
# :K=>0.0,
# :R=>0.0,
# :U=>0.0,
# :O=>0.0,
# :B=>0.0,
# :Z=>0.0,
# :X=>0.0}
# rbx-2.0.0-dev -X18
#
# => {:Y=>0.0,
# :Z=>0.0,
# :E=>0.0,
# :H=>0.0,
# :I=>"Ile",
# :G=>0.0,
# :Q=>"Gln",
# :F=>"Phe",
# :S=>0.0,
# :K=>"Lys",
# :T=>0.0,
# :U=>0.0,
# :P=>0.0,
# :D=>0.0,
# :X=>"Xaa",
# :L=>"Leu",
# :M=>"Met",
# :W=>0.0,
# :A=>0.0,
# :O=>"Pyl",
# :N=>0.0,
# :R=>"Arg",
# :B=>"Asx",
# :V=>0.0,
# :C=>0.0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment