From 2a0b4e0f678f18567eb9dbeb12d7c698a43b37a1 Mon Sep 17 00:00:00 2001
From: Xavier Grand <xavier.grand@ens-lyon.fr>
Date: Mon, 5 Dec 2022 15:09:22 +0100
Subject: [PATCH] src/nf_modules/star/main_2.7.8a.nf take into account
 available memory to limit file compression ressource.

---
 src/nf_modules/star/main_2.7.8a.nf | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/nf_modules/star/main_2.7.8a.nf b/src/nf_modules/star/main_2.7.8a.nf
index d865c75..389a2ee 100644
--- a/src/nf_modules/star/main_2.7.8a.nf
+++ b/src/nf_modules/star/main_2.7.8a.nf
@@ -34,6 +34,7 @@ process index_with_gtf {
     tuple val(genome_id), path ("*"), emit: index
 
   script:
+  memory = "${task.memory}" - ~/\s*GB/
 """
 STAR --runThreadN ${task.cpus} --runMode genomeGenerate \
 --genomeDir ./ \
@@ -250,6 +251,7 @@ process mapping2fusion {
     tuple val(reads_id), path("*.bam"), emit: bam
 
   script:
+  memory = "${task.memory}" - ~/\s*GB/
 if (reads_id instanceof List){
     file_prefix = reads_id[0]
   } else {
@@ -281,7 +283,8 @@ STAR --runThreadN ${task.cpus} \
 --chimScoreJunctionNonGTAG 0 \
 --chimScoreSeparation 1 \
 --chimSegmentReadGapMax 3 \
---chimMultimapNmax 50
+--chimMultimapNmax 50 \
+--limitBAMsortRAM ${memory}000000000
 
 mv ${reads_id}.Aligned.sortedByCoord.out.bam ${reads_id}.bam
 """
@@ -311,7 +314,8 @@ STAR --runThreadN ${task.cpus} \
 --chimScoreJunctionNonGTAG 0 \
 --chimScoreSeparation 1 \
 --chimSegmentReadGapMax 3 \
---chimMultimapNmax 50
+--chimMultimapNmax 50 \
+--limitBAMsortRAM ${memory}000000000
 
 mv ${reads_id}.Aligned.sortedByCoord.out.bam ${reads_id}.bam
 """
-- 
GitLab