----- Original Message ----- From: ""Chris Charley"" <[EMAIL PROTECTED]>
Newsgroups: perl.beginners
To: <beginners@perl.org>
Sent: Thursday, April 27, 2006 5:07 PM
Subject: Re: Mismatch Positions of Two Ambiguous Strings



----- Original Message ----- From: "Wijaya Edward" <[EMAIL PROTECTED]>
Subject: Mismatch Positions of Two Ambiguous Strings



Hi,
I have two strings that I want to compute the number of mismatches between them. These two strings are of the "same" size. Let's call them 'source' string and 'target' string. Now, the problem is that the 'source' and 'target' string may come in ambiguous form, meaning that in one position they may contain more than 1 (upto 4) characters. The ambiguous position is marked with square bracketed [ATCG] region.
The example is as follows:

Example 1 (where the source is ambiguous):

my $source1  = '[TCG]GGGG[AT]'; # ambiguous
my $target1   = 'AGGGGC'; # No of mismatch = 2  on position 1 and 6
my $target2  = 'TGGGGC'; # No of mismatch = 1  on position 6 only


Example 2 (where the source is NOT ambiguous):

my $source2  =  'TGGGGT'; # not-ambiguous
my $target1  = 'AGGGGC'; # No of mismatch = 2  on position 1 and 6
my $target3  = 'TGGGGT'; # No of mismatch = 0  all position matches


Example 3 (where both source and target are ambiguous)
my $source1  = '[TCG]GGGG[AT]'; # ambiguous
my $target1 = 'AGGGG[CT]'; # ambiguous, no of mismatch = 1 only at position 1

For example I can use bitwise operator to do it.

I have no problem when dealing with Example 1 and 2 above.
But I'm stuck with example 3, where both source and target is ambiguous.


Here is the current snippet I have, which doesn't do the job:

[snip]

Hello Edward

This code will handle ambiguous cases in the source, target or both or neither. I 'lifted' the expand_fasta funtion mostly from Perlmonks, (the link is given in the comments on that section of code). I that code is pretty much bulletproof. I tested all your cases and came up with good answers, as well as additional cases I constructed (where all characters mismatched, for example).

This did not provide the positions that the mismatches occurred at, but I didn't think that was what you were after. If it is, the mismatches() function would need to be different.

Chris

Forget my last post. D Bollinger's solution is succinct and to the point!

Chris



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to