From c239c16eb1f7d0dc6da9055cc26622f0c6355599 Mon Sep 17 00:00:00 2001 From: RAHenriksen Date: Thu, 24 Oct 2024 14:55:18 +0200 Subject: [PATCH] added threading option to cdiff for kraken submodule in testing --- Makefile | 2 +- cdifftyping.sh | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ca576ab..bfb4053 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ test: serotyping md5serotypecheck processing md5processcheck serotyping: @BIN_PATH=$$(dirname $$(which python)) && \ echo "Conda environment bin path: $$BIN_PATH" && \ - bash cdifftyping.sh -i ERR142064 -R1 test/ERR142064_1_subset.fastq.gz -R2 test/ERR142064_2_subset.fastq.gz -c test/ERR142064_subset.fasta -o test -db db -update no + bash cdifftyping.sh -i ERR142064 -R1 test/ERR142064_1_subset.fastq.gz -R2 test/ERR142064_2_subset.fastq.gz -t 1 -c test/ERR142064_subset.fasta -o test -db db -update no # Step 2: Check MD5 checksum md5serotypecheck: diff --git a/cdifftyping.sh b/cdifftyping.sh index 233464a..a6d732f 100755 --- a/cdifftyping.sh +++ b/cdifftyping.sh @@ -24,7 +24,11 @@ process_inputs() { read2="$2" shift 2 ;; - -c) + -t) + threads="$2" + shift 2 + ;; + -c) contigs="$2" shift 2 ;; @@ -42,7 +46,7 @@ process_inputs() { ;; *) echo "Unknown option: $1" - echo "Usage: $0 [-i ] [-R1 ] [-R2 ] [-c ] [-o ] -db -update " + echo "Usage: $0 [-i ] [-R1 ] [-R2 ] [-c ] [-o ] -db -t -update " exit 1 ;; esac @@ -51,7 +55,7 @@ process_inputs() { # Check if the required arguments -db and -update are provided if [ -z "$db" ] || [ -z "$update" ]; then echo "Missing required arguments!" - echo "Usage: $0 [-i ] [-R1 ] [-R2 ] [-c ] [-o ] -db -update " + echo "Usage: $0 [-i ] [-R1 ] [-R2 ] [-c ] [-o ] -db -t -update " echo exit 1 fi @@ -62,6 +66,11 @@ process_inputs "$@" echo -e "\n# Running..." echo "$0" "$@" +# Set default threads to 1 if not provided +if [ -z "$threads" ]; then + threads=1 + echo "Threads not provided. Defaulting to 1." +fi ## Main # Hardcoded paths @@ -117,6 +126,7 @@ if [ -n "$sampleid" ] || [ -n "$read1" ] || [ -n "$read2" ] || [ -n "$contigs" ] [ -n "$outdir" ] && echo "Output Directory: $outdir" echo "Database: $db" echo "Update: $update" + echo "threads: $threads" else echo -e "\n# No further task to be done..." exit 1 @@ -135,7 +145,7 @@ prefix="$spcdifffbidir/$sampleid" # prefix for indexes #Filtering reads with serum_readfilter echo -e "\n# Filtering reads with serum_readfilter..." -cmd="serum_readfilter runfilter kraken -R1 ${read1} -R2 ${read2} -o $spcdifffbidir/cdifffiltered -db $serumdb" +cmd="serum_readfilter runfilter kraken -R1 ${read1} -R2 ${read2} -t ${threads} -o $spcdifffbidir/cdifffiltered -db $serumdb" r1="$spcdifffbidir/cdifffiltered_R1.fastq" r2="$spcdifffbidir/cdifffiltered_R2.fastq" filtered_reads="$r1 $r2"