我有一个依赖输入参数(带有getopts)的大脚本。这些参数之一是一个包含文件的目录(均名为* bam)。此脚本分为两部分:
现在,从计算上来说,part1最初非常快。所以我的设置是:
但是,由于现在我需要分析的文件比最初计划的要多得多,所以我意识到Part1的计算量也很大-因此,我也需要在HPC上运行它。
所以我的问题是:
要清楚,这是我的脚本的示例:
#!/usr/bin/bash
# PART 0: accept all input arguments
USAGE() { echo "Usage: bash $0 [-b <in-bam-files-dir>] [-o <out-dir>] [-c <chromlen>]" 1>&2; exit 1; }
if (($# == 0)); then
USAGE
fi
# Use getopts to accept each argument
while getopts ":b:o:c:h" opt
do
case $opt in
b ) BAMFILES=$OPTARG
;;
o ) OUTDIR=$OPTARG
;;
c ) CHROMLEN=$OPTARG
;;
h ) USAGE
;;
\? ) echo "Invalid option: -$OPTARG exiting" >&2
exit
;;
: ) echo "Option -$OPTARG requires an argument" >&2
exit
;;
esac
done
# PART1: calculate this unique number
NUMBER=0
for i in $(ls $BAMFILES/*.bam)
do
make some calculations on each file to obtain a number ...
keep only the smallest found number and assign its value to $NUMBER
done
echo "Final number is ${NUMBER} "
# PART2: Using $NUMBER that we found above, submit a job for each *bam file
for i in $(ls $BAMFILES/*bam)
do
if [ ! -f ${OUTDIR}/${SAMPLE}.bw ];
then
command=" command -options -b $NUMBER $i"
echo $command | qsub -V -cwd -o $OUTDIR -e $OUTDIR -l tmem=6G -l h_vmem=6G -l h_rt=3600 -N result_${SAMPLE}
fi
done
答案是“取决于”。您可以将HPC集群设置为具有执行节点能够提交作业的能力,但这不是必需的。听起来像是对本地HPC管理员的快速提问将为您提供明确的答案。或者,您可以尝试执行快速脚本,该脚本除了提交第二份工作外什么也不做,看它是否有效。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句