I just started to bash and I have been stuck for sometime on a simple if;then statement. I use bash to run QIIME commands which are written in python. These commands allow me to deal with microbial DNA. From the raw dataset from the sequencing I first have to first check if they match the format that QIIME can deal with before I can proceed to the rest of the commands.
module load QIIME/1.9.1-foss-2016a-Python-2.7.11
echo 'checking mapping file and demultiplexing'
validate_mapping_file.py -m $PWD/map.tsv -o $PWD/mapcheck > tmp.txt
n_words=`wc -w tmp.txt`
echo "n_words:"$n_words
if [ n_words = '9 temp.txt' ];then
split_libraries_fastq.py -i $PWD/forward_reads.fastq.gz -b $PWD/barcodes.fastq.gz -m $PWD/map.tsv -o $PWD/demultiplexed
else
echo 'Error(s) in map'
exit 1
fi
If the map is good I expect the following output (9 words):
No errors or warnings were found in mapping file.
If it is bad (16 words):
Errors and/or warnings detected in mapping file. Please check the log and html file for details.
I want to used this output to condition the following commands split_libraries_fastq.py.
I tried many different version of the if;then statement, asked help around but nothing seems to be working. Anyone of you had an idea of why the 'then' command is not ran? Also I run it through a cluster.
Here is the output when my map is good, the second command is not ran:
checking mapping file and demultiplexing
n_words:9 tmp.txt
Error(s) in map
Thanks