From 1e8d161ea6c8870d8d33446f65e95f176b7ef074 Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Tue, 2 Mar 2021 11:12:30 -0600
Subject: [PATCH] Don't donwload fastqs if overridden

---
 CHANGELOG.md |  2 ++
 rna-seq.nf   | 20 ++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1025ae0..c90e24a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,8 @@
 * Add new CI py tests for override and integration
 * Fix fastq file and species error status detail bub (#118)
 * Make compatible with XPACK-DNANEXUS
+* Don't download fastq's if fastq override present
+* Override fastq count to override counts
 
 *Known Bugs*
 * Override params (inputBag, fastq, species) aren't checked for integrity
diff --git a/rna-seq.nf b/rna-seq.nf
index 923eccc..f761977 100644
--- a/rna-seq.nf
+++ b/rna-seq.nf
@@ -264,9 +264,14 @@ process getData {
     echo -e "LOG: unzipped" >> ${repRID}.getData.log
 
     # bag fetch fastq's only and rename by repRID
-    echo -e "LOG: fetching replicate bdbag" >> ${repRID}.getData.log
-    fastqCount=\$(sh ${script_bdbagFetch} \${replicate::-13} ${repRID})
-    echo -e "LOG: fetched" >> ${repRID}.getData.log
+    if [ "${fastqsForce}" != "" ]
+    then
+      echo -e "LOG: fetching replicate bdbag" >> ${repRID}.getData.log
+      fastqCount=\$(sh ${script_bdbagFetch} \${replicate::-13} ${repRID})
+      echo -e "LOG: fetched" >> ${repRID}.getData.log
+    else
+      echo -e "LOG: fastq override detected, not fetching fastqs" >> ${repRID}.getData.log
+    fi
 
     if [ "\${fastqCount}" == "0" ]
     then
@@ -277,9 +282,10 @@ process getData {
 }
 
 // Split fastq count into channel
+fastqCountTemp = Channel.create()
 fastqCount = Channel.create()
 fastqCount_fl.splitCsv(sep: ",", header: false).separate(
-  fastqCount
+  fastqCountTemp
 )
 
 // Set raw fastq to downloaded or forced input and replicate them for multiple process inputs
@@ -293,6 +299,9 @@ if (fastqsForce != "") {
       fastqs_parseMetadata
       fastqs_fastqc
     }
+  fastqsForce.count().into{
+    fastqCount
+  }
 } else {
   fastqs.collect().into {
     fastqs_seqwho
@@ -300,6 +309,9 @@ if (fastqsForce != "") {
     fastqs_parseMetadata
     fastqs_fastqc
   }
+  fastqCountTemp.into {
+    fastqCount
+  }
 }
 
 /*
-- 
GitLab