I have made a bash script for automation of alignment, the first part of the script is input args and execute alignment through bwa mem.
#!bin/bash
inputfilename=$1
ref=$2
# Name analysis
fastqname=$(basename "$inputfilename")
filename=${fastqname%%.*}
bwa mem -t 32 $ref $inputfilename > "process/"$filename".sam"
However, when execute the bash script, bwa mem returned with this error
[E::bwa_idx_load_from_disk] fail to locate the index files
Which indicated that it cannot found all index of the reference file that I previously made from bwa index command. However, when I type the name of the reference file to bwa mem on console or through subprocess from Python, this error not appeared.
EDIT 1: Follow instruction of @Charles Duffy I added set -x to my script and this is the log
ubuntu@bk-at:~/Documents/test/15$ bash treat_align.sh ref/chr21.fa raw/S200021517_L01_10.fq.gz
: invalid optionline 2: set: -
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
treat_align.sh: line 8: $'\r': command not found
[E::bwa_idx_load_from_disk] fail to locate the index files
p/s: IDK who closed my question but it DOES NOT THE SAME with the one suggest. The one suggest is from MacOS, meanwhile I worked with sublime on Ubuntu Terminal, not Mac. If any mods saw this, please reopen my post. I'm very desperate right now, Python script worked for me but it consumed ram and added more weight to the pipeline, thus make it slower. Plus not everyone on my working place knew how to install the right Python version.