Sha256: 0b8b9ed08b3b5180bdb333a2c47f6be13d29e9a43192280abf163423d6ccd465

Contents?: true

Size: 699 Bytes

Versions: 4

Compression:

Stored size: 699 Bytes

Contents

#!/usr/bin/env ruby

require 'scbi_fastq'


if ARGV.count < 3
  puts "#{$0} FASTQ OUTPUT_NAME SPLIT_BY [-gz]"
  exit
end

  
fastq = ARGV.shift
output_name = ARGV.shift
split_by = ARGV.shift.to_i

gz_arg=ARGV.shift
gz=false

if !gz_arg.nil? and gz_arg.index('-gz')
	gz='.gz'
end


file_index=1
out=FastqFile.new("#{output_name}#{file_index}.fastq#{gz}","w#{gz}")

fqr=FastqFile.new(fastq)

count = 0

fqr.each do |seq_name,seq_fasta,seq_qual,comments|
  
  out.write_seq(seq_name,seq_fasta,seq_qual,comments)

  count +=1

  if (count % split_by) == 0 
      
    file_index +=1
    out.close
    out=FastqFile.new("#{output_name}#{file_index}.fastq#{gz}","w#{gz}")

  end
end

out.close
fqr.close

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
seqtrimnext-2.0.62 bin/split_fastq.rb
seqtrimnext-2.0.61 bin/split_fastq.rb
seqtrimnext-2.0.60 bin/split_fastq.rb
seqtrimnext-2.0.59 bin/split_fastq.rb