1 # The Computer Language Shootout
2 # http://shootout.alioth.debian.org/
4 # contributed by jose fco. gonzalez
5 seq
= STDIN.readlines
.join
8 seq
.gsub
!(/>.*\n|\n/,"")
13 /[cgt]gggtaaa|tttaccc[acg]/i
,
14 /a[act]ggtaaa|tttacc[agt]t/i
,
15 /ag[act]gtaaa|tttac[agt]ct/i
,
16 /agg[act]taaa|ttta[agt]cct/i
,
17 /aggg[acg]aaa|ttt[cgt]ccct/i
,
18 /agggt[cgt]aa|tt[acg]accct/i
,
19 /agggta[cgt]a|t[acg]taccct/i
,
20 /agggtaa[cgt]|[acg]ttaccct/i
21 ].each
{|f
| puts
"#{f.source} #{seq.scan(f).size}" }
24 'B' => '(c|g|t)', 'D' => '(a|g|t)', 'H' => '(a|c|t)', 'K' => '(g|t)',
25 'M' => '(a|c)', 'N' => '(a|c|g|t)', 'R' => '(a|g)', 'S' => '(c|t)',
26 'V' => '(a|c|g)', 'W' => '(a|t)', 'Y' => '(c|t)'
27 }.each
{ |f
,r
| seq
.gsub
!(f
,r
) }