]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/genbank.rb
added \r remove hack to genbank/embl parsers
[biopieces.git] / code_ruby / lib / maasha / genbank.rb
index d444b4b7bfb2f301f5eb86425bce84bf3443bc25..b1c9f8734a7a7f6dac1df4c7a18a3d59a62e2af1 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(nil, seq, :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