]> git.donarmstrong.com Git - biopieces.git/commitdiff
changed fasta parse to allow leading empty lines
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 13 Dec 2013 10:37:23 +0000 (10:37 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 13 Dec 2013 10:37:23 +0000 (10:37 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2278 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/fasta.rb
code_ruby/lib/maasha/seq.rb
code_ruby/test/maasha/test_fasta.rb

index c9ce43d6d0610d1e7e69603471eaa720849d4650..971ad545582c8e82d63b3e2c3846069c87acd3b5 100644 (file)
@@ -32,7 +32,11 @@ class Fasta < Filesys
   # Method to get the next FASTA entry form an ios and return this
   # as a Seq object. If no entry is found or eof then nil is returned.
   def get_entry
-    block = @io.gets($/ + '>')
+    block = nil 
+
+    while block = @io.gets($/ + '>') and block.chomp($/ + '>').empty?
+    end
+
     return nil if block.nil?
 
     block.chomp!($/ + '>')
index c22ecec8948a0230079aacd05af1e552a168819e..9a8816dc53b47b60e764a98c184a44375dd36bff 100644 (file)
@@ -305,7 +305,7 @@ class Seq
       seq.chomp!
     end
 
-    ">" + seq_name + $/ + seq + $/
+    ">" + seq_name.to_s + $/ + seq + $/
   end
 
   # Method that given a Seq entry returns a FASTQ entry (a string).
index 3924f54a5d71b1de5a835f2a5c1a318f05011d02..2273eb05e6578ec65b1fc81012cd30dfc1e7ffbe 100755 (executable)
@@ -72,11 +72,6 @@ class FastaTest < Test::Unit::TestCase
     assert_raise(FastaError) { fasta.get_entry }
   end
 
-  test "#get_entry with leading newline raises" do
-    fasta = Fasta.new(StringIO.new("\n>test\nATCG\n"))
-    assert_raise(FastaError) { fasta.get_entry }
-  end
-
 # FIXME
 #  test "#get_entry raises on missing > in seq_name" do
 #    fasta = Fasta.new(StringIO.new("test\nATCG\n"))