Skip to content

Commit

Permalink
Merge pull request nf-core#374 from JoseEspinosa/fixes
Browse files Browse the repository at this point in the history
Update bedtools_genomecov image to use gnu sort
  • Loading branch information
JoseEspinosa authored Jul 8, 2024
2 parents a238997 + dbab390 commit 30a165a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions modules/local/bedtools_genomecov.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ process BEDTOOLS_GENOMECOV {
tag "$meta.id"
label 'process_medium'

conda "bioconda::bedtools=2.30.0"
conda "bioconda::bedtools=2.31.1 conda-forge::coreutils=9.5"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/bedtools:2.30.0--hc088bd4_0':
'biocontainers/bedtools:2.30.0--hc088bd4_0' }"
'oras://community.wave.seqera.io/library/bedtools_coreutils:ba273c06a3909a15':
'community.wave.seqera.io/library/bedtools_coreutils:a623c13f66d5262b' }"

input:
tuple val(meta), path(bam), path(flagstat)
Expand All @@ -19,9 +19,11 @@ process BEDTOOLS_GENOMECOV {
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def pe = meta.single_end ? '' : '-pc'
def buffer = task.memory.toGiga().intdiv(2)
"""
SCALE_FACTOR=\$(grep '[0-9] mapped (' $flagstat | awk '{print 1000000/\$1}')
echo \$SCALE_FACTOR > ${prefix}.scale_factor.txt
Expand All @@ -35,11 +37,22 @@ process BEDTOOLS_GENOMECOV {
$args \\
> tmp.bg
sort -k1,1 -k2,2n tmp.bg > ${prefix}.bedGraph
## ref: https://www.biostars.org/p/66927/
## ref in nf-core: https://github.com/nf-core/hicar/blob/d2d17a924e42d6f88640b79d48d8b332f33a953f/modules/local/atacreads/bedsort.nf#L23-L29
LC_ALL=C sort \\
--parallel=$task.cpus \\
--buffer-size=${buffer}G \\
-k1,1 -k2,2n \\
$args2 \\
tmp.bg \\
> ${prefix}.bedGraph
rm tmp.bg
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bedtools: \$(bedtools --version | sed -e "s/bedtools v//g")
sort: \$(sort --version | head -n 1 | awk '{print \$4;}')
END_VERSIONS
"""
}

0 comments on commit 30a165a

Please sign in to comment.