]> git.donarmstrong.com Git - biopieces.git/commitdiff
speedup fix of max_homopol again
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 16 Dec 2010 12:24:36 +0000 (12:24 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 16 Dec 2010 12:24:36 +0000 (12:24 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1191 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/Maasha/lib/seq.rb

index 23e69658782beb3f8b66d1f5924e287c7f0a08f4..696e07080801280b2f970d42bddd9d1faaa8d1d9 100644 (file)
@@ -164,13 +164,11 @@ class Seq
 
   # Method that returns the length of the longest homopolymeric stretch
   # found in a sequence.
-  def homopol_max
-    max = 1
-
+  def homopol_max(max = 1)
     return 0 if self.seq.nil? or self.seq.empty?
 
     self.seq.upcase.scan(/A{#{max},}|T{#{max},}|G{#{max},}|C{#{max},}|N{#{max},}/) do |match|
-      max = [match.size, max].max
+      max = match.size > max ? match.size : max
     end
 
     max