- # TODO - this should be some custom to_s method instead.
- def puts(record)
- if record.has_key? :SEQ_NAME and record.has_key? :SEQ
- @io.print ">#{record[:SEQ_NAME]}\n"
- @io.print "#{record[:SEQ]}\n"
- end
+ # Method to get the next pseudo FASTA entry consisting of a sequence name and
+ # space seperated quality scores in decimals instead of sequence. This is
+ # the quality format used by Sanger and 454.
+ def get_decimal_qual
+ block = @io.gets($/ + '>')
+ return nil if block.nil?
+
+ block.chomp!($/ + '>')
+
+ (seq_name, qual) = block.split($/, 2)
+
+ raise FastaError, "Bad FASTA qual format" if seq_name.nil? or qual.nil?
+
+ entry = Seq.new
+ entry.seq_name = seq_name.sub(/^>/, '').rstrip
+ entry.seq = nil
+ entry.type = nil
+ entry.qual = qual.tr("\n", " ").strip.split(" ").collect { |q| (q.to_i + SCORE_BASE).chr }.join("")
+
+ raise FastaError, "Bad FASTA format" if entry.seq_name.empty?
+ raise FastaError, "Bad FASTA format" if entry.qual.empty?
+
+ entry