Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^6: Longest common substring with N mismatches

by Anonymous Monk
on Sep 11, 2017 at 17:09 UTC ( #1199137=note: print w/replies, xml ) Need Help??


in reply to Re^5: Longest common substring with N mismatches
in thread Longest common substring with N mismatches

Sorry, I meant to write k-mer before :)
One example could be the following (using also the node you mentioned as input):
$str1='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; $str2='RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAABAAZZZZZZZ';

In this case, the whole $str1 should much because it only has 1 mismatch (assuming the user sets the allowed #mismatches to 1) and not only the AAAAA before the B.

Replies are listed 'Best First'.
Re^7: Longest common substring with N mismatches
by LanX (Bishop) on Sep 11, 2017 at 17:17 UTC
    Looks like the same solution fits, xor both strings at different positions and count the longest runs of zeros tolerating n non zeros in between, probably with a composed regex.

    See ^ in perlop#Bitwise-Or-and-Exclusive-Or

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re^7: Longest common substring with N mismatches
by Anonymous Monk on Sep 11, 2017 at 17:14 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199137]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-11-23 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (327 votes). Check out past polls.

    Notices?