Update by asebastian on Thu Oct 26 16:59:44 EDT 2017 from Aswathys-iMac.local
@@ -3,32 +3,24 @@ set -ueo pipefail
# Get parameters.
INPUT={{data.path}}
GENOME={{genome.path}}
-ORGANISM={{organism.name}}
+#ORGANISM={{organism.name}}
# Internal parameters.
RESULTS=results
DATA_DIR=$(dirname "$GENOME")
-INDEX=${DATA_DIR}/index
OUTPUT="mapped.bam"
-# Testing.
-
-echo -e "input data: $INPUT"
-echo -e "input genome: $GENOME"
-echo -e "DATA_DIR: $DATA_DIR"
-echo -e "INDEX: $INDEX"
-
-
# Build bwa index if not exist in project data folder.
-if [ ! -f "$DATA_DIR/index.bwt" ]; then
+if [ ! -f "$GENOME.bwt" ]; then
echo -e "Building bwa index.\n"
-bwa index -p index $GENOME
+bwa index ${GENOME}
fi
# Align sequences
echo -e "Mapping reads to genome.\n"
-bwa mem -t 4 $INDEX $INPUT | samtools view -Sb |samtools sort >${RESULTS}/$OUTPUT
-samtools index ${RESULTS}/$OUTPUT
+mkdir -p ${RESULTS}
+bwa mem -t 4 ${GENOME} ${INPUT} | samtools view -Sb |samtools sort >${RESULTS}/${OUTPUT}
+samtools index ${RESULTS}/${OUTPUT}
