From 785c48585f34224c4df2d8a19719891c692ef38f Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Fri, 12 Feb 2021 22:33:42 -0600
Subject: [PATCH] Change bdbag to use cookie locally

---
 conf/bdbag.json                 | 28 ++++++++++++++++++++++++++++
 rna-seq.nf                      | 12 +++++++-----
 workflow/scripts/bdbag_fetch.sh |  4 ++--
 3 files changed, 37 insertions(+), 7 deletions(-)
 create mode 100644 conf/bdbag.json

diff --git a/conf/bdbag.json b/conf/bdbag.json
new file mode 100644
index 0000000..2c2ab24
--- /dev/null
+++ b/conf/bdbag.json
@@ -0,0 +1,28 @@
+{
+  "fetch_config": {
+    "http": {
+      "http_cookies": {
+        "file_names": [
+            "*cookies.txt"
+        ],
+        "scan_for_cookie_files": true,
+        "search_paths": [
+            "."
+        ],
+        "search_paths_filter": "*cookies.txt"
+      }
+    },
+    "https": {
+      "http_cookies": {
+        "file_names": [
+            "*cookies.txt"
+        ],
+        "scan_for_cookie_files": true,
+        "search_paths": [
+            "."
+        ],
+        "search_paths_filter": "*cookies.txt"
+      }
+    }
+  }
+}
diff --git a/rna-seq.nf b/rna-seq.nf
index 763581a..5b15367 100644
--- a/rna-seq.nf
+++ b/rna-seq.nf
@@ -72,6 +72,7 @@ spikeForce = params.spikeForce
 email = params.email
 
 // Define fixed files and variables
+bdbagConfig = Channel.fromPath("${baseDir}/conf/bdbag.json")
 replicateExportConfig = Channel.fromPath("${baseDir}/conf/Replicate_For_Input_Bag.json")
 executionRunExportConfig = Channel.fromPath("${baseDir}/conf/Execution_Run_For_Output_Bag.json")
 if (params.source == "dev") {
@@ -239,8 +240,9 @@ process getData {
   tag "${repRID}"
 
   input:
+    path bdbagConfig
     path script_bdbagFetch
-    path cookies from bdbag
+    path cookies, stageAs: "deriva-cookies.txt" from bdbag
     path inputBag from inputBag_getData
 
   output:
@@ -256,10 +258,10 @@ process getData {
     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
+    #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}")
diff --git a/workflow/scripts/bdbag_fetch.sh b/workflow/scripts/bdbag_fetch.sh
index 45ee14a..59e1136 100644
--- a/workflow/scripts/bdbag_fetch.sh
+++ b/workflow/scripts/bdbag_fetch.sh
@@ -9,7 +9,7 @@ then
     n=0
     until [ "${n}" -ge "3" ]
     do
-        bdbag --resolve-fetch missing --validate full ${1} --debug && validate=$(tail -n validate.txt | grep -o 'is valid') && break
+        bdbag --resolve-fetch missing --validate full ${1} --debug --config-file bdbag.json && validate=$(tail -n validate.txt | grep -o 'is valid') && break
         n=$((n+1)) 
         sleep 15
     done
@@ -22,4 +22,4 @@ 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
\ No newline at end of file
+done
-- 
GitLab