我对使用HPC和SLURM完全陌生,因此我非常感谢这里的一些指导。
我需要迭代运行如下所示的命令
kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-SRR3225412" \
"SRR3225412_1.fastq.gz" \
"SRR3225412_2.fastq.gz"
SRR3225412
部分在每次交互中都会有所不同
问题是,正如我发现的那样,我不能只是将此附加到sbatch
命令的末尾
sbatch --nodes=1 \
--ntasks-per-node=1 \
--cpus-per-task=1 \
kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-SRR3225412" \
"SRR3225412_1.fastq.gz" \
"SRR3225412_2.fastq.gz"
此命令无效。我得到了错误
sbatch: error: This does not look like a batch script. The first
sbatch: error: line must start with #! followed by the path to an interpreter.
sbatch: error: For instance: #!/bin/sh
我想问一下,如何运行sbatch
命令,指定其运行参数,并为我要使用的kallisto
程序添加命令行参数?最后,我想拥有类似的东西
#!/bin/bash
for sample in ...
do
sbatch --nodes=1 \
--ntasks-per-node=1 \
--cpus-per-task=1 \
kallistoCommandOnSample --arg1 a1 \
--arg2 a2 arg3 a3
done
答案 0 :(得分:2)
错误sbatch: error: This does not look like a batch script.
是因为sbatch
期望提交脚本。它是批处理脚本,通常是Bash脚本,其中Slurm将以#SBATCH
开头的注释解释为选项。
因此,提交作业的典型方法是创建文件,我们将其命名为submit.sh
:
#! /bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-SRR3225412" \
"SRR3225412_1.fastq.gz" \
"SRR3225412_2.fastq.gz"
然后用
提交sbatch submit.sh
如果您要提交多个相似的工作,则使用job array出于多种原因是有益的。您想要创建的循环可以替换为单个提交脚本,如下所示:
#! /bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --array=1-10 # Replace here with the number of iterations in the loop
SAMPLES=(...) # here put what you would loop over
CURRSAMPLE=${SAMPLE[$SLURM_ARRAY_TASK_ID]}
kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-${CURRSAMPLE}" \
"${CURRSAMPLE}_1.fastq.gz" \
"${CURRSAMPLE}_2.fastq.gz"
@Carles Fenoy指出,如果您不想使用提交脚本,则可以使用--wrap
的{{1}}参数:
sbatch