/home/biol/perl5:是一个目录

/home/biol/perl5:是一个目录

下面的脚本崩溃了:

#!/bin/bash
#usage: sh oxford_pbs.sh ref.fa AA.fasta hybrid.gff3

cov=50
ide=100


for ((i=70;i<=${ide};i++));
do
  input=$(basename $(echo ${2} | sed 's|.gff3||g'))

  #cat <<EOF
  qsub <<EOF
#!/bin/bash -l

#PBS -N filter
#PBS -l walltime=20:00:00
#PBS -j oe
#PBS -l select=1:ncpus=1:mem=30G
#PBS -M [email protected]
##PBS -m bea

cd \$PBS_O_WORKDIR
module load bioperl/1.7.1-foss-2017a r/3.4.2-bioconductor-foss-2017a
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"

agat_sp_extract_sequences.pl --gff ${2}-ide${i}-cov${cov}-best-hit.gff3 -f ${1} -p -o ${2}-ide${i}-cov${cov}-best-hit.AA.fasta
EOF
done

出现此错误:

/var/spool/PBS/mom_priv/jobs/8352088.pbs.SC: line 24: /home/biol/perl5: Is a directory
/var/spool/PBS/mom_priv/jobs/8352088.pbs.SC: line 27: agat_sp_extract_sequences.pl: command not found

但是,这两个命令在命令行上运行没有任何问题:

> module load bioperl/1.7.1-foss-2017a r/3.4.2-bioconductor-foss-2017a
> eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
> 
> agat_sp_extract_sequences.pl --help

 ------------------------------------------------------------------------------
|   Another GFF Analysis Toolkit (AGAT) - Version: v0.1.0                      |
|   https://github.com/NBISweden/AGAT                                          |
|   National Bioinformatics Infrastructure Sweden (NBIS) - www.nbis.se         |
 ------------------------------------------------------------------------------

为什么 Perl 脚本不在 Bash 脚本内运行?

先感谢您

答案1

问题是$(perl ...)命令替换将立即完成,因为您已经完成qsub <<EOF而不是qsub <<'EOF'为了${i}扩展。

perl 将输出可以包含空格的行,例如

PERL_MB_OPT="--install_base \"/home/user/perl5\""

但是当您在最终脚本的执行中评估这些时,它将变成

PERL_MB_OPT=--install_base "/home/user/perl5"

/home/user/perl5你会得到关于目录的错误。最简单的解决方案是将 perl 推迟到以后:

eval "\$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"

相关内容