scbi_fastq is a ruby gem to read/write FASTQ files (DNA/RNA sequences) with qualities in a variety of formats (Sanger, Solexa, Ilumina).
Read FASTQ files in Sanger Solexa and Ilumina, making the appropriate quality values conversions
Quality values can be automatically splitted
Write FASTQ files in Sanger format
Iteration over large files without extra memory usage
Reading a FASTQ with iterator:
require 'scbi_fastq' # open file in sanger mode fqr=FastqFile.new('file1.fastq') fqr.each do |name,seq_fasta,qual,comments| puts name puts seq_fasta puts qual puts comments end fqr.close
Reading a FASTQ one sequence at a time:
require 'scbi_fastq' # open file in sanger mode fqr=FastqFile.new('file1.fastq')
# read one sequence name,seq_fasta,qual,comments=fqr.next_seq # name will be nil if there are not more sequences available
puts name puts seq_fasta puts qual puts comments end
end until name.nil?
Writing a FASTQ:
require 'scbi_fastq' # open new file f=FastqFile.new('file.fastq','w') # prepare sample data name = 'seq1' seq_fasta= 'acgtacgtacact' seq_qual= [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40] # write sequence to disk f.write_seq(name,seq_fasta,seq_qual,'comments') # close file f.close
This is a standalone gem.
gem install scbi_fastq
(The MIT License)
Copyright © 2010 Dario Guerrero
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.