Skip to content

Commit

Permalink
fix bug making mosdepth fail when length of the reference was smaller…
Browse files Browse the repository at this point in the history
… than --number_depth_windows [CW-2372]
  • Loading branch information
julibeg committed Jul 10, 2023
1 parent 26b3385 commit f6785da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.2.2]
### Fixed
- Bug where the `mosdepth` process would fail if the length of a reference sequence was smaller than the number of depth windows requested.

## [v0.2.1]
### Changed
- GitHub issue templates
Expand Down
12 changes: 8 additions & 4 deletions modules/local/pipeline.nf
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ process mosdepth {
script:
int mosdepth_extra_threads = task.cpus - 1
"""
# get window length for reference
# get the length of the reference
ref_length=\$(samtools idxstats input.bam | awk '\$1 == "$ref_id" {print \$2}')
window_length=\$(expr \$ref_length / $n_windows)
# if the reference is very short, `window_length` might be `0` --> set to `1`
[ "\$window_length" -eq "0" ] && window_length=1
# calculate the corresponding window length (check `ref_length` first because
# `expr a / b` returns non-zero exit code when `a < b`)
if [ "\$ref_length" -lt "$n_windows" ]; then
window_length=1
else
window_length=\$(expr \$ref_length / $n_windows)
fi
# get the depths (we could add `-x`, but it loses a lot of detail from the depth
# curves)
Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ manifest {
description = 'Amplicon workflow'
mainScript = 'main.nf'
nextflowVersion = '>=22.10.8'
version = 'v0.2.1'
version = 'v0.2.2'
}

epi2melabs {
Expand Down

0 comments on commit f6785da

Please sign in to comment.