Skip to content

Commit

Permalink
report alignment scores from surject
Browse files Browse the repository at this point in the history
  • Loading branch information
jeizenga committed Jul 6, 2023
1 parent be7fa18 commit f8cf5f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,12 @@ bam1_t* alignment_to_bam_internal(bam_hdr_t* header,
}
}

if (~core.flag & BAM_FUNMAP) {
// we've decided that it is aligned
int32_t score = alignment.score();
bam_aux_append(bam, "AS", 'i', sizeof(int32_t), (uint8_t*) &score);
}

if (!alignment.read_group().empty()) {
bam_aux_append(bam, "RG", 'Z', alignment.read_group().size() + 1, (uint8_t*) alignment.read_group().c_str());
}
Expand Down
5 changes: 4 additions & 1 deletion src/multipath_alignment_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,13 @@ void MultipathAlignmentEmitter::create_alignment_shim(const string& name, const
mapped = true;
}
}
// hacky way to inform the conversion code that the read is mapped
if (mapped) {
// hacky way to inform the conversion code that the read is mapped
shim.mutable_path()->add_mapping();
// and we'll also communicate the alignment score
shim.set_score(optimal_alignment_score(mp_aln, true));
}

// this tag comes from surject and is used in both
if (mp_aln.has_annotation("all_scores")) {
auto anno = mp_aln.get_annotation("all_scores");
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/convert_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int main_convert(int argc, char** argv) {
{
num_threads = parse<int>(optarg);
if (num_threads <= 0) {
cerr << "error:[vg mpmap] Thread count (-t) set to " << num_threads << ", must set to a positive integer." << endl;
cerr << "error:[vg convert] Thread count (-t) set to " << num_threads << ", must set to a positive integer." << endl;
exit(1);
}
omp_set_num_threads(num_threads);
Expand Down

0 comments on commit f8cf5f1

Please sign in to comment.