Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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' 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.

Is there an efficient way I can compute the number of mismatch between "source" and "target", of the above situation? 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
I have no problem when dealing when 'source' string is not ambigous like this
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
For example I can use bitwise operator to do it. But for ambigous case I'm lost.

PS: "target" string can be assumed to be never ambiguous.

Regards,
Edward

In reply to Mismatch Positions of Ambiguous String by monkfan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found