Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[rosalind] RSTR
  • Loading branch information
grondilu committed Dec 7, 2012
1 parent 85f27f2 commit a19c36f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rosalind/rstr-grondilu.pl
@@ -0,0 +1,14 @@
use v6;

my @data = $*IN.lines;
my ($N, $gc-content) = @data.shift.split: " ";
my $dna = @data.shift;

sub prob(:$dna, :$gc-content) {
1/2**$dna.chars * [*] map { $_ eq 'G'|'C' ?? $gc-content !! (1 - $gc-content) }, $dna.comb
}

printf "%.3f", 1 - exp ($N * log(1-prob :$dna, :$gc-content));

# vim: ft=perl6

0 comments on commit a19c36f

Please sign in to comment.