-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_pipeline.sh
executable file
·142 lines (117 loc) · 3.61 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
set -euo pipefail
set -x
#----------------------------------------------#
# User parameters
if [ ! -z "${1}" ] || [ ! -z "${2}" ] || [ ! -z "${irods_input_projectID}" ]
then
input_dir="${1}"
output_dir="${2}"
PROJECT_NAME="${irods_input_projectID}"
EXCLUSION_FILE=""
else
echo "One of the parameters is missing, make sure there is an input directory, output directory and project name(param 1, 2 or irods_input_projectID)."
exit 1
fi
#check if there is an exclusion file, if so change the parameter
if [ ! -z "${irods_input_sequencing__run_id}" ] && [ -f "/data/BioGrid/NGSlab/sample_sheets/${irods_input_sequencing__run_id}.exclude" ]
then
EXCLUSION_FILE="/data/BioGrid/NGSlab/sample_sheets/${irods_input_sequencing__run_id}.exclude"
fi
if [ ! -d "${input_dir}" ] || [ ! -d "${output_dir}" ]
then
echo "The input directory $input_dir, output directory $output_dir or fastq dir ${input_dir}/clean_fastq does not exist"
exit 1
else
input_fastq="${input_dir}/clean_fastq"
fi
#----------------------------------------------#
## make sure conda works
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/mnt/miniconda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/mnt/miniconda/etc/profile.d/conda.sh" ]; then
. "/mnt/miniconda/etc/profile.d/conda.sh"
else
export PATH="/mnt/miniconda/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<export -f conda
export -f __conda_activate
export -f __conda_reactivate
export -f __conda_hashr
#----------------------------------------------#
# Create the environment
# we can use the base installation of mamba to create the environment.
# Swapping to a parent env is not necessary anymore.
mamba env create -f envs/apollo_mapping.yaml --name pipeline_env
conda activate pipeline_env
#----------------------------------------------#
# Run the pipeline
case $PROJECT_NAME in
adhoc)
SPECIES="NotProvided"
;;
asperg)
SPECIES="Aspergillus_fumigatus"
;;
cauris)
SPECIES="Candida_auris"
;;
*)
SPECIES="NotProvided"
;;
esac
echo -e "\nRun pipeline..."
if [ ! -z ${irods_runsheet_sys__runsheet__lsf_queue} ]; then
QUEUE="${irods_runsheet_sys__runsheet__lsf_queue}"
else
QUEUE="bio"
fi
set -euo pipefail
# Setting up the tmpdir for singularity as the current directory (default is /tmp but it gets full easily)
# Containers will use it for storing tmp files when building a container
export SINGULARITY_TMPDIR="$(pwd)"
#without exclusion file
if [ "${EXCLUSION_FILE}" == "" ]
then
python apollo_mapping.py \
--queue "${QUEUE}" \
-i "${input_dir}" \
-o "${output_dir}" \
-s "${SPECIES}" \
--prefix "/mnt/db/juno/sing_containers"
result=$?
else
python apollo_mapping.py \
--queue "${QUEUE}" \
-i "${input_dir}" \
-o "${output_dir}" \
-s "${SPECIES}" \
--prefix "/mnt/db/juno/sing_containers" \
-ex "${EXCLUSION_FILE}"
result=$?
fi
# 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
do
if [ ! -z ${!key} ] ; then
attrname=${key:12}
attrname=${attrname/__/::}
echo "${attrname}: '${!key}'" >> ${OUTPUTDIR}/metadata.yml
fi
done
set -euo pipefail
exit ${result}