Skip to content

Commit

Permalink
added threading option to cdiff for kraken submodule in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RAHenriksen committed Oct 24, 2024
1 parent 4a5678e commit c239c16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 14 additions & 4 deletions cdifftyping.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ process_inputs() {
read2="$2"
shift 2
;;
-c)
-t)
threads="$2"
shift 2
;;
-c)
contigs="$2"
shift 2
;;
Expand All @@ -42,7 +46,7 @@ process_inputs() {
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [-i <sampleid>] [-R1 <read1>] [-R2 <read2>] [-c <contigs.fasta>] [-o <outdir>] -db <db> -update <update:yes/no>"
echo "Usage: $0 [-i <sampleid>] [-R1 <read1>] [-R2 <read2>] [-c <contigs.fasta>] [-o <outdir>] -db <db> -t <threads> -update <update:yes/no>"
exit 1
;;
esac
Expand All @@ -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 <sampleid>] [-R1 <read1>] [-R2 <read2>] [-c <contigs.fasta>] [-o <outdir>] -db <db> -update <update:yes/no>"
echo "Usage: $0 [-i <sampleid>] [-R1 <read1>] [-R2 <read2>] [-c <contigs.fasta>] [-o <outdir>] -db <db> -t <threads> -update <update:yes/no>"
echo
exit 1
fi
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit c239c16

Please sign in to comment.