-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerate_template.sh
executable file
·76 lines (63 loc) · 2.9 KB
/
generate_template.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
#!/bin/bash
set -eu
##external call with 3 arguments (rawdataName, group and workDir)
module list
host=$(hostname -s)
ENVIRONMENT_PARAMETERS="parameters_${host}.csv"
RAWDATANAME="${1}"
WORKDIR="${2}"
GROUP="${3}"
WORKFLOW="${EBROOTNGS_DEMULTIPLEXING}/workflow.csv"
echo "$WORKDIR AND $RAWDATANAME"
echo "GROUPIE: $GROUP"
mkdir -p "${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/"
mkdir -p "${WORKDIR}/rawdata/ngs/${RAWDATANAME}/"
mkdir -p "${WORKDIR}/logs/${RAWDATANAME}/"
rm -rf "${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/out.csv"
#
###### Dual barcode checker
#
sampsheet="${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/${RAWDATANAME}.csv"
mac2unix "${sampsheet}"
declare -a _sampleSheetColumnNames=()
declare -A _sampleSheetColumnOffsets=()
IFS="," read -r -a _sampleSheetColumnNames <<< "$(head -1 "${sampsheet}")"
for (( _offset = 0 ; _offset < ${#_sampleSheetColumnNames[@]:-0} ; _offset++ ))
do
_sampleSheetColumnOffsets["${_sampleSheetColumnNames[${_offset}]}"]="${_offset}"
done
dualBarcode="unknown"
if [[ -n "${_sampleSheetColumnOffsets["barcode"]+isset}" ]]; then
barcodeFieldIndex=$((_sampleSheetColumnOffsets["barcode"] + 1))
readarray -t barcodes< <(tail -n +2 "${sampsheet}" | cut -d "," -f "${barcodeFieldIndex}" | sort | uniq )
for barcode in "${barcodes[@]}"
do
if [[ "${barcode}" == *"-"* ]]
then
dualBarcode="TRUE"
else
dualBarcode="FALSE"
fi
done
fi
## Will return or nothing or in case there is a dualbarcode it will create a file
perl "${EBROOTNGS_DEMULTIPLEXING}/scripts/convertParametersGitToMolgenis.pl" "${EBROOTNGS_DEMULTIPLEXING}/parameters.csv" > \
"${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/out.csv"
perl "${EBROOTNGS_DEMULTIPLEXING}/scripts/convertParametersGitToMolgenis.pl" "${EBROOTNGS_DEMULTIPLEXING}/${ENVIRONMENT_PARAMETERS}" > \
"${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/environment_parameters.csv"
perl "${EBROOTNGS_DEMULTIPLEXING}/scripts/convertParametersGitToMolgenis.pl" "${EBROOTNGS_DEMULTIPLEXING}/parameters_${GROUP}.csv" > \
"${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/parameters_group.csv"
bash "${EBROOTMOLGENISMINCOMPUTE}/molgenis_compute.sh" \
-p "${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/out.csv" \
-p "${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/parameters_group.csv" \
-p "${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/environment_parameters.csv" \
-p "${WORKDIR}/generatedscripts/NGS_Demultiplexing/${RAWDATANAME}/${RAWDATANAME}.csv" \
-w "${WORKFLOW}" \
-rundir "${WORKDIR}/runs/NGS_Demultiplexing/${RAWDATANAME}/jobs" \
--header "${EBROOTNGS_DEMULTIPLEXING}/templates/slurm/header_tnt.ftl" \
--footer "${EBROOTNGS_DEMULTIPLEXING}/templates/slurm/footer_tnt.ftl" \
-o "dualBarcode=${dualBarcode};\
demultiplexingversion=$(module list | grep -o -P 'NGS_Demultiplexing(.+)')" \
-b slurm \
-weave \
--generate