0

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.

Rotomegax
  • 25
  • 5
  • 1
    You're missing some quotes. Run your script through http://shellcheck.net and fix what it finds; if that doesn't fix it, add `set -x` to your script to log how it's actually invoking your program, and [edit] the question to add the output to your question, with the `repr()` of the Python array that works when passed to `subprocess.Popen`. – Charles Duffy Aug 24 '22 at 03:26
  • Hi, I added the log from set-x, can you check through it for me pls? – Rotomegax Aug 24 '22 at 03:39
  • I closed your question. The `set -x` output you posted has telltale signs of your script having `\r` line endings. Line 2 and line 8 both have them, and probably other lines too. (Probably the entire file.) Read the [top answer](https://stackoverflow.com/a/39527986/68587) in the duplicate question and try the solutions. Don't worry about the question not being identical. The answer will help you. – John Kugelman Aug 24 '22 at 04:06
  • Getting back here (my above comment was the last thing I did before signing off for the night yesterday), and John K's diagnosis is absolutely correct. – Charles Duffy Aug 24 '22 at 13:46

0 Answers0