From: martinahansen Date: Thu, 16 Dec 2010 12:24:36 +0000 (+0000) Subject: speedup fix of max_homopol again X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8b67ce6de89caceac3cb7d1c520c14f8966bf827;p=biopieces.git speedup fix of max_homopol again git-svn-id: http://biopieces.googlecode.com/svn/trunk@1191 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/Maasha/lib/seq.rb b/code_ruby/Maasha/lib/seq.rb index 23e6965..696e070 100644 --- a/code_ruby/Maasha/lib/seq.rb +++ b/code_ruby/Maasha/lib/seq.rb @@ -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