Skip to content

Commit

Permalink
make output mode const
Browse files Browse the repository at this point in the history
  • Loading branch information
tijyojwad committed Mar 20, 2024
1 parent 2f663ad commit 9351670
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions dorado/read_pipeline/HtsWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class HtsWriter : public MessageSink {
void terminate(const FlushOptions&) override;
void restart() override { start_input_processing(&HtsWriter::input_thread_fn, this); }

int write(const bam1_t* record);
size_t get_total() const { return m_total; }
size_t get_primary() const { return m_primary; }
size_t get_unmapped() const { return m_unmapped; }
Expand Down
3 changes: 2 additions & 1 deletion dorado/utils/hts_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ class HtsFile {

bool finalise_is_noop() const { return m_finalise_is_noop; }
void finalise(const ProgressCallback& progress_callback, int writer_threads);

private:
HtsFilePtr m_file;
SamHdrPtr m_header;
size_t m_num_records{0};
bool m_finalised{false};
bool m_finalise_is_noop;
OutputMode m_mode;
const OutputMode m_mode;
};

} // namespace dorado::utils
4 changes: 3 additions & 1 deletion tests/BamWriterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ TEST_CASE("HtsWriterTest: Read and write FASTQ with tag", TEST_GROUP) {
HtsReader reader(input_fastq.string(), std::nullopt);
{
// Write with tags into temporary folder.
HtsWriter writer(out_fastq.string(), HtsFile::OutputMode::FASTQ, 2);
utils::HtsFile hts_file(out_fastq.string(), HtsFile::OutputMode::FASTQ, 2);
HtsWriter writer(hts_file);
reader.read();
CHECK_THAT(bam_aux2Z(bam_aux_get(reader.record.get(), "RG")),
Equals("6a94c5e38fbe36232d63fd05555e41368b204cda_dna_r10.4.1_e8.2_400bps_hac@v4."
"3.0"));
CHECK_THAT(bam_aux2Z(bam_aux_get(reader.record.get(), "st")),
Equals("2023-06-22T07:17:48.308+00:00"));
writer.write(reader.record.get());
hts_file.finalise([](size_t) { /* noop */ }, 2);
}

// Read temporary file to make sure tags were correctly set.
Expand Down

0 comments on commit 9351670

Please sign in to comment.