From 0ed40d0be2b5f54a778f8158557160efe90c818b Mon Sep 17 00:00:00 2001 From: martinahansen Date: Mon, 19 Sep 2011 11:43:36 +0000 Subject: [PATCH] fixed grave bug in genbank.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1527 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/lib/maasha/genbank.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/code_ruby/lib/maasha/genbank.rb b/code_ruby/lib/maasha/genbank.rb index a6ec292..dcdfbe3 100644 --- a/code_ruby/lib/maasha/genbank.rb +++ b/code_ruby/lib/maasha/genbank.rb @@ -24,6 +24,7 @@ require 'maasha/seq' require 'maasha/filesys' +require 'pp' # Error class for all exceptions to do with Genbank. class GenbankError < StandardError; end @@ -135,28 +136,27 @@ class Genbank < Filesys end class GenbankFeatures - @@i = 0 - @@j = 0 - def initialize(entry, hash_feats, hash_quals) @entry = entry @hash_feats = hash_feats @hash_quals = hash_quals + @i = 0 + @j = 0 end def each - while @entry[@@i] and @entry[@@i] !~ /^ORIGIN/ - if @entry[@@i] =~ /^\s{5}([A-Za-z_-]+)/ + while @entry[@i] and @entry[@i] !~ /^ORIGIN/ + if @entry[@i] =~ /^\s{5}([A-Za-z_-]+)/ if want_feat? $1 record = {} - feat, loc = @entry[@@i].lstrip.split(/\s+/, 2) + feat, loc = @entry[@i].lstrip.split(/\s+/, 2) - @@j = @@i + 1 + @j = @i + 1 - while @entry[@@j] and @entry[@@j] !~ /^(\s{21}\/|\s{5}[A-Za-z_-]|[A-Z])/ - loc << @entry[@@j].lstrip - @@j += 1 + while @entry[@j] and @entry[@j] !~ /^(\s{21}\/|\s{5}[A-Za-z_-]|[A-Z])/ + loc << @entry[@j].lstrip + @j += 1 end get_quals.each_pair { |k,v| @@ -170,7 +170,7 @@ class GenbankFeatures end end - @@j > @@i ? @@i = @@j : @@i += 1 + @j > @i ? @i = @j : @i += 1 end end @@ -180,13 +180,13 @@ class GenbankFeatures quals = {} k = 0 - while @entry[@@j] and @entry[@@j] !~ /^\s{5}[A-Za-z_-]|^[A-Z]/ - if @entry[@@j] =~ /^\s{21}\/([^=]+)="([^"]+)/ + while @entry[@j] and @entry[@j] !~ /^\s{5}[A-Za-z_-]|^[A-Z]/ + if @entry[@j] =~ /^\s{21}\/([^=]+)="([^"]+)/ qual = $1 val = $2 if want_qual? qual - k = @@j + 1 + k = @j + 1 while @entry[k] and @entry[k] !~ /^(\s{21}\/|\s{5}[A-Za-z_-]|[A-Z])/ val << @entry[k].lstrip.chomp('"') @@ -201,7 +201,7 @@ class GenbankFeatures end end - k > @@j ? @@j = k : @@j += 1 + k > @j ? @j = k : @j += 1 end quals -- 2.39.2