Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add alternative version of revcomp problem
~18x faster by avoiding .trans() and bulk output
  • Loading branch information
gerdr committed May 8, 2012
1 parent dde18a0 commit ccbd2c0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions other/revcomp.pl
@@ -0,0 +1,22 @@
use v6;

my %trans = 'wsatugcyrkmbdhvnATUGCYRKMBDHVN'.comb Z=>
'WSTAACGRYMKVHDBNTAACGRYMKVHDBN'.comb;

my ($desc, @seq);

for lines() {
dump, $desc = $_, next if /^ \>/;
@seq.unshift(.comb.reverse.map({ %trans{$^c} // $^c }));
LAST dump;
}

sub dump {
LEAVE @seq = Nil;
return unless $desc.defined;

@seq.splice($_, 0, "\n")
for (60, 120 ...^ * >= +@seq).reverse;

say $desc, "\n", @seq.join;
}

0 comments on commit ccbd2c0

Please sign in to comment.