module Bio::AminoAcid::Data

Constants

NAMES

IUPAC code

WEIGHT

AAindex FASG760101 - Molecular weight (Fasman, 1976)

Fasman, G.D., ed.
Handbook of Biochemistry and Molecular Biology", 3rd ed.,
Proteins - Volume 1, CRC Press, Cleveland (1976)

Public Instance Methods

[](x) click to toggle source
# File lib/bio/data/aa.rb, line 129
def [](x)
  NAMES[x]
end
aa()
Alias for: names
name(x) click to toggle source
# File lib/bio/data/aa.rb, line 139
def name(x)
  str = NAMES[x]
  if str and str.length == 3
    NAMES[str]
  else
    str
  end
end
name2one(x) click to toggle source
# File lib/bio/data/aa.rb, line 196
def name2one(x)
  str = reverse[x.to_s.downcase]
  if str and str.length == 3
    three2one(str)
  else
    str
  end
end
name2three(x) click to toggle source
# File lib/bio/data/aa.rb, line 213
def name2three(x)
  reverse[x.downcase]
end
names() click to toggle source

backward compatibility

# File lib/bio/data/aa.rb, line 134
def names
  NAMES
end
Also aliased as: aa
one(x)
Alias for: to_1
one2name(x) click to toggle source
# File lib/bio/data/aa.rb, line 188
def one2name(x)
  if x and x.length != 1
    raise ArgumentError
  else
    three2name(NAMES[x])
  end
end
one2three(x) click to toggle source
# File lib/bio/data/aa.rb, line 172
def one2three(x)
  if x and x.length != 1
    raise ArgumentError
  else
    NAMES[x]
  end
end
three(x)
Alias for: to_3
three2name(x) click to toggle source
# File lib/bio/data/aa.rb, line 205
def three2name(x)
  if x and x.length != 3
    raise ArgumentError
  else
    NAMES[x]
  end
end
three2one(x) click to toggle source
# File lib/bio/data/aa.rb, line 180
def three2one(x)
  if x and x.length != 3
    raise ArgumentError
  else
    reverse[x]
  end
end
to_1(x) click to toggle source
# File lib/bio/data/aa.rb, line 148
def to_1(x)
  case x.to_s.length
  when 1
    x
  when 3
    three2one(x)
  else
    name2one(x)
  end
end
Also aliased as: one
to_3(x) click to toggle source
# File lib/bio/data/aa.rb, line 160
def to_3(x)
  case x.to_s.length
  when 1
    one2three(x)
  when 3
    x
  else
    name2three(x)
  end
end
Also aliased as: three
to_re(seq) click to toggle source
# File lib/bio/data/aa.rb, line 217
def to_re(seq)
  replace = {
    'B' => '[DNB]',
    'Z' => '[EQZ]',
    'J' => '[ILJ]',
    'X' => '[ACDEFGHIKLMNPQRSTVWYUOX]',
  }
  replace.default = '.'

  str = seq.to_s.upcase
  str.gsub!(/[^ACDEFGHIKLMNPQRSTVWYUO]/) { |aa|
    replace[aa]
  }
  Regexp.new(str)
end
weight(x = nil) click to toggle source
# File lib/bio/data/aa.rb, line 110
def weight(x = nil)
  return WEIGHT unless x

  if x.length > 1
    total = 0.0
    x.each_byte do |byte|
      aa = byte.chr.upcase
      if WEIGHT[aa]
        total += WEIGHT[aa]
      else
        raise "Error: invalid amino acid '#{aa}'"
      end
    end
    total -= NucleicAcid.weight[:water] * (x.length - 1)
  else
    WEIGHT[x]
  end
end