Bioinformatics/Global alignment: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: more idiomatic)
m (→‎{{header|Raku}}: Thanks SqrtNegInf for the Rakuish uplifts ; some obsessive but insignificant changes ; it seems a little bit slower with the default topic array variable ?)
Line 515: Line 515:


sub printCounts(\seq) {
sub printCounts(\seq) {
my %bases = seq.comb.Bag ;
my $bases = seq.comb.Bag ;
say "\nNucleotide counts for ", seq, " :";
say "\nNucleotide counts for ", seq, " :";
say %bases.kv, " and total length = ", %bases.values.sum
say $bases.kv, " and total length = ", $bases.total
}
}


Line 524: Line 524:
S1 = s1.substr: $offset ;
S1 = s1.substr: $offset ;
with S1.index(s2.substr(0,1)) -> $p { $offset += $p } else { return False }
with S1.index(s2.substr(0,1)) -> $p { $offset += $p } else { return False }
S1 = s1.substr: $offset ;
return s1.chars - $offset if s2.starts-with: s1.substr: $offset
return s1.chars - $offset if s2.starts-with: S1
}
}
}
}
Line 537: Line 536:


sub shortestCommonSuperstring {
sub shortestCommonSuperstring {
my @ss = deduplicate @_ ;
my \ß = $ = [~] my @ss = deduplicate @_ ; # ShortestSuper
my \ß = $ = [~] @ss ; # ShortestSuper
for @ss.permutations -> @perm {
for @ss.permutations -> @perm {
my \sup = $ = @perm[0];
my \sup = $ = @perm[0];
for @perm.rotor(2 => -1) -> @duo {
for @perm.rotor(2 => -1) { sup ~= @_[1].substr: stringCentipede |@_ }
my \overlapPos = stringCentipede |@duo[0,1];
sup ~= @duo[1].substr: overlapPos;
}
ß = sup if sup.chars < ß.chars ;
ß = sup if sup.chars < ß.chars ;
}
}