in reply to Re^3: merging dna sequences
in thread merging dna sequences

would this still work for more than 2 strings

As long as the ambiguous bases are in distinct positions, yes.

In the general case, you can then write:

my @s = ( "AYGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTTA", "ACGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTKA", "ACGTACTAGWCTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTTA", "ACGTACTAGACTACAGACTACAGMCATCTACAGACTCATCAGCAGCATATTTA", "ACGTACTAGACTACAGACTACAGACATCTACAGACTCATRAGCAGCATATTTA", # ... ); my $m = shift @s; for my $s (@s) { my $m_ = $m; $m_ =~ tr/ACGT/\0/c; my $s_ = $s; $s_ =~ tr/ACGT/\0/c; $m = $m ^ $m_ ^ $s ^ $s_ | $m_ & $s_; } say $m; # AYGTACTAGWCTACAGACTACAGMCATCTACAGACTCATRAGCAGCATATTKA ^ ^ ^ ^ ^

(P.S., sorry — meant to reply to garyboyd... )

Replies are listed 'Best First'.
Re^5: merging dna sequences
by garyboyd (Acolyte) on Nov 10, 2011 at 16:07 UTC

    Thanks Eliya that is now working perfectly!