Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 40 lines (34 sloc) 1.007 kB
# 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
Jump to Line
Something went wrong with that request. Please try again.