From 821a0f05ca8eb6eb427250a19ed8193b099744c8 Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Fri, 12 Feb 2021 23:16:00 -0600
Subject: [PATCH] Move fastq count before cp

---
 rna-seq.nf                      | 11 ++---------
 workflow/scripts/bdbag_fetch.sh |  2 ++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/rna-seq.nf b/rna-seq.nf
index 5b15367..693199e 100644
--- a/rna-seq.nf
+++ b/rna-seq.nf
@@ -257,12 +257,6 @@ process getData {
     hostname > ${repRID}.getData.log
     ulimit -a >> ${repRID}.getData.log
 
-    # link deriva cookie for authentication
-    #echo -e "LOG: linking deriva cookie" >> ${repRID}.getData.log
-    #mkdir -p ~/.bdbag
-    #cp `readlink -e cookies.txt` ~/.bdbag/deriva-cookies.txt
-    #echo -e "LOG: linked" >> ${repRID}.getData.log
-
     # get bag basename
     replicate=\$(basename "${inputBag}")
     echo -e "LOG: bag replicate name \${replicate}" >> ${repRID}.getData.log
@@ -274,10 +268,9 @@ process getData {
 
     # bag fetch fastq's only and rename by repRID
     echo -e "LOG: fetching replicate bdbag" >> ${repRID}.getData.log
-    sh ${script_bdbagFetch} \${replicate::-13} ${repRID}
+    fastqCount=\$(sh ${script_bdbagFetch} \${replicate::-13} ${repRID})
     echo -e "LOG: fetched" >> ${repRID}.getData.log
-    
-    fastqCount=\$(find . -name '*.fastq.gz' | wc -l)
+
     if [ "\${fastqCount}" == "0" ]
     then
       touch dummy.R1.fastq.gz
diff --git a/workflow/scripts/bdbag_fetch.sh b/workflow/scripts/bdbag_fetch.sh
index 59e1136..d336829 100644
--- a/workflow/scripts/bdbag_fetch.sh
+++ b/workflow/scripts/bdbag_fetch.sh
@@ -18,8 +18,10 @@ if [ "${validate}" != "is valid" ]
 then
     exit 1
 fi
+count=$(find */ -name "*[_.]R[1-2].fastq.gz" | wc -l)
 for i in $(find */ -name "*[_.]R[1-2].fastq.gz")
 do
     path=${2}.$(echo ${i##*/} | grep -o "R[1,2].fastq.gz")
     cp ${i} ./${path}
 done
+echo ${count}
-- 
GitLab