随机字符串简介
作者:L. Grondin
http://rosalind.info/problems/prob/
示例输入
ACGATACAA 0.129 0.287 0.423 0.476 0.641 0.742 0.783
示例输出
-5.737 -5.217 -5.263 -5.360 -5.958 -6.628 -7.009
源代码: prob-grondilu.pl
use v6; my @sample = "ACGATACAA 0.129 0.287 0.423 0.476 0.641 0.742 0.783".split: "\n"; sub MAIN($input-file = Nil) { my ($dna, $gc-content-string) = $input-file ?? $input-file.IO.lines !! @sample; my @A = $gc-content-string.split(" "); my @B = map { log(prob :$dna, :gc-content($_))/log(10) }, @A; say "{@B».fmt: "%.3f"}"; } sub prob(:$dna, :$gc-content) { 1/2**$dna.chars * [*] map { $_ eq 'G'|'C' ?? $gc-content !! (1 - $gc-content) }, $dna.comb; }