]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/genbank.rb
changed Seq.new argument to hash
[biopieces.git] / code_ruby / lib / maasha / genbank.rb
index d444b4b7bfb2f301f5eb86425bce84bf3443bc25..9635efd69f92971b6cac9ab54c3331885c77ee28 100644 (file)
@@ -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