Skip to content

Commit

Permalink
Merge branch 'smalton/DOR-953-qs-fastq' into 'master'
Browse files Browse the repository at this point in the history
[DOR-953] Add qscore tag to fastq output

Closes DOR-953

See merge request machine-learning/dorado!1301
  • Loading branch information
malton-ont committed Dec 10, 2024
2 parents dbece01 + 1716853 commit bf51bd4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions dorado/utils/hts_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <htslib/sam.h>
#include <spdlog/spdlog.h>

#include <array>
#include <cassert>
#include <filesystem>
#include <map>
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit bf51bd4

Please sign in to comment.