Skip to content

Commit

Permalink
fix: Use biWFA for smaller sequences or very high identity matches
Browse files Browse the repository at this point in the history
  • Loading branch information
ekg committed Oct 28, 2024
1 parent 907a16e commit 263321c
Showing 1 changed file with 19 additions and 40 deletions.
59 changes: 19 additions & 40 deletions src/common/wflign/src/wflign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,23 @@ void do_biwfa_alignment(
const int status = wf_aligner.alignEnd2End(target, (int)target_length, query, (int)query_length);

if (status == 0) { // WF_STATUS_SUCCESSFUL
// Create alignment record on heap
auto* aln = new alignment_t();
aln->ok = true;
aln->j = 0;
aln->i = 0;
aln->query_length = query_length;
aln->target_length = target_length;
// Create alignment record on stack
alignment_t aln;
aln.ok = true;
aln.j = 0;
aln.i = 0;
aln.query_length = query_length;
aln.target_length = target_length;
aln.is_rev = false;

// Copy alignment CIGAR
wflign_edit_cigar_copy(wf_aligner, &aln->edit_cigar);
wflign_edit_cigar_copy(wf_aligner, &aln.edit_cigar);

// Write alignment
if (paf_format_else_sam) {
write_alignment_paf(
out,
*aln, // Dereference the pointer
aln,
query_name,
query_total_length,
query_offset,
Expand All @@ -81,48 +82,26 @@ void do_biwfa_alignment(
min_identity,
mashmap_estimated_identity);
} else {
write_merged_alignment(
// Write SAM output directly
write_alignment_sam(
out,
{aln}, // Pass pointer to alignment
wf_aligner,
penalties,
emit_md_tag,
paf_format_else_sam,
no_seq_in_sam,
query,
aln,
query_name,
query_total_length,
query_offset,
query_length,
query_is_rev,
target,
target_name,
target_total_length,
target_offset,
target_length,
min_identity,
#ifdef WFA_PNG_TSV_TIMING
0, // elapsed_time_wflambda_ms
1, // num_alignments
1, // num_alignments_performed
#endif
mashmap_estimated_identity,
wflign_max_len_minor,
wflign_max_len_minor,
0, // erode_k
0, // chain_gap
0, // max_patching_score
0, // min_inversion_length
MIN_WF_LENGTH,
0 // wf_max_dist_threshold
#ifdef WFA_PNG_TSV_TIMING
,
nullptr, // prefix_wavefront_plot_in_png
0, // wfplot_max_size
false, // emit_patching_tsv
nullptr // out_patching_tsv
#endif
);
no_seq_in_sam,
emit_md_tag,
query,
target,
0); // No target pointer shift for biwfa
}
}
}
Expand Down Expand Up @@ -467,7 +446,7 @@ void WFlign::wflign_affine_wavefront(

// Use biWFA for smaller sequences or very high identity matches

if (!force_wflign) {
if (!force_wflign && (query_length <= MAX_LEN_FOR_STANDARD_WFA || target_length <= MAX_LEN_FOR_STANDARD_WFA)) {
do_biwfa_alignment(
query_name, query, query_total_length, query_offset, query_length, query_is_rev,
target_name, target, target_total_length, target_offset, target_length,
Expand Down

0 comments on commit 263321c

Please sign in to comment.