问题
I have this script which works fine when I call it with sh but it fails when I use qsub. Could someone please help me debug this? I can't seem to find an answer online
#!/bin/bash
#$ -S /bin/bash
#$ -V
#$ -cwd
#$ -l h_vmem=6G
#$ -N MHCIp
if [ $# -lt 2 ]
then
echo need 2 arguments
echo "USAGE : qsub run_MHCIprediction.sh <input_peptide_file> <MHCI_allele_file>"
exit 0
fi
input_file=$1
allele_file=$2
output_prefix=`echo ${input_file} | awk -F"." '{print $1}'`
while read -u 10 allele strip_allele
do
/inside/depot4/users/arjun/tools/IEDB/mhc_i/src/predict_binding.py \
IEDB_recommended \
${allele} \
9 \
${input_file} > ${output_prefix}"_"${strip_allele}".tsv"
done 10<${allele_file}
input_file contains values such as
>pept1
ABDGSHADSDJASDAJ
>pept2
AHSYEHDBDJSJAKSK
allele_file looks like
HLA-A*01:01 HLA-A_01_01
HLA-B*03:02 HLA-B_03_02
回答1:
In case anyone else runs across this, the script in question is from the IEDB MHC class I binding prediction scripts, and the error is introduced when the script tries to read from stdin, which is piped from /dev/null/ in the context of an LSF job, and the end result is adding an empty string to the end of the arguments list.
The relevant section of code looks like this, and the line you'll need to add is "args = filter(None, args)"
...
parser = OptionParser(usage=usage)
parser.add_option("-m", dest="filename_mhc",
help="FILE containing a single MHC sequence in fasta format.", metavar="FILE")
(options, args) = parser.parse_args()
# If there's input ready, do something, else do something
# else. Note timeout is zero so select won't block at all.
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
infile = sys.stdin.readline().strip()
args.append(infile)
args = filter(None, args) #strip blank arguments that might be introduced by LSF
if (len(args) == 0): self.commandline_help()
...
来源:https://stackoverflow.com/questions/26661804/shell-variables-in-qsub