#! perl -slw use strict; use Benchmark qw[ cmpthese ]; our $seq = "ACGGGAGGACGGGAAAATTACTACGGCATTAGCacgggaggacgggaaaattactacggcattagc"; our %xref = ( A => 'T', C => 'G', G => 'C', T => 'A', a => 't', c => 'g', g => 'c', t => 'a', ); our %rc = ( A => q{T}, T => q{A}, C => q{G}, G => q{C}, ); cmpthese -1, { tr => q[ ( my $revcmp = reverse $seq ) =~tr[ACGTacgt][tgcaTGCA]; ], davido => q[ my $seq = $seq; for(my $ix = 0; $ix < length $seq; ++$ix ) { substr( $seq, $ix, 1, $xref{ substr( $seq, $ix, 1 ) } ); } my $reverse = reverse($seq); ], atcroft => q[ my $complement; my @letters = split //, $seq; while ( @letters ) { my $l = uc pop @letters; $complement .= $rc{$l}; } ], hdb => q[ my $rev=''; my $n = length $seq; while( $n-- ){ $rev .= $_ for map chr( $_ & 2 ? $_^4: $_^21 ), ord substr $seq, $n, 1 } ], } __END__ C:\test>junk60 Rate hdb atcroft davido tr hdb 9827/s -- -35% -71% -100% atcroft 15077/s 53% -- -55% -99% davido 33822/s 244% 124% -- -99% tr 2679052/s 27163% 17669% 7821% --