Commits

Sarah Richardson committed 385faa2

match random function stop finding to changes in Codons.pm; update code to match standards

Comments (0)

Files changed (1)

lib/Bio/GeneDesign/Random.pm

 
   if ($stopswit)
   {
-    my $stoplist = _find_in_frame($DNA, "*", $codon_t);
-    foreach my $pos (@$stoplist)
+    my $stophsh = _find_in_frame($DNA, "*", $codon_t);
+    while (scalar keys %{$stophsh})
     {
-      my $bit = substr($DNA, (($pos + 1) * 3) - 3, 3);
-      #substr($DNA, (($pos + 1) * 3) - 3, 3) = scalar reverse($bit);
-      substr($DNA, (($pos + 1) * 3) - 3, 3, scalar reverse($bit));
-      if (int(rand(1)+.5) == 1)
+      foreach my $pos (keys %{$stophsh})
       {
-        my $bat = substr($DNA, (($pos + 1) * 3) - 2, 2);
-        #substr($DNA, (($pos + 1) * 3) - 2, 2) = scalar reverse($bat);
-        substr($DNA, (($pos + 1) * 3) - 2, 2, scalar reverse($bat));
+        my $bit = substr $DNA, $pos, 3;
+        substr $DNA, $pos, 3, scalar reverse $bit;
+        if (int(rand(1)+.5) == 1)
+        {
+          my $bat = substr $DNA, $pos, 2;
+          substr $DNA, $pos, 2, scalar reverse$bat;
+        }
       }
+      $stophsh = _find_in_frame($DNA, "*", $codon_t);
     }
   }
   return $DNA;