Skip to content

Commit

Permalink
Merge branch 'DOR-696_store_qs_as_float' into 'master'
Browse files Browse the repository at this point in the history
DOR-696 Change qs tag type to float

Closes DOR-696

See merge request machine-learning/dorado!1005
  • Loading branch information
kdolan1973 committed May 17, 2024
2 parents c54efac + 661ddd7 commit d6b0f68
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion documentation/SAM.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
| | |
| ------ | -----------------------------------------------------------|
| RG:Z: | `<runid>_<basecalling_model>_<barcode_arrangement>` |
| qs:i: | mean basecall qscore rounded to the nearest integer |
| qs:f: | mean basecall qscore |
| ts:i: | the number of samples trimmed from the start of the signal |
| ns:i: | the basecalled sequence corresponds to the interval `signal[ts : ns]` <br /> the move table maps to the same interval. <br /> note that `ns` reflects trimming (if any) from the rear <br /> of the signal. |
| mx:i: | read mux |
Expand Down
8 changes: 4 additions & 4 deletions dorado/read_pipeline/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ std::string ReadCommon::generate_read_group() const {
}

void ReadCommon::generate_read_tags(bam1_t *aln, bool emit_moves, bool is_duplex_parent) const {
int qs = static_cast<int>(std::round(calculate_mean_qscore()));
bam_aux_append(aln, "qs", 'i', sizeof(qs), (uint8_t *)&qs);
float qs = calculate_mean_qscore();
bam_aux_append(aln, "qs", 'f', sizeof(qs), (uint8_t *)&qs);

float du = (float)(get_raw_data_samples() + num_trimmed_samples) / (float)sample_rate;
bam_aux_append(aln, "du", 'f', sizeof(du), (uint8_t *)&du);
Expand Down Expand Up @@ -108,8 +108,8 @@ void ReadCommon::generate_read_tags(bam1_t *aln, bool emit_moves, bool is_duplex
}

void ReadCommon::generate_duplex_read_tags(bam1_t *aln) const {
int qs = static_cast<int>(std::round(calculate_mean_qscore()));
bam_aux_append(aln, "qs", 'i', sizeof(qs), (uint8_t *)&qs);
float qs = calculate_mean_qscore();
bam_aux_append(aln, "qs", 'f', sizeof(qs), (uint8_t *)&qs);
uint32_t duplex = 1;
bam_aux_append(aln, "dx", 'i', sizeof(duplex), (uint8_t *)&duplex);

Expand Down
2 changes: 1 addition & 1 deletion dorado/summary/summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ bool SummaryData::write_rows_from_reader(
auto duration = reader.get_tag<float>("du");

auto seqlen = reader.record->core.l_qseq;
auto mean_qscore = reader.get_tag<int>("qs");
auto mean_qscore = reader.get_tag<float>("qs");

auto num_samples = reader.get_tag<int>("ns");
auto trim_samples = reader.get_tag<int>("ts");
Expand Down
2 changes: 1 addition & 1 deletion tests/ReadTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_CASE(TEST_GROUP ": Test tag generation", TEST_GROUP) {
REQUIRE(alignments.size() == 1);
bam1_t* aln = alignments[0].get();

CHECK(bam_aux2i(bam_aux_get(aln, "qs")) == 14);
CHECK(bam_aux2f(bam_aux_get(aln, "qs")) == 14.0f);
CHECK(bam_aux2i(bam_aux_get(aln, "ns")) == 4132);
CHECK(bam_aux2i(bam_aux_get(aln, "ts")) == 132);
CHECK(bam_aux2i(bam_aux_get(aln, "mx")) == 2);
Expand Down

0 comments on commit d6b0f68

Please sign in to comment.