Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git] / bench / yarv / bm_so_reverse_complement.rb
blob5cf1a86adac0bcb775f5d7c9a11223fc331e9ddf
1 #!/usr/bin/ruby\r
2 # The Great Computer Language Shootout\r
3 # http://shootout.alioth.debian.org/\r
4 #\r
5 # Contributed by Peter Bjarke Olsen\r
6 # Modified by Doug King\r
7 \r
8 seq=Array.new\r
9 \r
10 def revcomp(seq)\r
11   seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')\r
12   stringlen=seq.length\r
13   0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"}\r
14 end\r
16 input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb')\r
18 while input.gets\r
19   if $_ =~ />/\r
20     if seq.length != 0\r
21       revcomp(seq.join)\r
22       seq=Array.new\r
23     end\r
24     puts $_\r
25   else\r
26     $_.sub(/\n/,'')\r
27     seq.push $_\r
28   end\r
29 end\r
30 revcomp(seq.join)\r