This is my current working code. Its purpose is to find a string of amino acids that match a regular expression and put the matching string as well as what is found before and after the matching string in 3 separate scalars.
if($sequence[1] =~ m/^(.*)$reg(.*)$/i){
$aligned[$posCount][0] = $1;
$aligned[$posCount][1] = $2;
$aligned[$posCount][2] = $3;
}
$reg used to be a regular expression contained in a single set of parens.
Example:
$reg = (K[STN]\w\w[GST]\w{1,2}[KRA]R[IVF]);
But now I have set it up to automatically place parens around \w of variable length, so the previous $reg would now be:
$reg = (K[STN]\w\w[GST])(\w{1,2})([KRA]R[IVF]);
Such that a string searched against a regular expression with 1 variable length component would be split into 5 pieces. The stuff found before the match, constant length match1, variable length match, constant length match2, the stuff found after the match. I want to make it so a user could have any number of variable length regions.
Is there a method with which I could add recursion?
if($sequence[1] =~ m/^(.*)$reg(.*)$/i){
for(my $x = 0; $x < $numInsertionDeletes; $x++){
$aligned[$posCount][$x] = ????????;
}
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.