我开发了MOSCA,一个元组学分析管道(MG和MT),可通过Bioconda获得。我想把它转换成snakemake,因为它很容易让MOSCA通过API同时运行一些访问和一些计算要求很高的任务。此外,我认为这将有助于更好地将工具塑造成标准格式
我的问题是,MOSCA有很多参数,必须将这些参数传输到配置文件中。虽然这对于大多数参数来说是微不足道的,但同时输入MG和MT文件则更为棘手。此外,莫斯卡将样品放在一起考虑。所以我创建了一个示例文件samples.tsv
MG files MT files Sample
path/to/mg_R1.fastq,path/to/mg_R2.fastq path/to/mt_R1.fastq,path/to/mt_R2.fastq Sample
我希望Snakefile读取它并保留“样本”信息。下面的示例包括MG预处理和管道的组装,其中preprocess.py
和assembly.py
脚本包含相应的功能。
这是Snakefile
from pandas import read_table
configfile: "config.json"
rule all:
input:
expand("{output}/Assembly/{experiment[1][Sample]}/contigs.fasta",
output = config["output"], experiment = read_table(config["experiments"], "\t").iterrows())
rule mg_preprocess: # mt_preprocess make same, but data = mrna?
input:
list(expand({experiment}[1]["MG files"], experiment = read_table(config["experiments"], "\t").iterrows()))[0]
output:
expand("{output}/Preprocess/Trimmomatic/quality_trimmed_{name}{fr}_paired.fq",
fr = ['forward', 'reverse'], output = config["output"], name = 'pretty_commune')
threads:
config["threads"]
run:
shell("""python preprocess.py -i {reads} -t {threads} -o {output}
-adaptdir MOSCA/Databases/illumina_adapters -rrnadbs MOSCA/Databases/rRNA_databases""",
output = config["output"])
rule assembly:
input:
expand("{output}/Preprocess/Trimmomatic/quality_trimmed_{name}{fr}_paired.fq",
fr = ['forward', 'reverse'], output = config["output"], name = 'pretty_commune')
output:
expand("{output}/Assembly/{experiment[1][Sample]}/contigs.fasta",
output = config["output"], experiment = read_table(config["experiments"], "\t").iterrows())
threads:
config["threads"]
run:
reads = ",".join(map(str, input))
shell("python assembly.py -r {input} -t {threads} -o {output}/Assembly/{sample} -a {assembler}",
output = config["output"], sample = config["experiments"][1]["sample"],
assembler = config["assembler"])
这是config.json
{
"output":
"snakemake_learn",
"threads":
14,
"experiments":
"samples.tsv",
"assembler":
"metaspades"
}
我得到了错误
NameError in line 12 of /path/to/Snakefile:
name 'experiment' is not defined
File "/path/to/Snakefile", line 12, in <module>
实验是如何定义的
我不知道你想干什么,但请告诉我电话号码
看起来太复杂了。我会将示例表放在一个数据框架中,并使用它,而不是每次都使用来自
read_table
的迭代器。例如:无论如何,我认为错误
name 'experiment' is not defined
是因为list(expand({experiment}[1]["MG files"]
中的{experiment}
不是可以用实际值替换的字符串编辑:
事实上
expand('{experiment}', experiment= ss["MG files"][0]),
这行没有多大意义。。。这和ss["MG files"][0]
一样相关问题 更多 >
编程相关推荐