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