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

When comparing many strings against many strings (not just two), performance actually might matter.

On my machine, your substr method takes 2.65 secs, while the XOR method I suggested above takes only 0.12 secs (for the same data), i.e. it's roughly 20 times as fast.

  • Comment on Re^2: mismatching characters in dna sequence

Replies are listed 'Best First'.
Re^3: mismatching characters in dna sequence
by prbndr (Acolyte) on Dec 30, 2011 at 04:44 UTC
    eliya -- is your transliteration correct? the results differ from the other code snippets already posted.

      AFAICT, they only differ in being zero- vs. one-based, i.e. in my output "4" means 4th character. Both can be trivially converted to one another by adding or subtracting 1.  Or which difference are you referring to?

        in some very rare cases i have a conversion from an A->N. the N is just another character. the other code snippets catch this type of conversion whereas your code calls it a G->A. why is this the case?