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
129 def [](x)
130   NAMES[x]
131 end
aa()
Alias for: names
name(x) click to toggle source
    # File lib/bio/data/aa.rb
139 def name(x)
140   str = NAMES[x]
141   if str and str.length == 3
142     NAMES[str]
143   else
144     str
145   end
146 end
name2one(x) click to toggle source
    # File lib/bio/data/aa.rb
196 def name2one(x)
197   str = reverse[x.to_s.downcase]
198   if str and str.length == 3
199     three2one(str)
200   else
201     str
202   end
203 end
name2three(x) click to toggle source
    # File lib/bio/data/aa.rb
213 def name2three(x)
214   reverse[x.downcase]
215 end
names() click to toggle source

backward compatibility

    # File lib/bio/data/aa.rb
134 def names
135   NAMES
136 end
Also aliased as: aa
one(x)
Alias for: to_1
one2name(x) click to toggle source
    # File lib/bio/data/aa.rb
188 def one2name(x)
189   if x and x.length != 1
190     raise ArgumentError
191   else
192     three2name(NAMES[x])
193   end
194 end
one2three(x) click to toggle source
    # File lib/bio/data/aa.rb
172 def one2three(x)
173   if x and x.length != 1
174     raise ArgumentError
175   else
176     NAMES[x]
177   end
178 end
three(x)
Alias for: to_3
three2name(x) click to toggle source
    # File lib/bio/data/aa.rb
205 def three2name(x)
206   if x and x.length != 3
207     raise ArgumentError
208   else
209     NAMES[x]
210   end
211 end
three2one(x) click to toggle source
    # File lib/bio/data/aa.rb
180 def three2one(x)
181   if x and x.length != 3
182     raise ArgumentError
183   else
184     reverse[x]
185   end
186 end
to_1(x) click to toggle source
    # File lib/bio/data/aa.rb
148 def to_1(x)
149   case x.to_s.length
150   when 1
151     x
152   when 3
153     three2one(x)
154   else
155     name2one(x)
156   end
157 end
Also aliased as: one
to_3(x) click to toggle source
    # File lib/bio/data/aa.rb
160 def to_3(x)
161   case x.to_s.length
162   when 1
163     one2three(x)
164   when 3
165     x
166   else
167     name2three(x)
168   end
169 end
Also aliased as: three
to_re(seq) click to toggle source
    # File lib/bio/data/aa.rb
217 def to_re(seq)
218   replace = {
219     'B' => '[DNB]',
220     'Z' => '[EQZ]',
221     'J' => '[ILJ]',
222     'X' => '[ACDEFGHIKLMNPQRSTVWYUOX]',
223   }
224   replace.default = '.'
225 
226   str = seq.to_s.upcase
227   str.gsub!(/[^ACDEFGHIKLMNPQRSTVWYUO]/) { |aa|
228     replace[aa]
229   }
230   Regexp.new(str)
231 end
weight(x = nil) click to toggle source
    # File lib/bio/data/aa.rb
110 def weight(x = nil)
111   return WEIGHT unless x
112 
113   if x.length > 1
114     total = 0.0
115     x.each_byte do |byte|
116       aa = byte.chr.upcase
117       if WEIGHT[aa]
118         total += WEIGHT[aa]
119       else
120         raise "Error: invalid amino acid '#{aa}'"
121       end
122     end
123     total -= NucleicAcid.weight[:water] * (x.length - 1)
124   else
125     WEIGHT[x]
126   end
127 end