我正在整理一个 Snakemake slurm 工作流程,但我的工作目录因 slurm 输出文件变得混乱而遇到麻烦。我希望我的工作流程至少将这些文件定向到我的工作目录内的“slurm”目录。我目前的工作流程设置如下:
配置.yaml:
reads:
1:
2:
samples:
15FL1-2: /datasets/work/AF_CROWN_RUST_WORK/2020-02-28_GWAS/data/15FL1-2
15Fl1-4: /datasets/work/AF_CROWN_RUST_WORK/2020-02-28_GWAS/data/15Fl1-4
Run Code Online (Sandbox Code Playgroud)
集群.yaml:
localrules: all
__default__:
time: 0:5:0
mem: 1G
output: _{rule}_{wildcards.sample}_%A.slurm
fastqc_raw:
job_name: sm_fastqc_raw
time: 0:10:0
mem: 1G
output: slurm/_{rule}_{wildcards.sample}_{wildcards.read}_%A.slurm
Run Code Online (Sandbox Code Playgroud)
蛇文件:
configfile: "config.yaml"
workdir: config["work"]
rule all:
input:
expand("analysis/fastqc_raw/{sample}_R{read}_fastqc.html", sample=config["samples"],read=config["reads"])
rule clean:
shell:
"rm -rf analysis logs"
rule fastqc_raw:
input:
'data/{sample}_R{read}.fastq.gz'
output:
'analysis/fastqc_raw/{sample}_R{read}_fastqc.html'
log:
err = 'logs/fastqc_raw/{sample}_R{read}.out',
out = 'logs/fastqc_raw/{sample}_R{read}.err'
shell:
"""
fastqc {input} --noextract --outdir 'analysis/fastqc_raw' 2> {log.err} > {log.out}
"""
Run Code Online (Sandbox Code Playgroud)
然后我打电话:
snakemake --jobs 4 …Run Code Online (Sandbox Code Playgroud) 我目前有一个snakemake工作流程,需要使用lambda通配符,设置如下:
蛇文件:
configfile: "config.yaml"
workdir: config["work"]
rule all:
input:
expand("logs/bwa/{ref}.log", ref=config["refs"])
rule bwa_index:
input:
lambda wildcards: 'data/'+config["refs"][wildcards.ref]+".fna.gz"
output:
"logs/bwa/{ref}.log"
log:
"logs/bwa/{ref}.log"
shell:
"bwa index {input} 2&>1 {log}"
Run Code Online (Sandbox Code Playgroud)
配置文件:
work: /datasets/work/AF_CROWN_RUST_WORK/2020-02-28_GWAS
refs:
12NC29: GCA_002873275.1_ASM287327v1_genomic
12SD80: GCA_002873125.1_ASM287312v1_genomic
Run Code Online (Sandbox Code Playgroud)
这是可行的,但我不得不使用 hack 来获取 的输出bwa_index来处理 的输入all。我的技巧是生成一个日志文件作为 的一部分bwa_index,将日志设置为 的输出bwa_index,然后将 的输入设置all为这些日志文件。正如我所说,它有效,但我不喜欢它。问题在于 的真实输出bwa_index格式为,例如GCA_002873275.1_ASM287327v1_genomic.fna.sa. 因此,要指定这些输出文件,我需要使用 lambda 函数作为输出,如下所示:
rule bwa_index:
input:
lambda wildcards: 'data/'+config["refs"][wildcards.ref]+".fna.gz"
output:
lambda wildcards: 'data/'+config["refs"][wildcards.ref]+".fna.sa"
log:
"logs/bwa/{ref}.log"
shell:
"bwa index {input} 2&>1 {log}"
Run Code Online (Sandbox Code Playgroud)
然后使用带有 …