From c26ca54f7aa466df7e094516be078bdac5566043 Mon Sep 17 00:00:00 2001
From: Adam Caprez <acaprez2@unl.edu>
Date: Wed, 16 Mar 2016 12:11:09 -0500
Subject: [PATCH] Add cd'ing to correct directory

The BLAHP submit wrapper creates a temp directory and cd's there
before running the executable. This breaks Pegasus jobs for a
sharedfs site as it expects to be in the shared-scratch dir
via the `remote_iwd` Condor ClassAd.  This dir is available via
the PEGASUS_SCRATCH_DIR env variable in the job, so cd there as a
workaround.
---
 chipathlon/jobs/scripts/download_fastq.py        | 2 +-
 chipathlon/jobs/scripts/sort_wrapper.sh          | 1 +
 chipathlon/jobs/scripts/zcat_wrapper.sh          | 1 +
 chipathlon/jobs/wrappers/bedtools_wrapper.sh     | 1 +
 chipathlon/jobs/wrappers/bowtie2_wrapper.sh      | 1 +
 chipathlon/jobs/wrappers/bwa_wrapper.sh          | 1 +
 chipathlon/jobs/wrappers/macs2_wrapper.sh        | 1 +
 chipathlon/jobs/wrappers/picard_wrapper.sh       | 1 +
 chipathlon/jobs/wrappers/r_spp_nodups_wrapper.sh | 1 +
 chipathlon/jobs/wrappers/samtools_wrapper.sh     | 1 +
 10 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/chipathlon/jobs/scripts/download_fastq.py b/chipathlon/jobs/scripts/download_fastq.py
index 9b79b4b..3bd57cf 100755
--- a/chipathlon/jobs/scripts/download_fastq.py
+++ b/chipathlon/jobs/scripts/download_fastq.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/bin/env python 
 import chipathlon.utils
 import argparse
 
diff --git a/chipathlon/jobs/scripts/sort_wrapper.sh b/chipathlon/jobs/scripts/sort_wrapper.sh
index 87439cc..5b8ff45 100755
--- a/chipathlon/jobs/scripts/sort_wrapper.sh
+++ b/chipathlon/jobs/scripts/sort_wrapper.sh
@@ -1,3 +1,4 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 /bin/sort -k 8gr,8gr "$1" | awk 'BEGIN{OFS="\t"}{$r="PEAK_"NR; print $0;}' > "$2"
diff --git a/chipathlon/jobs/scripts/zcat_wrapper.sh b/chipathlon/jobs/scripts/zcat_wrapper.sh
index 5d189ed..8fc0ba4 100755
--- a/chipathlon/jobs/scripts/zcat_wrapper.sh
+++ b/chipathlon/jobs/scripts/zcat_wrapper.sh
@@ -1,3 +1,4 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 /bin/zcat "$1" | awk 'BEGIN{OFS="\t"}{print $1,int($2),int($3),$4,$5,$6,$7,$8,$9,$10;}' > "$2"
diff --git a/chipathlon/jobs/wrappers/bedtools_wrapper.sh b/chipathlon/jobs/wrappers/bedtools_wrapper.sh
index bbfc47e..1cd6933 100755
--- a/chipathlon/jobs/wrappers/bedtools_wrapper.sh
+++ b/chipathlon/jobs/wrappers/bedtools_wrapper.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 . /util/opt/lmod/lmod/init/profile
 module load bedtools
 bedtools "$@"
diff --git a/chipathlon/jobs/wrappers/bowtie2_wrapper.sh b/chipathlon/jobs/wrappers/bowtie2_wrapper.sh
index 6a63fcb..f23550e 100755
--- a/chipathlon/jobs/wrappers/bowtie2_wrapper.sh
+++ b/chipathlon/jobs/wrappers/bowtie2_wrapper.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 . /util/opt/lmod/lmod/init/profile
 module load bowtie
 bowtie2 "$@"
diff --git a/chipathlon/jobs/wrappers/bwa_wrapper.sh b/chipathlon/jobs/wrappers/bwa_wrapper.sh
index 47f0780..b1b75bf 100755
--- a/chipathlon/jobs/wrappers/bwa_wrapper.sh
+++ b/chipathlon/jobs/wrappers/bwa_wrapper.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 . /util/opt/lmod/lmod/init/profile
 module load bwa
 bwa "$@"
diff --git a/chipathlon/jobs/wrappers/macs2_wrapper.sh b/chipathlon/jobs/wrappers/macs2_wrapper.sh
index bc3238d..cbeb384 100755
--- a/chipathlon/jobs/wrappers/macs2_wrapper.sh
+++ b/chipathlon/jobs/wrappers/macs2_wrapper.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 . /util/opt/lmod/lmod/init/profile
 module load python/2.7 macs2
 macs2 "$@"
diff --git a/chipathlon/jobs/wrappers/picard_wrapper.sh b/chipathlon/jobs/wrappers/picard_wrapper.sh
index 92ffde2..b897c97 100755
--- a/chipathlon/jobs/wrappers/picard_wrapper.sh
+++ b/chipathlon/jobs/wrappers/picard_wrapper.sh
@@ -2,6 +2,7 @@
 set -eu -o pipefail
 set -o pipefail
 
+cd $PEGASUS_SCRATCH_DIR
 . /util/opt/lmod/lmod/init/profile
 module load picard
 
diff --git a/chipathlon/jobs/wrappers/r_spp_nodups_wrapper.sh b/chipathlon/jobs/wrappers/r_spp_nodups_wrapper.sh
index bf96b43..fdce742 100755
--- a/chipathlon/jobs/wrappers/r_spp_nodups_wrapper.sh
+++ b/chipathlon/jobs/wrappers/r_spp_nodups_wrapper.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 . /util/opt/lmod/lmod/init/profile
 module load R spp
 Rscript ${SPP_NODUPS} "$@"
diff --git a/chipathlon/jobs/wrappers/samtools_wrapper.sh b/chipathlon/jobs/wrappers/samtools_wrapper.sh
index b6cc153..7ba5f07 100755
--- a/chipathlon/jobs/wrappers/samtools_wrapper.sh
+++ b/chipathlon/jobs/wrappers/samtools_wrapper.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+cd $PEGASUS_SCRATCH_DIR
 . /util/opt/lmod/lmod/init/profile
 module load samtools
 samtools "$@"
-- 
GitLab