| Module | Bio::NucleicAcid::Data |
| In: |
lib/bio/data/na.rb
|
| NAMES | = | { 'y' => '[tc]', 'r' => '[ag]', 'w' => '[at]', 's' => '[gc]', 'k' => '[tg]', 'm' => '[ac]', 'b' => '[tgc]', 'd' => '[atg]', 'h' => '[atc]', 'v' => '[agc]', 'n' => '[atgc]', 'a' => 'a', 't' => 't', 'g' => 'g', 'c' => 'c', 'u' => 'u', 'A' => 'Adenine', 'T' => 'Thymine', 'G' => 'Guanine', 'C' => 'Cytosine', 'U' => 'Uracil', 'Y' => 'pYrimidine', 'R' => 'puRine', 'W' => 'Weak', 'S' => 'Strong', 'K' => 'Keto', 'M' => 'aroMatic', 'B' => 'not A', 'D' => 'not C', 'H' => 'not G', 'V' => 'not T', } |
IUPAC code
|
|
| WEIGHT | = | { # Calculated by BioPerl's Bio::Tools::SeqStats.pm :-) 'a' => 135.15, 't' => 126.13, 'g' => 151.15, 'c' => 111.12, 'u' => 112.10, :adenine => 135.15, :thymine => 126.13, :guanine => 151.15, :cytosine => 111.12, :uracil => 112.10, :deoxyribose_phosphate => 196.11, :ribose_phosphate => 212.11, :hydrogen => 1.00794, :water => 18.015, } |
# File lib/bio/data/na.rb, line 160
160: def to_re(seq, rna = false)
161: replace = {
162: 'y' => '[tcy]',
163: 'r' => '[agr]',
164: 'w' => '[atw]',
165: 's' => '[gcw]',
166: 'k' => '[tgk]',
167: 'm' => '[acm]',
168: 'b' => '[tgcyskb]',
169: 'd' => '[atgrwkd]',
170: 'h' => '[atcwmyh]',
171: 'v' => '[agcmrsv]',
172: 'n' => '[atgcyrwskmbdhvn]'
173: }
174: replace.default = '.'
175:
176: str = seq.to_s.downcase
177: str.gsub!(/[^atgcu]/) { |na|
178: replace[na]
179: }
180: if rna
181: str.tr!("t", "u")
182: end
183: Regexp.new(str)
184: end
# File lib/bio/data/na.rb, line 117
117: def weight(x = nil, rna = nil)
118: if x
119: if x.length > 1
120: if rna
121: phosphate = WEIGHT[:ribose_phosphate]
122: else
123: phosphate = WEIGHT[:deoxyribose_phosphate]
124: end
125: hydrogen = WEIGHT[:hydrogen]
126: water = WEIGHT[:water]
127:
128: total = 0.0
129: x.each_byte do |byte|
130: base = byte.chr.downcase
131: if WEIGHT[base]
132: total += WEIGHT[base] + phosphate - hydrogen * 2
133: else
134: raise "Error: invalid nucleic acid '#{base}'"
135: end
136: end
137: total -= water * (x.length - 1)
138: else
139: WEIGHT[x.to_s.downcase]
140: end
141: else
142: WEIGHT
143: end
144: end