in reply to Re^2: mismatching characters in dna sequence
in thread mismatching characters in dna sequence

If you apply binary xor (exclusive-or) on the strings, you get another string as a result. This string contains the null character in places where the two strings were identical, and various other characters in positions where the two strings were different. For each tuple of letters, the result is different.
  • Comment on Re^3: mismatching characters in dna sequence

Replies are listed 'Best First'.
Re^4: mismatching characters in dna sequence
by Eliya (Vicar) on Dec 30, 2011 at 01:31 UTC
    For each tuple of letters, the result is different.

    A problem might be (depending on what exactly the OP needs) that "A" ^ "T" is the same as "T" ^ "A" (etc.), so the direction of the change (i.e. A->T or T->A) would be lost with this simple approach.

Re^4: mismatching characters in dna sequence
by prbndr (Acolyte) on Dec 30, 2011 at 01:47 UTC
    yes, i need to know the direction of change.
      You can get the information back from the strings if needed:
      use warnings; use strict; my $source="ATTCCGGG"; print "source: $source\n"; for my $str ( "ATTGCGGG", "ATACCGGC", "ACTGCGGT" , "ATCGGGGG" ) { print "string: $str\n"; my @res = unpack "c*", $source ^ $str; for my $i (grep $res[$_], 0 .. $#res) { print "$i: ", substr($source, $i, 1), "->", substr($str, $i, 1), "\n"; } }
      I am not sure how fast this is compared to the PDL solution.