Skip to content

Commit

Permalink
Merge pull request #26 from kdelange/master
Browse files Browse the repository at this point in the history
shellcheck updates
  • Loading branch information
Gerbenvandervries authored Aug 4, 2020
2 parents 6f65cd9 + 48922ae commit 6990ad5
Show file tree
Hide file tree
Showing 21 changed files with 587 additions and 386 deletions.
Binary file added .DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions check/indentationcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

echo '#####################################################################################'
echo ' Bash code must be indented with TABs. Checking for lines indented with spaces ... '
echo '#####################################################################################'
grep -n '^[[:space:]]* [[:space:]]*' "${WORKSPACE:-../}"/protocols/*.*sh
grep_exit_status="${?}"
if [[ "${grep_exit_status}" -eq 0 ]]; then
echo '#####################################################################################'
echo ' ERROR: found Bash files containing lines (partially) indented with spaces.'
echo '#####################################################################################'
exit 1
elif [[ "${grep_exit_status}" -eq 1 ]]; then
echo ' Ok: all Bash files indented with TABs.'
echo '####################################################################################'
exit 0
else
echo ' FAILED: indentation sanity check failed.'
echo '####################################################################################'
exit 1
fi
104 changes: 104 additions & 0 deletions check/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash

#
# Disable some shellcheck warnings:
# * SC2004: $/${} is unnecessary on arithmetic variables.
# But for consistency we prefer to always use ${} anyway.
# * SC2015: Note that A && B || C is not if-then-else. C may run when A is true.
# We know and use this construct regularly to create "transactions"
# where C is only executed when both A and B have succeeded.
#
export SHELLCHECK_OPTS="-e SC2004 -e SC2015"

function showHelp() {
#
# Display commandline help on STDOUT.
#
cat <<EOH
===============================================================================================================
Script for sanity checking of Bash code of this repo using ShellCheck.
Usage:
$(basename "${0}") OPTIONS
Options:
-h Show this help.
-v Enables verbose output.
===============================================================================================================
EOH
exit 0
}


#
# Parse commandline options
#
while getopts "hv" opt
do
case "${opt}" in
h)
showHelp
;;
v)
verbose='1'
;;
\?)
printf '%s\n' "FATAL: Invalid option -${OPTARG}. Try $(basename "${0}") -h for help."
exit 1
;;
:)
printf '%s\n' "FATAL: Option -${OPTARG} requires an argument. Try $(basename "${0}") -h for help."
exit 1
;;
*)
printf '%s\n' "FATAL Unhandled option. Try $(basename "${0}") -h for help."
exit 1
;;
esac
done

#
# Check if ShellCheck is installed.
#
which shellcheck 2>&1 >/dev/null \
|| {
printf '%s\n' 'FATAL: cannot find shellcheck; make sure it is installed and can be found in ${PATH}.'
exit 1
}

#
# Run ShellCheck for all Bash scripts in the bin/ subdir.
# * Includes sourced files, so the libraries from the lib/ subfolder
# are checked too as long a they are used in at least one script.
# * Select format and output based on whether this script is
# executed by Jenkins or by a regular user.
#
if [[ -n "${WORKSPACE:-}" ]]
then
#
# Exclude SC2154 (warning for variables that are referenced but not assigned),
# because we cannot easily resolve variables sourced from etc/*.cfg config files.
#
export SHELLCHECK_OPTS="${SHELLCHECK_OPTS} -e SC2154"
#
# ShellCheck for Jenkins.
#
shellcheck -a -x -o all -f checkstyle "${WORKSPACE}"/protocols/*.sh | tee checkstyle-result.xml
#
# Reformat the generated report to add hyperlinks to the ShellCheck issues on the wiki:
# https://github.com/koalaman/shellcheck/wiki/SC${ISSUENUMBER}
# explaining whatis wrong with the code / style and how to improve it.
#
perl -pi -e "s|message='([^']+)'\s+source='ShellCheck.(SC[0-9]+)'|message='&lt;a href=&quot;https://github.com/koalaman/shellcheck/wiki/\$2&quot;&gt;\$2: \$1&lt;/a&gt;' source='ShellCheck.\$2'|" checkstyle-result.xml
else
#
# ShellCheck for regular user on the commandline.
#
MYDIR="$(cd -P "$(dirname "${0}")" && pwd)"
if [[ "${verbose:-0}" -eq 1 ]]
then
cd "${MYDIR}/.."
shellcheck -a -x -o all -f tty protocols/*.sh # cannot use the printf construct used below for non-vebose output as it destroys the terminal colors.
cd '-' # Goes back to previous directory before we changed to ${MYDIR}.
else
printf '%s\n' "$(cd "${MYDIR}/.." && shellcheck -a -x -o all -f gcc protocols/*.sh)"
fi
fi
63 changes: 0 additions & 63 deletions generate_template.sh

This file was deleted.

14 changes: 3 additions & 11 deletions parameters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobname,jobname

##### Tools and versions #####
jdkVersion,Java/1.7.0_80
NGSUtilsVersion,ngs-utils #(ngs-utils/19.03.3-GCCcore-7.3.0)
NGSUtilsVersion,ngs-utils/19.03.3-GCCcore-7.3.0
NGSRNAVersion,NGS_RNA/4.0.0
fastqcVersion,FastQC/0.11.8-Java-11-LTS
samtoolsVersion,SAMtools/1.9-GCCcore-7.3.0
Expand All @@ -20,19 +20,11 @@ PythonPlusVersion,PythonPlus/3.7.4-${toolchain}-v20.02.1
gatkVersion,GATK/4.1.4.1-Java-8-LTS
ghostscriptVersion,Ghostscript/9.27-GCCcore-7.3.0
multiqcVersion,multiqc/1.7-GCCcore-7.3.0-Python-3.7.4-bare
NGSUtilsVersion,ngs-utils
fastqcVersion,FastQC/0.11.3-Java-1.7.0_80
RVersion,R/3.2.1-${toolchain}
wkhtmltopdfVersion,wkhtmltopdf/0.11.0_rc1-static-amd64
anacondaVersion,Anaconda/1.8.0-Linux-x86_64
hisatVersion,hisat/0.1.5-beta-${toolchain}
starVersion,STAR/2.7.3a-${toolchain}
pythonVersion,Python/2.7.10-${toolchain}
gatkVersion,GATK/3.6-Java-1.8.0_74
ghostscriptVersion,Ghostscript/9.16-${toolchain}
kallistoVersion,Kallisto/0.43.0-${toolchain}
BBMapVersion,BBMap/35.69-Java-1.7.0_80
multiqcVersion,multiqc/1.0-${toolchain}-Python-2.7.11
picardJar,picard.jar
mergeSamFilesJar,MergeSamFiles
processReadCountsJar,ProcessReadCounts.jar
Expand Down Expand Up @@ -67,8 +59,8 @@ leftbarcodefq,${leftbarcode}.fq
rightbarcodefq,${rightbarcode}.fq
leftbarcodefqgz,${leftbarcodefq}.gz
rightbarcodefqgz,${rightbarcodefq}.gz
trimmedLeftBarcodeFqGz,${projectRawtmpDataDir}/${filePrefix}_${barcode}_val_1.fq.gz
trimmedRightBarcodeFqGz,${projectRawtmpDataDir}/${filePrefix}_${barcode}_val_2.fq.gz
trimmedLeftBarcodeFqGz,${projectRawtmpDataDir}/${filePrefix}_${barcode}_1_val_1.fq.gz
trimmedRightBarcodeFqGz,${projectRawtmpDataDir}/${filePrefix}_${barcode}_2_val_2.fq.gz
workflowFile,$MC_HOME/NGS_RNA_seq_pipeline/workflow.csv

##### GENOME,INDEX,ANNOTATION FILES #####
Expand Down
57 changes: 29 additions & 28 deletions protocols/AddOrReplaceReadGroups.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#MOLGENIS nodes=1 ppn=8 mem=8gb walltime=05:00:00

#string project
Expand All @@ -23,36 +24,36 @@
#string tmpName
#string logsDir

makeTmpDir ${addOrReplaceGroupsBam}
tmpAddOrReplaceGroupsBam=${MC_tmpFile}
makeTmpDir "${addOrReplaceGroupsBam}"
tmpAddOrReplaceGroupsBam="${MC_tmpFile}"

makeTmpDir ${addOrReplaceGroupsBai}
tmpAddOrReplaceGroupsBai=${MC_tmpFile}
makeTmpDir "${addOrReplaceGroupsBai}"
tmpAddOrReplaceGroupsBai="${MC_tmpFile}"

#Load modules
${stage} ${picardVersion}
module load "${picardVersion}"

#check modules
${checkStage}

echo "## "$(date)" Start $0"

java -Xmx6g -XX:ParallelGCThreads=8 -jar ${EBROOTPICARD}/${picardJar} AddOrReplaceReadGroups \
I=${sortedBam} \
O=${tmpAddOrReplaceGroupsBam} \
SORT_ORDER=coordinate \
RGID=${externalSampleID} \
RGLB=${externalSampleID}_${barcode} \
RGPL=ILLUMINA \
RGPU=${sequencer}_${flowcell}_${run}_${lane}_${barcode} \
RGSM=${externalSampleID} \
RGDT=$(date --rfc-3339=date) \
CREATE_INDEX=true \
MAX_RECORDS_IN_RAM=4000000 \
TMP_DIR=${tempDir}

echo "returncode: $?";
mv ${tmpAddOrReplaceGroupsBam} ${addOrReplaceGroupsBam}
mv ${tmpAddOrReplaceGroupsBai} ${addOrReplaceGroupsBai}
echo "succes moving files";
echo "## "$(date)" ## $0 Done "
"${checkStage}"

echo "## $(date) Start $0"

java -Xmx6g -XX:ParallelGCThreads=8 -jar "${EBROOTPICARD}"/"${picardJar}" AddOrReplaceReadGroups \
I="${sortedBam}" \
O="${tmpAddOrReplaceGroupsBam}" \
SORT_ORDER=coordinate \
RGID="${externalSampleID}" \
RGLB="${externalSampleID}"_"${barcode}" \
RGPL=ILLUMINA \
RGPU="${sequencer}"_"${flowcell}"_"${run}"_"${lane}"_"${barcode}" \
RGSM="${externalSampleID}" \
RGDT=$(date --rfc-3339=date) \
CREATE_INDEX=true \
MAX_RECORDS_IN_RAM=4000000 \
TMP_DIR="${tempDir}"

echo "returncode: $?";
mv "${tmpAddOrReplaceGroupsBam}" "${addOrReplaceGroupsBam}"
mv "${tmpAddOrReplaceGroupsBai}" "${addOrReplaceGroupsBai}"
echo "succes moving files";
echo "## $(date) ## $0 Done "
Loading

0 comments on commit 6990ad5

Please sign in to comment.