我编写了一个执行sortmeRNA版本4.2.0的snakemake管道。管道如下,当我为1个示例运行它时,它可以完美运行:
SAMPLES = ['A']
READS=["R1", "R2"]
rule all:
input:
expand("Clean/{exp}.clean.{read}.fastq.gz", exp = SAMPLES, read = READS)
rule sortmeRNA:
input:
one = "{SAMPLES}.R1.trimd.fastq.gz",
two = "{SAMPLES}.R2.trimd.fastq.gz"
output:
one = "Clean/{SAMPLES}.clean.R1.fastq.gz",
two = "Clean/{SAMPLES}.clean.R2.fastq.gz"
params:
bac16s = "rRNA_databases/silva-bac-16s-id90.fasta",
bac23s = "rRNA_databases/silva-bac-23s-id98.fasta",
acc = "--num_alignments 1 --threads 16 --fastx --other -v"
message: "---Sorting reads with rRNA databases---"
shell:'''
rm -rf {SAMPLES}/kvdb;\
sortmerna -ref {params.bac16s} -ref {params.bac23s}\
-reads {input.one} -reads {input.two}\
--workdir {SAMPLES}\
{params.acc} && \
echo "deinterleaving...." &&\
bash deinterleave_fastq.sh < {SAMPLES}/out/other.fastq {output.one} {output.two} compress && \
echo "moving log and removing folder.." && mkdir -p Sort_log && mv {SAMPLES}/out/aligned.log Sort_log/{SAMPLES}.log &&\
rm -rf {SAMPLES}
'''
最后一部分执行以下操作:
- 清除{SAMPLES} / kvdb(如果存在)
- 运行sortmeRNA
- 检查{SAMPLES} /out/other.fastq
- 运行“ deinterleave_fastq.sh”并将R1和R2放入名为“ Clean”的文件夹中
- 将'aligned.log'移动到Sort_log并将其重命名为{SAMPLES} .log
- 删除{SAMPLES}文件夹。
本质上,发生的事情是,对于每个“样本”,它都会过滤出fastq文件,仅保留所需的输出并清除其他文件夹。
提交时附有:
snakemake -ps sortmeRNAv4.2.0.snakefile --cluster "sbatch -n 1 --time=02:00:00 -c 16" --jobs 1
当我执行以下操作时,就会出现问题:
SAMPLES = ['A','B']
snakemake -ps sortmeRNAv4.2.0.snakefile --cluster "sbatch -n 1 --time=02:00:00 -c 16" --jobs 2
作业已提交,但陷入错误
rm -rf AB
我知道,SAMPLES被A&B取代,因为它尚未生成,并且每次清除文件夹时都无法满足条件。如何修改代码,使每个作业并行运行而不会发生冲突?即在任何给定时间,该命令应仅
批处理命令集
SAMPLES = A,完成流程SAMPLES = B,完成流程
而不要混在一起。
提前致谢。
这里的问题是,{SAMPLES}
在您的输入和输出中是通配符。在外壳程序中,它被视为规则上方定义的全局变量。
您应该{wildcards.SAMPLES}
在shell部分中使用:
rule sortmeRNA:
input:
one = "{SAMPLES}.R1.trimd.fastq.gz",
two = "{SAMPLES}.R2.trimd.fastq.gz"
output:
one = "Clean/{SAMPLES}.clean.R1.fastq.gz",
two = "Clean/{SAMPLES}.clean.R2.fastq.gz"
params:
bac16s = "rRNA_databases/silva-bac-16s-id90.fasta",
bac23s = "rRNA_databases/silva-bac-23s-id98.fasta",
acc = "--num_alignments 1 --threads 16 --fastx --other -v"
message: "---Sorting reads with rRNA databases---"
shell:'''
rm -rf {wildcards.SAMPLES}/kvdb;\
sortmerna -ref {params.bac16s} -ref {params.bac23s}\
-reads {input.one} -reads {input.two}\
--workdir {wildcards.SAMPLES}\
{params.acc} && \
echo "deinterleaving...." &&\
bash deinterleave_fastq.sh < {wildcards.SAMPLES}/out/other.fastq {output.one} {output.two} compress && \
echo "moving log and removing folder.." && mkdir -p Sort_log && mv {wildcards.SAMPLES}/out/aligned.log Sort_log/{wildcards.SAMPLES}.log &&\
rm -rf {wildcards.SAMPLES}
'''
您还应该避免将通配符命名为全局python变量。您的规则一次只处理一个样本,因此只需调用它{sample}
,SAMPLES
并将规则上面定义的python变量保留即可。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句