From 13f4ed32debae50e9212343ef65a4cf42fa8b39c Mon Sep 17 00:00:00 2001 From: martinahansen Date: Thu, 16 Dec 2010 12:17:47 +0000 Subject: [PATCH] speedup fix of max_homopol git-svn-id: http://biopieces.googlecode.com/svn/trunk@1190 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/Maasha/lib/seq.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code_ruby/Maasha/lib/seq.rb b/code_ruby/Maasha/lib/seq.rb index a6f071d..23e6965 100644 --- a/code_ruby/Maasha/lib/seq.rb +++ b/code_ruby/Maasha/lib/seq.rb @@ -165,12 +165,12 @@ class Seq # Method that returns the length of the longest homopolymeric stretch # found in a sequence. def homopol_max - max = 0 + max = 1 - if self.seq - self.seq.upcase.scan(/[A]+|[T]+|[G]+|[C]+|[N]+/) do |match| - max = [match.size, max].max - end + 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 end max -- 2.39.5