1#!/usr/bin/ruby
2# The Great Computer Language Shootout
3# http://shootout.alioth.debian.org/
4#
5# Contributed by Peter Bjarke Olsen
6# Modified by Doug King
7
8seq=Array.new
9
10def 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"}
14end
15
16input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb')
17
18while 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
29end
30revcomp(seq.join)
31