<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 10/20/2010 08:59 AM, Rick Westerman wrote:
<blockquote cite="mid:4CBEE7AF.2080309@purdue.edu" type="cite">
  <meta http-equiv="Context-Type"
 content="text/html; charset=ISO-8859-1">
  <br>
  <blockquote cite="mid:4CBEE486.6000608@purdue.edu" type="cite"> The
code in question (with extra comments):<br>
    <tt><br>
    </tt>
    <blockquote><tt>for my $i ( 1 .. $mid_length ) {</tt><br>
      <tt>&nbsp;&nbsp;&nbsp; for my $base (qw{A C G T}) {</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $fuzzycode&nbsp; = $mid;</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $prebase_i&nbsp; = $i - 1;</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $postbase_i = $mid_length - $i;</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $fuzzycode =~ s{</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^([ACGT]{$prebase_i})&nbsp;&nbsp;&nbsp;&nbsp; #capture bases, if any,
before current base</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ([ACGT])&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; #current base</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ([ACGT]{$postbase_i})$}&nbsp; #capture bases, if any,
after current base</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {$1$base$3}xms;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #replace current base with
$base</tt><br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push @{ $mid_pools{$fuzzycode} }, $pool_name;</tt><br>
      <tt>&nbsp;&nbsp;&nbsp; }</tt><br>
      <tt>}</tt><br>
    </blockquote>
Actually, I don't see any problem with this code.</blockquote>
  <br>
Readability is the issue.&nbsp;&nbsp; IMHO, the author is using a sledgehammer
when a peen hammer would do.&nbsp; Speedups are not the issue.&nbsp; The
following is much more clear ... especially to the the novice Perl
programmer who is not that familiar with regexes.<br>
  <br>
  <br>
for my $i ( 0 .. $mid_length - 1) {<br>
&nbsp;&nbsp;&nbsp; for my $base (qw{A C G T}) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $fuzzycode = $mid;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; substr($fuzzycode, $i, 1, $base);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push @{ $mid_pools{$fuzzycode} }, $pool_name;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "$fuzzycode\n";<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
  <br>
  <br>
Explaining substr should be a piece of cake compared to regex captures
and replacements.<br>
</blockquote>
<br>
And, I hope this is obvious, the extra print statement is my code above
was just for verification purposes so that I could make sure that my
code did the same as the original regex code.&nbsp; If my code fragment was
to be put in the RADpools code then the print statement would, of
course, be removed.<br>
<br>
<div class="moz-signature">-- <br>
Rick Westerman <a class="moz-txt-link-abbreviated" href="mailto:westerman@purdue.edu">westerman@purdue.edu</a>
Bioinformatics specialist at the Genomics Facility.
Phone: (765) 494-0505 FAX: (765) 496-7255
Department of Horticulture and Landscape Architecture
625 Agriculture Mall Drive
West Lafayette, IN 47907-2010
Physically located in room S049, WSLR building
</div>
</body>
</html>