Skip to content

Commit

Permalink
Merge pull request #271 from waveygang/fix-query-end
Browse files Browse the repository at this point in the history
Fix query end position
  • Loading branch information
ekg authored Sep 12, 2024
2 parents 4521c10 + 7e5c5a5 commit 11c7a80
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,22 @@ jobs:
run: ASAN_OPTIONS=detect_leaks=1:symbolize=1 LSAN_OPTIONS=verbosity=0:log_threads=1 build/bin/wfmash data/reference.fa.gz data/reads.500bps.fa.gz -s 0.5k -N -a > reads.500bps.sam && samtools view reads.500bps.sam -bS | samtools sort > reads.500bps.bam && samtools index reads.500bps.bam && samtools view reads.500bps.bam | head
- name: Test mapping+alignment with short reads (255bps) (PAF output)
run: ASAN_OPTIONS=detect_leaks=1:symbolize=1 LSAN_OPTIONS=verbosity=0:log_threads=1 build/bin/wfmash data/reads.255bps.fa.gz -w 16 -s 100 -L > reads.255bps.paf && head reads.255bps.paf
- name: Install Rust and Cargo
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install wgatools
run: cargo install --git https://github.com/wjwei-handsome/wgatools.git
- name: Run wfmash and generate PAF
run: build/bin/wfmash -t 8 -n 1 -k 19 -s 5000 -p 90 -c 30k -P 50k -T SGDref -Q S288C -Y '#' data/scerevisiae8.fa.gz data/scerevisiae8.fa.gz > test.paf
- name: Convert PAF to MAF using wgatools
run: wgatools paf2maf --target data/scerevisiae8.fa.gz --query data/scerevisiae8.fa.gz test.paf > test.maf
- name: Check if MAF file is not empty
run: |
if [ -s test.maf ]; then
echo "MAF file is not empty. Test passed."
else
echo "MAF file is empty. Test failed."
exit 1
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ test/
.idea/
cmake-build-debug/
result
.aider*
16 changes: 13 additions & 3 deletions src/common/wflign/src/wflign_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ void write_merged_alignment(
&max_dist_threshold, &wf_aligner,
&multi_patch_alns,
&convex_penalties,
&chain_gap, &max_patching_score, &min_inversion_length, &erode_k
&chain_gap, &max_patching_score, &min_inversion_length, &erode_k,
&query_total_length // Add this line to capture query_total_length
#ifdef WFA_PNG_TSV_TIMING
,&emit_patching_tsv,
&out_patching_tsv
Expand Down Expand Up @@ -1396,8 +1397,17 @@ void write_merged_alignment(
query_pos = query_length;
target_pos = target_length;

// Adjust target_length if we used additional sequence
target_end += tail_aln.target_length;
// Add safety checks first
uint64_t new_query_end = query_offset + query_length;
uint64_t new_target_end = target_offset + target_length + actual_extension;

if (new_query_end > query_total_length || new_target_end > target_total_length) {
std::cerr << "[wfmash::patch] Warning: Alignment extends beyond sequence bounds. Truncating." << std::endl;
}

// Adjust query_end and target_end, ensuring we don't exceed the total lengths
query_end = std::min(new_query_end, query_total_length);
target_end = std::min(new_target_end, target_total_length);
}
}

Expand Down

0 comments on commit 11c7a80

Please sign in to comment.