一致序列和概要信息
作者:L. Grondin
寻找最可能的共同祖先
http://rosalind.info/problems/cons/
示例输入
ATCCAGCT GGGCAACT ATGGATCT AAGCAACC TTGGAACT ATGCCATT ATGGCACT
示例输出
ATGCAACT A: 5 1 0 0 5 5 0 0 C: 0 0 1 4 2 0 6 1 G: 1 1 6 3 0 1 0 0 T: 1 5 0 0 0 1 1 6
源代码: cons-grondilu.pl
use v6; my @default-data = qw{ ATCCAGCT GGGCAACT ATGGATCT AAGCAACC TTGGAACT ATGCCATT ATGGCACT }; my \N = @default-data.pick.chars; my %profile; %profile{$_} = [0 xx N] for <A C G T>; for @default-data[] { my @dna = .comb; my %dna-index-map = classify { @dna[$_] }, ^@dna; for %dna-index-map.kv -> $k, $v { %profile{$k}[$v[]]»++; } } my @profile = %profile<A C G T>; say my $consensus = [~] gather for ^N -> \c { my $max = max map { @profile[$_][c] }, ^4; take <A C G T>[$_] given first { @profile[$_][c] == $max }, ^4; } say [~] .key, ': ', @profile[.value] for enum <A C G T>.sort;