Class: Demultiplexer
- Inherits:
-
Object
- Object
- Demultiplexer
- Defined in:
- lib/demultiplexer.rb,
lib/demultiplexer/version.rb
Overview
Adding VERSION constant to class.
Constant Summary collapse
- DEFAULT =
{ verbose: false, mismatches_max: 0, revcomp_index1: false, revcomp_index2: false, scores_min: 16, scores_mean: 16 }
- VERSION =
'0.1.2'
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.run(fastq_files, options) ⇒ Object
Public: Class method to run demultiplexing of MiSeq sequences.
Instance Method Summary collapse
-
#demultiplex ⇒ Object
Internal: Method to demultiplex reads according the index.
-
#initialize(fastq_files, options) ⇒ Demultiplexer
constructor
Internal: Constructor method for Demultiplexer object.
Constructor Details
#initialize(fastq_files, options) ⇒ Demultiplexer
Internal: Constructor method for Demultiplexer object.
fastq_files - Array with paths to FASTQ files. options - Options Hash.
:verbose - Verbose flag (default: false).
:mismatches_max - Integer value indicating max mismatches
(default: 0).
:samples_file - String with path to samples file.
:revcomp_index1 - Flag indicating that index1 should be
reverse-complemented (default: false).
:revcomp_index2 - Flag indicating that index2 should be
reverse-complemented (default: false).
:output_dir - String with output directory (optional).
:scores_min - An Integer representing the Phred score
minimum, such that a reads is dropped if a
single position in the index contain a
score below this value (default: 16).
:scores_mean=> - An Integer representing the mean Phread
score, such that a read is dropped if the
mean quality score is below this value
(default: 16).
Returns Demultiplexer object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/demultiplexer.rb', line 104 def initialize(fastq_files, ) = @samples = SampleReader.read([:samples_file], [:revcomp_index1], [:revcomp_index2]) @undetermined = @samples.size @index_hash = IndexBuilder.build(@samples, [:mismatches_max]) @data_io = DataIO.new(@samples, fastq_files, [:compress], [:output_dir]) @status = Status.new(@samples) end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
40 41 42 |
# File 'lib/demultiplexer.rb', line 40 def status @status end |
Class Method Details
.run(fastq_files, options) ⇒ Object
Public: Class method to run demultiplexing of MiSeq sequences.
fastq_files - Array with paths to FASTQ files. options - Options Hash.
:verbose - Verbose flag (default: false).
:mismatches_max - Integer value indicating max mismatches
(default: 0).
:samples_file - String with path to samples file.
:revcomp_index1 - Flag indicating that index1 should be
reverse-complemented (default: false).
:revcomp_index2 - Flag indicating that index2 should be
reverse-complemented (default: false).
:output_dir - String with output directory (optional).
:scores_min - An Integer representing the Phred score
minimum, such that a reads is dropped if a
single position in the index contain a
score below this value (default: 16).
:scores_mean=> - An Integer representing the mean Phread
score, such that a read is dropped if the
mean quality score is below this value
(default: 16).
Examples
Demultiplexer.run(['I1.fq', 'I2.fq', 'R1.fq', 'R2.fq'], \
samples_file: 'samples.txt')
# => <Demultiplexer>
Returns Demultiplexer object
71 72 73 74 75 76 77 78 79 |
# File 'lib/demultiplexer.rb', line 71 def self.run(fastq_files, ) = DEFAULT.merge() log_file = File.join([:output_dir], 'Demultiplex.log') demultiplexer = new(fastq_files, ) Screen.clear if [:verbose] demultiplexer.demultiplex puts demultiplexer.status if [:verbose] demultiplexer.status.save(log_file) end |
Instance Method Details
#demultiplex ⇒ Object
Internal: Method to demultiplex reads according the index. This is done by simultaniously read-opening all input files (forward and reverse index files and forward and reverse read files) and read one entry from each. Such four entries we call a set of entries. If the quality scores from either index1 or index2 fails the criteria for mean and min required quality the set is skipped. In the combined indexes are found in the search index, then the reads are writting to files according to the sample information in the search index. If the combined indexes are not found, then the reads have their names appended with the index sequences and the reads are written to the Undertermined files.
Returns nothing.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/demultiplexer.rb', line 128 def demultiplex @data_io.open_input_files do |ios_in| @data_io.open_output_files do |ios_out| ios_in.each do |index1, index2, read1, read2| @status.count += 2 puts(@status) if [:verbose] && (@status.count % 1_000) == 0 next unless index_qual_ok?(index1, index2) match_index(ios_out, index1, index2, read1, read2) # break if @status.count == 100_000 end end end end |