-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_pipeline.sh
executable file
·80 lines (66 loc) · 2.08 KB
/
run_pipeline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
set -x
#----------------------------------------------#
# User parameters
input_dir="${1%/}"
output_dir="${2%/}"
PROJECT_NAME="${irods_input_projectID}" # This should be an environment variable
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null 2>&1 && pwd )"
cd ${DIR}
echo "Current directory: ${DIR}"
# Sanity checks
if [ ! -z "${1}" ] || [ ! -z "${2}" ] || [ ! -z "${irods_input_projectID}" ]
then
INPUTDIR="${1}"
OUTPUTDIR="${2}"
PROJECT_NAME="${irods_input_projectID}"
echo "Input dir: ${INPUTDIR}"
echo "Output dir: ${OUTPUTDIR}"
echo "Project name: ${PROJECT_NAME}"
else
echo "No inputdir, outputdir or project name (param 1, 2, irods_input_projectID)"
exit 1
fi
#check if there is an rename file, otherwise exit
if [ ! -z "${irods_input_sequencing__run_id}" ] && [ -f "/data/BioGrid/NGSlab/sample_sheets/${irods_input_sequencing__run_id}.rename" ]
then
RENAME_FILE="/data/BioGrid/NGSlab/sample_sheets/${irods_input_sequencing__run_id}.rename"
echo "Rename file found for run ${irods_input_sequencing__run_id}: ${RENAME_FILE}"
else
echo "No rename file found for run ${irods_input_sequencing__run_id}"
exit 1
fi
if [ ! -d "${INPUTDIR}" ] || [ ! -d "${OUTPUTDIR}" ]
then
echo "inputdir $INPUTDIR or output dir $OUTPUTDIR does not exist!"
exit 1
fi
set -euo pipefail
echo -e "\nRun pipeline..."
python rename.py ${INPUTDIR} ${OUTPUTDIR} ${RENAME_FILE}
result=$?
# Propagate metadata
set +euo pipefail
SEQ_KEYS=
SEQ_ENV=`env | grep irods_input_sequencing`
for SEQ_AVU in ${SEQ_ENV}
do
SEQ_KEYS="${SEQ_KEYS} ${SEQ_AVU%%=*}"
done
for key in $SEQ_KEYS irods_input_illumina__Flowcell \
irods_input_illumina__Instrument \
irods_input_illumina__Date \
irods_input_illumina__Run_number \
irods_input_illumina__Run_Id \
irods_input_minion__flow_cell_id \
irods_input_minion__sample_id \
irods_input_user__runinfo__name \
irods_input_user__runinfo__id
do
if [ ! -z ${!key} ] ; then
attrname=${key:12}
attrname=${attrname/__/::}
echo "${attrname}: '${!key}'" >> ${OUTPUTDIR}/metadata.yml
fi
done
exit ${result}