X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=code_ruby%2Flib%2Fmaasha%2Fgenbank.rb;h=9635efd69f92971b6cac9ab54c3331885c77ee28;hb=a30677c14f1738f6a76e8c12f2e732cdef9958d6;hp=d444b4b7bfb2f301f5eb86425bce84bf3443bc25;hpb=471889816720cc10e68f9b9a31a5fc9b6732a23b;p=biopieces.git diff --git a/code_ruby/lib/maasha/genbank.rb b/code_ruby/lib/maasha/genbank.rb index d444b4b..9635efd 100644 --- a/code_ruby/lib/maasha/genbank.rb +++ b/code_ruby/lib/maasha/genbank.rb @@ -68,7 +68,7 @@ class Genbank < Filesys block.chomp!("//" + $/ ) - entry = block.split $/ + entry = block.tr("\r", "\n").split $/ return nil if entry.empty? @@ -81,13 +81,13 @@ class Genbank < Filesys i = @entry.size j = i - 1 - while @entry[j] and @entry[j] !~ /^[A-Z]/ + while @entry[j] and @entry[j] =~ /^\s+\d/ j -= 1 end seq = @entry[j + 1 .. i].join.delete(" 0123456789") - Seq.new(nil, seq, "dna") if seq + Seq.new(seq: seq, type: :dna) if seq end # Method to get the base keys from Genbank entry and return these @@ -109,7 +109,7 @@ class Genbank < Filesys j += 1 end - if keys.has_key? key.to_sym + if keys[key.to_sym] keys[key.to_sym] << ";" + val else keys[key.to_sym] = val @@ -147,7 +147,7 @@ class GenbankFeatures def each while @entry[@i] and @entry[@i] !~ /^ORIGIN/ - if @entry[@i] =~ /^\s{5}([A-Za-z_-]+)/ + if @entry[@i] =~ /^\s{5}([53'A-Za-z_-]+)/ if want_feat? $1 record = {} @@ -155,7 +155,7 @@ class GenbankFeatures @j = @i + 1 - while @entry[@j] and @entry[@j] !~ /^(\s{21}\/|\s{5}[A-Za-z_-]|[A-Z])/ + while @entry[@j] and @entry[@j] !~ /^(\s{21}\/|\s{5}[53'A-Za-z_-]|[A-Z])/ loc << @entry[@j].lstrip @j += 1 end @@ -181,7 +181,7 @@ class GenbankFeatures quals = {} k = 0 - while @entry[@j] and @entry[@j] !~ /^\s{5}[A-Za-z_-]|^[A-Z]/ + while @entry[@j] and @entry[@j] !~ /^\s{5}[53'A-Za-z_-]|^[A-Z]/ if @entry[@j] =~ /^\s{21}\/([^=]+)="([^"]+)/ qual = $1 val = $2 @@ -189,7 +189,7 @@ class GenbankFeatures if want_qual? qual k = @j + 1 - while @entry[k] and @entry[k] !~ /^(\s{21}\/|\s{5}[A-Za-z_-]|[A-Z])/ + while @entry[k] and @entry[k] !~ /^(\s{21}\/|\s{5}[53'A-Za-z_-]|[A-Z])/ val << @entry[k].lstrip.chomp('"') k += 1 end