<!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> for my $base (qw{A C G T}) {</tt><br>
<tt> my $fuzzycode = $mid;</tt><br>
<tt> my $prebase_i = $i - 1;</tt><br>
<tt> my $postbase_i = $mid_length - $i;</tt><br>
<tt> $fuzzycode =~ s{</tt><br>
<tt> ^([ACGT]{$prebase_i}) #capture bases, if any,
before current base</tt><br>
<tt> ([ACGT]) #current base</tt><br>
<tt> ([ACGT]{$postbase_i})$} #capture bases, if any,
after current base</tt><br>
<tt> {$1$base$3}xms; #replace current base with
$base</tt><br>
<tt> push @{ $mid_pools{$fuzzycode} }, $pool_name;</tt><br>
<tt> }</tt><br>
<tt>}</tt><br>
</blockquote>
Actually, I don't see any problem with this code.</blockquote>
<br>
Readability is the issue. IMHO, the author is using a sledgehammer
when a peen hammer would do. Speedups are not the issue. 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>
for my $base (qw{A C G T}) {<br>
my $fuzzycode = $mid;<br>
substr($fuzzycode, $i, 1, $base);<br>
push @{ $mid_pools{$fuzzycode} }, $pool_name;<br>
print "$fuzzycode\n";<br>
}<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. 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>