Class: Fastq
- Inherits:
-
Object
- Object
- Fastq
- Defined in:
- lib/nugen_barcode_splitter/fastq.rb
Instance Method Summary collapse
- #add(num, outdir) ⇒ Object
- #close ⇒ Object
-
#initialize(filename) ⇒ Fastq
constructor
A new instance of Fastq.
Constructor Details
#initialize(filename) ⇒ Fastq
Returns a new instance of Fastq.
2 3 4 5 6 7 |
# File 'lib/nugen_barcode_splitter/fastq.rb', line 2 def initialize(filename) @filehandle = File.open(filename, "r") line = @filehandle.readline() raise RuntimeError, "Invalid fastq file!" if !line.include?("@") @filehandle.pos = 0 end |
Instance Method Details
#add(num, outdir) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nugen_barcode_splitter/fastq.rb', line 9 def add(num, outdir) bases = "N" * num qualities = "@" * num outfile = File.open(outdir, 'w') while !@filehandle.eof? outfile.write(@filehandle.readline) outfile.write("#{bases}" + @filehandle.readline) outfile.write(@filehandle.readline) outfile.write("#{qualities}" + @filehandle.readline) end outfile.close() end |
#close ⇒ Object
23 24 25 |
# File 'lib/nugen_barcode_splitter/fastq.rb', line 23 def close() @filehandle.close() end |