require 'maasha/seq'
require 'maasha/filesys'
+require 'pp'
# Error class for all exceptions to do with Genbank.
class GenbankError < StandardError; end
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|
end
end
- @@j > @@i ? @@i = @@j : @@i += 1
+ @j > @i ? @i = @j : @i += 1
end
end
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('"')
end
end
- k > @@j ? @@j = k : @@j += 1
+ k > @j ? @j = k : @j += 1
end
quals