in reply to Re^2: How can I get correct result in counting 3-letter words?
in thread How can I get correct result in counting 3-letter words?

Humm, you didn't actually use my code. (Not that the results would be visibly different.)

Your suggestion to remove the offending letters is broken if said letters can appear anywhere but the beginning and end of the string. "AAAGNTTT" should give "AAA", "TTT", but you're algorithm would give "AAA" and "GTT".

  • Comment on Re^3: How can I get correct result in counting 3-letter words?

Replies are listed 'Best First'.
Re^4: How can I get correct result in counting 3-letter words?
by aaron_baugher (Curate) on Apr 23, 2012 at 02:25 UTC

    True, I was just curious about the performance difference between substr and /.../g. And I don't know this bioinformatics stuff well enough to know what's a valid group and what isn't, and whether you can assume things will break on the right boundaries (or what to do with extra letters if they don't). But doesn't your final solution with /.../gs give "AAA" and "GNT"? Should it be /[ACGT]{3}/gs to make it skip to the next valid set of three?

    Aaron B.
    My Woefully Neglected Blog, where I occasionally mention Perl.