First off, congratulations on getting the onlyIDleft.

Secondly, I think the changes you made in sub make_approximate() are the appropriate changes to make to convert it from nucleotides to amino acids.

Fourthly, I think the problem arises when you use square brackets in your original motif for matching. I ran it using the following:

my $motif = [IFVL][RK][AGST]; my $answer = make_approximate($motif, 1); print $answer, \n;

output: [(?:I(?:F(?:V(?:L][(?:R(?:K][(?:A(?:G(?:S(?:T]|.])|.T])|.ST])|.GST])|.][AGST])|.K][AGST])|.][RK][AGST])|.L][RK][AGST])|.VL][RK][AGST])|.FVL][RK][AGST])

Since [IFVL] matches a single character of I or F or V or L, if you use square brackets[IFVL], the subroutine breaks this unit apart. Instead of the output we get above, we would have wanted something like this:

(?:[IFVL](?:[RK].|.[AGST])|.[RK][AGST])

So, if you want to use square brackets, you will need to incorporate a step that checks for opening and closing of square brackets and acts differently if inside brackets. Alternatively, you could substitute in placeholders for groupings like [IFVL]. This might be better since you could have a hash key for polar amino acids, small and large hydrophobic, etc. Anyway, I’ll leave that for you to think about.


In reply to Re: Understanding a script that looks for mismatches to a regex by frozenwithjoy
in thread Understanding a script that looks for mismatches to a regex by onlyIDleft

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.