]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/fastq.rb
polish of fastq
[biopieces.git] / code_ruby / lib / maasha / fastq.rb
index c57f4eb9165bb3423fccc22590f89550a8125c69..8789899e50d796406657b10727252c32f5f6479f 100644 (file)
@@ -33,22 +33,20 @@ class Fastq < Filesys
   # Method to get the next FASTQ entry from an ios and return this
   # as a Seq object. If no entry is found or eof then nil is returned.
   def get_entry
-    begin
-      seq_name       = @io.gets.chomp!
-      seq            = @io.gets.chomp!
-      @io.gets
-      qual           = @io.gets.chomp!
-
-      entry          = Seq.new
-      entry.seq      = seq
-      entry.seq_name = seq_name[1 .. seq_name.length]
-      entry.qual     = qual
-      entry.type     = nil
-
-      entry
-    rescue
-      nil
-    end
+    seq_name       = @io.gets.chomp!
+    seq            = @io.gets.chomp!
+    @io.gets
+    qual           = @io.gets.chomp!
+
+    entry          = Seq.new
+    entry.seq      = seq
+    entry.seq_name = seq_name[1 .. seq_name.length]
+    entry.qual     = qual
+    entry.type     = nil
+
+    entry
+  rescue
+    nil
   end
 end
 
@@ -83,7 +81,7 @@ class FastqIndex
   # Method to read from file a Fastq entry from an indexed position,
   # and return the entry as a Seq object.
   def get(seq_name)
-    raise FastqError, "Sequence name: #{seq_name} not found in index." unless @index.has_key? seq_name
+    raise FastqError, "Sequence name: #{seq_name} not found in index." unless @index[seq_name]
 
     elem = @index[seq_name]
     @ios.sysseek(elem.offset_seq)