我想知道如何管理蛇文件中的路径。假设我有这样的配置:
current_dir
current_dir/snakefiles
current_dir/configfiles
Run Code Online (Sandbox Code Playgroud)
我这样执行我的工作流程:
current_dir$ snakemake -s snakefiles/my_snakefile --configfile configfiles/my_config.yml
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用全局变量获取 Snakefile 的路径workflow.snakefile,但我还想获取:
current_dir如何实现这一目标?Snakemake 中还有其他我不知道的全局变量吗?
谢谢
我从snakemake开始。我设法定义了一些可以独立运行的规则,但不能在工作流程中运行。也许问题在于它们有不相关的输入和输出。
我目前的工作流程是这样的:
configfile: './config.yaml'
rule all:
input: dynamic("task/{job}/taskOutput.tab")
rule split_input:
input: "input_fasta/snp.fa"
output: dynamic("task/{job}/taskInput.fa")
shell:
"rm -Rf tasktmp task; \
mkdir tasktmp task; \
split -l 200 -d {input} ./tasktmp/; \
ls tasktmp | awk '{{print \"mkdir task/\"$0}}' | sh; \
ls tasktmp | awk '{{print \"mv ./tasktmp/\"$0\" ./task/\"$0\"/taskInput.fa\"}}' | sh"
rule task:
input: "task/{job}/taskInput.fa"
output: "task/{job}/taskOutput.tab"
shell: "cp {input} {output}"
rule make_parameter_file:
output:
"par/parameters.txt
shell:
"rm -Rf par;mkdir par; \
echo \"\
minimumFlankLength=5\n\
maximumFlankLength=200\n\
alignmentLengthDifference=2\
allowedMismatch=4\n\
allowedProxyMismatch=2\n\
allowedIndel=3\n\
ambiguitiesAsMatch=1\n\" …Run Code Online (Sandbox Code Playgroud) 是否可以使用命令行开关将snakemake 文件和/或规则文件配置为仅在某些情况下执行某些规则。
为了详细说明,假设我的规则文件夹中有这些规则:
是否可以通过这种方式配置/执行工作流程:
snakemake --user_option 2a将导致规则 1、规则 2a、规则 3 被调用snakemake --user_option 2b将导致规则 1、规则 2b、规则 3 被调用提前致谢。
我有一个 Snakemake 工作流程,其中包含运行另一个“内部”snakemake 工作流程的规则。
有时内部工作流程的某个规则失败,就意味着内部工作流程失败。因此,output内部工作流程下列出的所有文件都会被外部工作流程删除,即使创建这些文件的内部工作流程的规则成功完成也是如此。
有没有办法防止snakemake删除失败规则的输出?或者也许您可以建议另一种解决方法?
一些注意事项:
protected,但这没有帮助。exit 0到内部工作流程的调用末尾,以使 Snakemake 认为它已成功完成,像这样:
rule run_inner:
input:
inputs...
output:
outputs...
shell:
"""
snakemake -s inner.snakefile
exit 0
"""
Run Code Online (Sandbox Code Playgroud)
但输出仍然被删除。
将不胜感激任何帮助。谢谢!
我的蛇文件看起来像这样。
rule do00_download_step01_download_:
input:
output:
"data/00_download/scores.pqt"
run:
from lib.do00_download import do00_download_step01_download_
do00_download_step01_download_()
rule do00_download_step02_get_the_mean_:
input:
"data/00_download/scores.pqt"
output:
"data/00_download/cleaned.pqt"
run:
from lib.do00_download import do00_download_step02_get_the_mean_
do00_download_step02_get_the_mean_()
rule do01_corr_step01_correlate:
input:
"data/00_download/cleaned.pqt"
output:
"data/01_corr/corr.pqt"
run:
from lib.do01_corr import do01_corr_step01_correlate
do01_corr_step01_correlate()
rule do95_plot_step01_correlations:
input:
"data/01_corr/corr.pqt"
output:
"plot/heatmap.png"
run:
from lib.do95_plot import do95_plot_step01_correlations
do95_plot_step01_correlations()
rule do95_plot_step02_plot_dist:
input:
"data/00_download/cleaned.pqt"
output:
"plot/dist.png"
run:
from lib.do95_plot import do95_plot_step02_plot_dist
do95_plot_step02_plot_dist()
rule do99_figures_step01_make_figure:
input:
"plot/dist.png"
"plot/heatmap.png"
output:
"figs/fig01.svg"
run:
from lib.do99_figures import do99_figures_step01_make_figure
do99_figures_step01_make_figure()
rule all:
input:
"figs/fig01.svg"
Run Code Online (Sandbox Code Playgroud)
我已按顺序排列规则,希望这能确保所有步骤都按该顺序运行。但是,当我运行时snakemake,它只运行第一条规则,然后退出。 …
我在函数中索引我的snakemake通配符时遇到问题.由于某种原因,变量在"通配符"列表中的存储顺序各不相同.我使用该函数为我的一个规则生成输入文件的路径,并且随着正确值的位置发生变化,规则每次查询只会成功一次.如何在"通配符"列表中控制或修复通配符的位置?我添加了我的Snakefile的相关内容.
谢谢你,zuup
#!/usr/bin/env python3
import glob
import re
R_BIN = "Rscript"
pop = "lineA lineB".split()
group = "test control".split()
chrom = "X Y".split()
def getInput(Wildcards):
pop = str(Wildcards[0])
group = str(Wildcards[1])
chrom = str(Wildcards[2])
path = "Resources/bed/" + pop + "_" + group + r"_rep[1-5]/" + pop + "_" + group + r"_rep[1-5]_chr" + chrom + ".bed"
return(glob.glob(path))
rule BED2BS:
input:
getInput
output:
wd + "Resources/bs/{pop}_{group}/{group}_chr{chrom}.RDS"
shell:
R_BIN + " Scripts/Script1.R {input} {output}"
Run Code Online (Sandbox Code Playgroud) 我想在snakemake的帮助下对不同的输入文件多次执行R脚本。为此,我尝试使用 expand 函数。
我对snakemake比较陌生,当我正确理解它时,扩展功能为我提供了例如多个输入文件,然后所有输入文件都可以通过{input}.
是否可以对文件一一调用shell命令?
假设我在 config.yaml 中有这个定义:
types:
- "A"
- "B"
Run Code Online (Sandbox Code Playgroud)
这将是我的示例规则:
rule manual_groups:
input:
expand("chip_{type}.bed",type=config["types"])
output:
expand("data/p_chip_{type}.model",type=config["types"])
shell:
"Rscript scripts/pre_process.R {input}"
Run Code Online (Sandbox Code Playgroud)
这将导致命令:
Rscript scripts/pre_process.R chip_A.bed chip_B.bed
Run Code Online (Sandbox Code Playgroud)
是否可以使用如下两种类型独立调用命令两次:
Rscript scripts/pre_process.R chip_A.bed
Rscript scripts/pre_process.R chip_B.bed
Run Code Online (Sandbox Code Playgroud)
提前感谢您的任何帮助!