Hi, I am trying to run a bash script for MLST at CGE (https://cge.cbs.dtu.dk/services/MLST/). I have fastq files and downloaded the MLST program. When I ran the program with single fastq file (R1 and R2) it is able to generate the results but I am getting problem with the batch run in the script. Please see the script below and the error message.
#!/usr/bin/env bash
if [ -z $1 ] ; then
echo "Hint: $0 Input_Directory_Containing_.fastq.gz Speciesname"
exit 1
fi
inputdir=$1
species=$2
export MLST_DB=/home/CGE_server/mlst/mlst_db
cd ~/HOME_MLST
for files in "$inputdir"/*r1.fastq.gz ; do
echo "Working on $files and ${files/r1.fastq.gz/r2.fastq.gz} for species $species"
#cp $files ${files/r1.fastq.gz/r2.fastq.gz} .
bfile=$(basename $files)
mkdir "${bfile%%r1.fastq.gz}"
sudo docker run --rm -it -v $MLST_DB:/database -v $(pwd):/workdir mlst -i $bfile ${bfile/r1.fastq.gz/r2.fastq.gz} -o ${bfile%%r1.fastq.gz} -s $species -x
echo "Finished working on $files"
done
ERROR:
$bash mlst.sh ecoli
Working on ecoli/*r1.fastq.gz and ecoli/*r2.fastq.gz for species
usage: mlst.py [-h] -i INFILE [INFILE ...] [-o OUTDIR] -s SPECIES
[-p DATABASE] [-t TMP_DIR] [-mp METHOD_PATH] [-x] [-q]
[-matrix]
mlst.py: error: argument -s/--species: expected one argument
Finished working on ecoli/*r1.fastq.gz
Hi, Thank you for your suggestions.
I am running the script. However, it shows below error.
error message:
Did you try thinking about what to do after seeing the hint and seeing the long answer I wrote? I specifically said "Your script expects the first command line arg to be the inputdir, and the second command line arg to be the species name." You only provided one command line argument, the species name, and it was in the wrong position. What's missing? What order should you put the arguments in?
Off course. I read your comments otherwise how I knew the error. As script expects the first command line arg to be the inputdir, and the second command line arg to be the species name, I am giving first argument mlst.sh and second ecoli.
Anyway I ran my script with the same running command ($bash mlst.sh ecoli) as inputdir (pwd) and got run.
inputdir=$(pwd) species=$1
You ran
bash mlst.sh species
.mlst.sh
is a file, not a directory.Correct:
bash mlst.sh inputdir species
Thank you for letting me know. I tried in this way also but it show following error. I am in working directory and giving the command (bash mlst.sh /home/MLST/ ecoli). Sorry I am new in bash scripting.