--- /dev/null
+# Copyright (C) 2007-2011 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# This software is part of the Biopieces framework (www.biopieces.org).
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+require 'maasha/seq'
+require 'maasha/filesys'
+
+# Error class for all exceptions to do with FASTQ.
+class FastqError < StandardError; end
+
+class Fastq < Filesys
+ # Method to get the next FASTQ 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
+ begin
+ seq_name = @io.gets.chomp!
+ seq = @io.gets.chomp!
+ qual_name = @io.gets.chomp!
+ qual = @io.gets.chomp!
+
+ entry = Seq.new
+ entry.type = @type.nil? ? nil : @type.downcase
+ entry.seq = seq
+ entry.seq_name = seq_name[1 .. seq_name.length]
+ entry.qual = qual
+
+ entry
+ rescue
+ nil
+ end
+ end
+
+ # 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
+ end
+end
+
+
+__END__