in reply to Maximal Parsimony Problem
I have no understanding of the problem domain so the following code is not a solution to your actual problem, but is an alternative way of finding changes between adjacent strings in a list and counting those changes by column.
use strict; use warnings; my $sites = [ 'CGGCGGAAAACTGTCCTCCGTGC', # mouse 'CGACGGAACATTCTCCTCCGCGC', # rat 'CGACGGAATATTCCCCTCCGTGC', # human 'CGACGGAAGACTCTCCTCCGTGC', # chimp ]; my @val = my_parsimony ($sites); print @val; sub my_parsimony { my ($sites) = @_; my $lastSite = $sites->[0]; my @mincol = (0) x length $lastSite; for my $nextSite (@$sites) { my $changes = $lastSite ^ $nextSite; $lastSite = $nextSite; next unless $changes =~ s/[^\0]/+/g; my $pos = 0; ++$mincol[$pos++] while -1 != ($pos = index $changes, '+', $po +s); } return @mincol; }
Prints:
00100000302012000000200
|
|---|