"be consistent" | |
PerlMonks |
Re^2: calculation of charged amino acidsby Cristoforo (Curate) |
on Jul 23, 2013 at 20:24 UTC ( [id://1045952]=note: print w/replies, xml ) | Need Help?? |
The 'g' switch on the three regular expressions shouldn't be there.
If $aa =~/[DNEQ]/ig matches, then the following match, $aa=~/[KRH]/ig, fails (and the pos is reset so that the last expression, $aa=~/[DNEQKRH]/ig will match. However, if $aa=~/[KRH]/ig matches, then pos will be '1' and the following match, $aa=~/[DNEQKRH]/ig will fail because it will attempt to match beginning at pos 1 instead of pos 0. You can see this in the following code snippet. This prints
This, in effect, counts the acid base in the neutral count but not the base. He probably wants the neutral count to be other than the acid or base, in which case, that regular expression should be, $aa=~/[^DNEQKRH]/i, negating the class. Without the 'g' switch, and negating the neutral class, the output would look like: Chris
In Section
Seekers of Perl Wisdom
|
|