-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_pipeline.sh
executable file
·129 lines (104 loc) · 3.18 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
#!/bin/bash
# Wrapper for juno AMR pipeline
set -euo pipefail
#----------------------------------------------#
# User parameters
if [ ! -z "${1}" ] || [ ! -z "${2}" ] || [ ! -z "${irods_input_projectID}" ]
then
input_dir="${1}"
output_dir="${2}"
PROJECT_NAME="${irods_input_projectID}"
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
if [ ! -d "${input_dir}" ] || [ ! -d "${output_dir}" ] || [ ! -d "${input_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}"
fi
case $PROJECT_NAME in
adhoc|gasadhoc|bacid|rogas|svgasuit)
GENUS_ALL="other"
;;
dsshig|svshig)
GENUS_ALL="escherichia_coli"
;;
salm|svsalent|svsaltyp|vdl_salm)
GENUS_ALL="salmonella"
;;
svlismon|vdl_list)
GENUS_ALL="other"
;;
svstec|vdl_ecoli|vdl_stec)
GENUS_ALL="escherichia_coli"
;;
campy|vdl_campy)
GENUS_ALL="campylobacter"
;;
*)
GENUS_ALL="other"
;;
esac
#----------------------------------------------#
## 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/juno_amr.yaml --name pipeline_env
conda activate pipeline_env
#----------------------------------------------#
# Run the pipeline
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
python juno_amr.py --queue "${QUEUE}" -i "${input_dir}" -o "${output_dir}" -s "${GENUS_ALL}"
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
do
if [ ! -z ${!key} ] ; then
attrname=${key:12}
attrname=${attrname/__/::}
echo "${attrname}: '${!key}'" >> ${OUTPUTDIR}/metadata.yml
fi
done
set -euo pipefail
exit ${result}
# Produce svg with rules
# snakemake --config sample_sheet=config/sample_sheet.yaml \
# --configfiles config/pipeline_parameters.yaml config/user_parameters.yaml \
# -j 1 --use-conda \
# --rulegraph | dot -Tsvg > files/DAG.svg