-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.cr
51 lines (44 loc) · 1.03 KB
/
test.cr
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
40
41
42
43
44
45
46
47
48
49
50
51
seq = IO::Memory.new
ilen = 0
STDIN.each_line do |line|
ilen += line.bytesize + 1
seq << line.chomp unless line.starts_with? '>'
end
seq = seq.to_s
clen = seq.bytesize
def run(seq, clen, ilen)
[
/agggtaaa|tttaccct/,
/[cgt]gggtaaa|tttaccc[acg]/,
/a[act]ggtaaa|tttacc[agt]t/,
/ag[act]gtaaa|tttac[agt]ct/,
/agg[act]taaa|ttta[agt]cct/,
/aggg[acg]aaa|ttt[cgt]ccct/,
/agggt[cgt]aa|tt[acg]accct/,
/agggta[cgt]a|t[acg]taccct/,
/agggtaa[cgt]|[acg]ttaccct/,
].each { |f| puts "#{f.source} #{seq.scan(f).size}" }
hash = {
"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)",
}
t = Time.local
seq = seq.gsub(/B|D|H|K|M|N|R|S|V|W|Y/, hash)
puts
puts ilen
puts clen
puts seq.size
STDERR.puts "time(#{(Time.local - t).to_f})"
end
t = (ARGV[0]? || 5).to_i
STDERR.puts "started\t#{Process.pid}"
t.times { run(seq, clen, ilen) }