reverse-complement Matz's Ruby #2 program
source code
# The Computer Language Benchmarks Game
# https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
#
# Contributed by Peter Bjarke Olsen
# Modified by Doug King
# Modified by Joseph LaFata
seq=""
def revcomp(seq)
seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')
stringlen=seq.length-1
0.step(stringlen,60) {|x| print seq[x,60] , "\n"}
end
STDIN.each do |line|
if line.include? '>'
if !seq.empty?
revcomp(seq)
seq=""
end
puts line
else
line.chomp!
seq << line
end
end
revcomp(seq)
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
ruby 1.8.7
(2014-01-28
patchlevel 376)
[x86_64-linux]
Sat, 08 Jun 2024 00:57:10 GMT
COMMAND LINE:
/usr/share/rvm/rubies/ruby-1.8.7-head/bin/ruby revcomp.mri-2.mri 0 < revcomp-input100000001.txt
(TRUNCATED) PROGRAM OUTPUT:
>ONE Homo sapiens alu
CTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTC
GCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTC
AAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGC
CCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCT
CGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGG
CGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAG
TGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCT
GCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTT
GTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCC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