Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 40 lines (34 sloc) 1.007 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
# The Computer Language Shootout
# http://shootout.alioth.debian.org/
#
# contributed by jose fco. gonzalez
# Adapted for the Ruby Benchmark Suite.

Bench.run [20] do |n|
  n.times do
    fname = File.dirname(__FILE__) + "/fasta.input"
    seq = File.read(fname)
    ilen = seq.size

    seq.gsub!(/>.*\n|\n/,"")
    clen = seq.length

    [
    /agggtaaa|tttaccct/i,
    /[cgt]gggtaaa|tttaccc[acg]/i,
    /a[act]ggtaaa|tttacc[agt]t/i,
    /ag[act]gtaaa|tttac[agt]ct/i,
    /agg[act]taaa|ttta[agt]cct/i,
    /aggg[acg]aaa|ttt[cgt]ccct/i,
    /agggt[cgt]aa|tt[acg]accct/i,
    /agggta[cgt]a|t[acg]taccct/i,
    /agggtaa[cgt]|[acg]ttaccct/i
    ].each {|f| puts "#{f.source} #{seq.scan(f).size}" }

    {
    'B' => '(c|g|t)', 'D' => '(a|g|t)', 'H' => '(a|c|t)', 'K' => '(g|t)',
    'M' => '(a|c)', 'N' => '(a|c|g|t)', 'R' => '(a|g)', 'S' => '(c|t)',
    'V' => '(a|c|g)', 'W' => '(a|t)', 'Y' => '(c|t)'
    }.each { |f,r| seq.gsub!(f,r) }

    puts
    puts ilen
    puts clen
    puts seq.length
  end
end
Something went wrong with that request. Please try again.