Module | Bio::AminoAcid::Data
In: | lib/bio/data/aa.rb

### Methods

[] aa name name2one name2three names one one2name one2three three three2name three2one to_1 to_3 to_re weight

### Constants

NAMES

=

{ 'A' => 'Ala', 'C' => 'Cys', 'D' => 'Asp', 'E' => 'Glu', 'F' => 'Phe', 'G' => 'Gly', 'H' => 'His', 'I' => 'Ile', 'K' => 'Lys', 'L' => 'Leu', 'M' => 'Met', 'N' => 'Asn', 'P' => 'Pro', 'Q' => 'Gln', 'R' => 'Arg', 'S' => 'Ser', 'T' => 'Thr', 'V' => 'Val', 'W' => 'Trp', 'Y' => 'Tyr', 'B' => 'Asx', # D/N 'Z' => 'Glx', # E/Q 'J' => 'Xle', # I/L 'U' => 'Sec', # 'uga' (stop) 'O' => 'Pyl', # 'uag' (stop) 'X' => 'Xaa', # (unknown) 'Ala' => 'alanine', 'Cys' => 'cysteine', 'Asp' => 'aspartic acid', 'Glu' => 'glutamic acid', 'Phe' => 'phenylalanine', 'Gly' => 'glycine', 'His' => 'histidine', 'Ile' => 'isoleucine', 'Lys' => 'lysine', 'Leu' => 'leucine', 'Met' => 'methionine', 'Asn' => 'asparagine', 'Pro' => 'proline', 'Gln' => 'glutamine', 'Arg' => 'arginine', 'Ser' => 'serine', 'Thr' => 'threonine', 'Val' => 'valine', 'Trp' => 'tryptophan', 'Tyr' => 'tyrosine', 'Asx' => 'asparagine/aspartic acid [DN]', 'Glx' => 'glutamine/glutamic acid [EQ]', 'Xle' => 'isoleucine/leucine [IL]', 'Sec' => 'selenocysteine', 'Pyl' => 'pyrrolysine', 'Xaa' => 'unknown [A-Z]', }

IUPAC code

- www.iupac.org/
- www.chem.qmw.ac.uk/iubmb/newsletter/1999/item3.html
- www.ebi.ac.uk/RESID/faq.html

WEIGHT

=

{ 'A' => 89.09, 'C' => 121.15, # 121.16 according to the Wikipedia 'D' => 133.10, 'E' => 147.13, 'F' => 165.19, 'G' => 75.07, 'H' => 155.16, 'I' => 131.17, 'K' => 146.19, 'L' => 131.17, 'M' => 149.21, 'N' => 132.12, 'P' => 115.13, 'Q' => 146.15, 'R' => 174.20, 'S' => 105.09, 'T' => 119.12, 'U' => 168.06, 'V' => 117.15, 'W' => 204.23, 'Y' => 181.19, }

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)

[Source]

         # File lib/bio/data/aa.rb, line 131
    131:     def [](x)
    132:       NAMES[x]
    133:     end

aa()

Alias for names

name(x)

[Source]

         # File lib/bio/data/aa.rb, line 141
    141:     def name(x)
    142:       str = NAMES[x]
    143:       if str and str.length == 3
    144:         NAMES[str]
    145:       else
    146:         str
    147:       end
    148:     end

name2one(x)

[Source]

         # File lib/bio/data/aa.rb, line 198
    198:     def name2one(x)
    199:       str = reverse[x.to_s.downcase]
    200:       if str and str.length == 3
    201:         three2one(str)
    202:       else
    203:         str
    204:       end
    205:     end

name2three(x)

[Source]

         # File lib/bio/data/aa.rb, line 215
    215:     def name2three(x)
    216:       reverse[x.downcase]
    217:     end

names()

backward compatibility

[Source]

         # File lib/bio/data/aa.rb, line 136
    136:     def names
    137:       NAMES
    138:     end

one(x)

Alias for to_1

one2name(x)

[Source]

         # File lib/bio/data/aa.rb, line 190
    190:     def one2name(x)
    191:       if x and x.length != 1
    192:         raise ArgumentError
    193:       else
    194:         three2name(NAMES[x])
    195:       end
    196:     end

one2three(x)

[Source]

         # File lib/bio/data/aa.rb, line 174
    174:     def one2three(x)
    175:       if x and x.length != 1
    176:         raise ArgumentError
    177:       else
    178:         NAMES[x]
    179:       end
    180:     end

three(x)

Alias for to_3

three2name(x)

[Source]

         # File lib/bio/data/aa.rb, line 207
    207:     def three2name(x)
    208:       if x and x.length != 3
    209:         raise ArgumentError
    210:       else
    211:         NAMES[x]
    212:       end
    213:     end

three2one(x)

[Source]

         # File lib/bio/data/aa.rb, line 182
    182:     def three2one(x)
    183:       if x and x.length != 3
    184:         raise ArgumentError
    185:       else
    186:         reverse[x]
    187:       end
    188:     end

to_1(x)

[Source]

         # File lib/bio/data/aa.rb, line 150
    150:     def to_1(x)
    151:       case x.to_s.length
    152:       when 1
    153:         x
    154:       when 3
    155:         three2one(x)
    156:       else
    157:         name2one(x)
    158:       end
    159:     end

to_3(x)

[Source]

         # File lib/bio/data/aa.rb, line 162
    162:     def to_3(x)
    163:       case x.to_s.length
    164:       when 1
    165:         one2three(x)
    166:       when 3
    167:         x
    168:       else
    169:         name2three(x)
    170:       end
    171:     end

to_re(seq)

[Source]

         # File lib/bio/data/aa.rb, line 219
    219:     def to_re(seq)
    220:       replace = {
    221:         'B' => '[DNB]',
    222:         'Z' => '[EQZ]',
    223:         'J' => '[ILJ]',
    224:         'X' => '[ACDEFGHIKLMNPQRSTVWYUOX]',
    225:       }
    226:       replace.default = '.'
    227:
    228:       str = seq.to_s.upcase
    229:       str.gsub!(/[^ACDEFGHIKLMNPQRSTVWYUO]/) { |aa|
    230:         replace[aa]
    231:       }
    232:       Regexp.new(str)
    233:     end

weight(x = nil)

[Source]

         # File lib/bio/data/aa.rb, line 110
    110:     def weight(x = nil)
    111:       if x
    112:         if x.length > 1
    113:           total = 0.0
    114:           x.each_byte do |byte|
    115:             aa = byte.chr.upcase
    116:             if WEIGHT[aa]
    117:               total += WEIGHT[aa]
    118:             else
    119:               raise "Error: invalid amino acid '#{aa}'"
    120:             end
    121:           end
    122:           total -= NucleicAcid.weight[:water] * (x.length - 1)
    123:         else
    124:           WEIGHT[x]
    125:         end
    126:       else
    127:         WEIGHT
    128:       end
    129:     end

[Validate]