From 1716853cc9c161d6e8946e1ecb45255e40b94706 Mon Sep 17 00:00:00 2001 From: Steve Malton Date: Tue, 10 Dec 2024 15:10:45 +0000 Subject: [PATCH] [DOR-953] Add qscore tag to fastq output --- dorado/utils/hts_file.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dorado/utils/hts_file.cpp b/dorado/utils/hts_file.cpp index 779d8d21a..1273a8a45 100644 --- a/dorado/utils/hts_file.cpp +++ b/dorado/utils/hts_file.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -24,6 +25,9 @@ bool compare_headers(const dorado::SamHdrPtr& header1, const dorado::SamHdrPtr& return (strcmp(sam_hdr_str(header1.get()), sam_hdr_str(header2.get())) == 0); } +// BAM tags to add to the read header for fastx output +constexpr std::array fastq_aux_tags{"RG", "st", "DS", "qs"}; + } // namespace namespace dorado::utils { @@ -60,15 +64,15 @@ HtsFile::HtsFile(const std::string& filename, OutputMode mode, int threads, bool switch (m_mode) { case OutputMode::FASTQ: m_file.reset(hts_open(m_filename.c_str(), "wf")); - hts_set_opt(m_file.get(), FASTQ_OPT_AUX, "RG"); - hts_set_opt(m_file.get(), FASTQ_OPT_AUX, "st"); - hts_set_opt(m_file.get(), FASTQ_OPT_AUX, "DS"); + for (const auto& tag : fastq_aux_tags) { + hts_set_opt(m_file.get(), FASTQ_OPT_AUX, tag); + } break; case OutputMode::FASTA: m_file.reset(hts_open(filename.c_str(), "wF")); - hts_set_opt(m_file.get(), FASTQ_OPT_AUX, "RG"); - hts_set_opt(m_file.get(), FASTQ_OPT_AUX, "st"); - hts_set_opt(m_file.get(), FASTQ_OPT_AUX, "DS"); + for (const auto& tag : fastq_aux_tags) { + hts_set_opt(m_file.get(), FASTQ_OPT_AUX, tag); + } break; case OutputMode::BAM: if (m_filename != "-" && m_sort_bam) {