Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: match and mismatch

by artist (Parson)
on Nov 14, 2008 at 09:38 UTC ( #723605=note: print w/ replies, xml ) Need Help??


in reply to match and mismatch

use Algorithm::Diff qw(diff sdiff LCS traverse_sequences); + my @seq1= split //,"1 AGCTGATCGAGCTAGTACCCTAGCTC 26"; my @seq2 =split //,"15 AGCTGATCGAGCTAGTACCCTATCTC 40"; my @diffs = diff( \@seq1, \@seq2 ); foreach (@diffs) { foreach (@{$_}) { print join " " => @{$_},"\n"; } print "\n"; }
And here is the output which shows the difference at each position if any. So on '25th' position, you have 'G' in one, and 'T' in the other.
+ 1 5 - 2 - 25 G + 25 T - 30 2 + 30 4 - 31 6 + 31 0
--Artist


Comment on Re: match and mismatch
Select or Download Code
Re^2: match and mismatch
by lima1 (Curate) on Nov 14, 2008 at 17:49 UTC
    Just for the sake of completeness: The runtime here is N^2. The identifcation of mismatches is obviously possible in N (see solutions above). But this solution is much more powerful and can identify insertions and deletions as well.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://723605]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-08-29 01:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls