Skip to content

Commit 006fbb6

Browse files
committed
optimized the resources and scratch dir usage across all the modules
1 parent 4c35414 commit 006fbb6

5 files changed

Lines changed: 31 additions & 19 deletions

File tree

modules/local/alignment/main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ process STAR_ALIGNMENT_WASP {
2525
--readFilesCommand zcat \\
2626
--outSAMtype BAM SortedByCoordinate \\
2727
--outSAMunmapped Within \\
28-
--outTmpDir ${task.workDir} \\
28+
--outTmpDir ${task.workDir}/_STARtmp \\
2929
--outFileNamePrefix ${meta.sampleid}. \\
3030
--outFilterMultimapNmax 20 \\
3131
--alignSJoverhangMin 8 \\
@@ -53,7 +53,7 @@ process STAR_ALIGNMENT_WASP {
5353
--chimMainSegmentMultNmax 1 \\
5454
--genomeLoad NoSharedMemory
5555
56-
samtools index ${meta.sampleid}.Aligned.sortedByCoord.out.bam
57-
samtools stats ${meta.sampleid}.Aligned.sortedByCoord.out.bam > ${meta.sampleid}.samtools_stats.txt
56+
samtools index -@ ${task.cpus} ${meta.sampleid}.Aligned.sortedByCoord.out.bam
57+
samtools stats -@ ${task.cpus} ${meta.sampleid}.Aligned.sortedByCoord.out.bam > ${meta.sampleid}.samtools_stats.txt
5858
"""
5959
}

modules/local/allele_count/main.nf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ process ALLELE_COUNT{
1717
1818
[[ -f "${reference_fa}.fai" ]] || samtools faidx ${reference_fa}
1919
20-
bgzip -c ${regions_vcf} > sites.vcf.gz
20+
bgzip -@ ${task.cpus} -c ${regions_vcf} > sites.vcf.gz
2121
2222
tabix -p vcf sites.vcf.gz
2323
@@ -29,6 +29,7 @@ process ALLELE_COUNT{
2929
-R sites.vcf.gz \\
3030
-a FORMAT/AD,FORMAT/DP \\
3131
-Ou ${bam} \\
32+
--threads ${task.cpus} \\
3233
| bcftools call -m -Ou -o ${meta.sampleid}.vcf
3334
bcftools query -f '%CHROM\\t%POS\\t%REF\\t%ALT\\t[%DP]\\t[%AD]\\n' ${meta.sampleid}.vcf \\
3435
| awk -F '\\t' 'BEGIN{OFS="\\t"}

modules/local/index_genome/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ process STAR_GENOME_INDEX {
1818
--genomeDir STAR_INDEX \\
1919
--genomeFastaFiles ${ref_fa} \\
2020
--sjdbGTFfile ${gtf} \\
21-
--outTmpDir ${task.workDir}
21+
--outTmpDir ${task.workDir}/_STARgenomeTmp
2222
"""
2323
}

modules/local/subset_1kgp/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ process SUBSET_1KGP_VCF {
1313
1414
total_threads=${task.cpus}
1515
16-
threads_per_job=\$(( total_threads > 4 ? 4 : total_threads ))
16+
threads_per_job=\$(( total_threads > 2 ? 2 : total_threads ))
1717
parallel_jobs=\$(( total_threads / threads_per_job ))
1818
parallel_jobs=\$(( parallel_jobs < 1 ? 1 : parallel_jobs ))
1919
@@ -55,7 +55,7 @@ process SUBSET_1KGP_VCF {
5555
[[ -s "${meta.sampleid}.chrX.snps.het.vcf.gz" ]] && echo "${meta.sampleid}.chrX.snps.het.vcf.gz"
5656
} > list.txt
5757
58-
bcftools concat -f list.txt -Ou \\
58+
bcftools concat --threads \${total_threads} -f list.txt -Ou \\
5959
| bcftools sort --temp-dir ${task.workDir} -Ov -o ${meta.sampleid}.1KGP.snps.het.vcf
6060
else
6161
echo "Phased VCF dir is empty. Creating empty output files."

nextflow.config

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,39 @@ profiles {
2121
errorStrategy = { task.exitStatus in [140, 143, 137, 104, 134, 139, 1] ? 'retry' : 'finish' }
2222
maxRetries = 3
2323
maxErrors = '-1'
24-
cpus = { Math.min(4 * task.attempt, 64) }
25-
memory = { "${Math.min(16 * task.attempt, 128)} GB" }
26-
time = { "${Math.min(task.attempt, 3)}d" }
24+
cpus = { Math.min(8 * task.attempt, 16) }
25+
memory = { "${Math.min(12 * task.attempt, 24)} GB" }
26+
time = { "${Math.min(2 * task.attempt, 6)}h" }
27+
withName: 'CHECK_FASTQ' {
28+
cpus = { Math.min(1 * task.attempt, 2) }
29+
memory = { "${Math.min(2 * task.attempt, 4)} GB" }
30+
time = { "${Math.min(1 * task.attempt, 2)}h" }
31+
}
2732
withName: 'ADAPTER_TRIM' {
28-
cpus = { Math.min(32 * task.attempt, 64) }
29-
memory = { "${Math.min(64 * task.attempt, 128)} GB" }
30-
time = { "${Math.min(task.attempt, 3)}d" }
33+
cpus = { Math.min(8 * task.attempt, 32) }
34+
memory = { "${Math.min(12 * task.attempt, 24)} GB" }
35+
time = { "${Math.min(2 * task.attempt, 6)}h" }
3136
}
3237
withName: 'STAR_GENOME_INDEX' {
33-
cpus = { Math.min(32 * task.attempt, 64) }
38+
cpus = { Math.min(16 * task.attempt, 64) }
3439
memory = { "${Math.min(48 * task.attempt, 128)} GB" }
35-
time = { "${Math.min(task.attempt, 3)}d" }
40+
time = { "${Math.min(2 * task.attempt, 4)}h" }
3641
}
3742
withName: 'STAR_ALIGNMENT_WASP' {
3843
cpus = { Math.min(32 * task.attempt, 64) }
3944
memory = { "${Math.min(64 * task.attempt, 128)} GB" }
40-
time = { "${Math.min(task.attempt, 3)}d" }
45+
time = { "${Math.min(3 * task.attempt, 6)}h" }
4146
}
4247
withName: 'SUBSET_1KGP_VCF' {
43-
cpus = { Math.min(32 * task.attempt, 64) }
44-
memory = { "${Math.min(32 * task.attempt, 128)} GB" }
45-
time = { "${Math.min(task.attempt, 3)}d" }
48+
stageInMode = 'symlink'
49+
cpus = { Math.min(16 * task.attempt, 32) }
50+
memory = { "${Math.min(64 * task.attempt, 128)} GB" }
51+
time = { "${Math.min(2 * task.attempt, 6)}h" }
52+
}
53+
withName: 'REPORT' {
54+
cpus = { Math.min(2 * task.attempt, 4) }
55+
memory = { "${Math.min(4 * task.attempt, 8)} GB" }
56+
time = { "${Math.min(30 * task.attempt, 120)}m" }
4657
}
4758
}
4859
workDir = "${System.getenv('WORK')}/nf-rna-wasp-allele-count_work"

0 commit comments

Comments
 (0)