Python Snakemake删除--config值中的下划线?
我试图将名为samples的Python Snakemake删除--config值中的下划线?,python,snakemake,Python,Snakemake,我试图将名为samples的--config参数传递给snakemake函数。看起来不管我怎么传递,所有的下划线都被删除了?有什么建议吗,还是我做错了什么 snakemake-s snakefile.py all--configfile/share/biocore/keith/dennislab/snakemake/templates/tagseq.json--config samples=60_3_6, 或 snakemake-s snakefile.py all--configfile/sh
--config
参数传递给snakemake函数。看起来不管我怎么传递,所有的下划线都被删除了?有什么建议吗,还是我做错了什么
snakemake-s snakefile.py all--configfile/share/biocore/keith/dennislab/snakemake/templates/tagseq.json--config samples=60_3_6,
或
snakemake-s snakefile.py all--configfile/share/biocore/keith/dennislab/snakemake/templates/tagseq.json--config samples=“60_3_6”
或
snakemake-s snakefile.py all--configfile/share/biocore/keith/dennislab/snakemake/templates/tagseq.json--config samples='60_3_6'
对于snakefile中的config dictionary,它们都会生成这样的结果(请注意最后的samples参数)
{code>{u__________________________________________________________________________________________([('basename'、'/share/biocore/keith/dennislab')、('id'、'PE')、('fastqs'、'rhesus_tagseq')、('human_rrna_ref'、'/share/biocore/keith/workshop/rnaseq_示例/参考资料/human_rrna.fasta')、('star_ref'、'share/biocore/keith/dennislab/star/star.Overlap 100.gencode'))、'hts_star')、'([(‘注释’、‘这是为htspreproc>star运行一个样本’、(‘作业名称’、‘hts_star’)、(‘n’,1)、(‘ntasks’,9)、(‘分区’、‘生产’、(‘时间’、‘120’、(‘mem’、‘32000’)、(‘注释2’、‘样本名称和分析类型将插入到.out和.err’、(‘输出’、‘slurm_out/hts_star’,('error','slurm_out/hts_star_.err'),('mail-type','NONE'),('mail-user','kgmitchell@ucdavis.edu“)],“示例”:(6036,)}
Snakemake通过将--config
键/值对的值作为输入依次传递给每个函数来评估该值:
parsers = [int, float, eval, str]
在Python中计算数值文本时
因此,60\u 3\u 6
作为一个整数进行计算,因为int
在str
之前进行了尝试:
>>> for p in parsers:
... print(p('60_3_6'))
...
6036
6036.0
6036
60_3_6
(在问题的第一个示例中,60_3_6,
作为值传递;在这种情况下,eval
返回一个元组,其中包含6036
作为其唯一元素,如配置值转储中所示)
要解决这个问题,您需要传递一个值,该值只能由str
成功处理
另一个可能的解决方法是传递一个可调用的
lambda : '60_3_6'
由于snakemake将使用一个包装器脚本,但是我不知道如何从配置文件或命令行执行此操作,我认为您需要直接从python代码调用snakemake的main
函数(可能创建一个包装器脚本?)。这种“双引号”似乎有效:
snakemake --config samples='"10_13"'
它也适用于多个样本:
snakemake --config samples='"10_13", "foo", "19_19"'
虚拟蛇形文件:
samples= config['samples']
rule all:
input:
expand('{sample}.txt', sample= samples),
rule one:
output:
'{sample}.txt',
shell:
r"""
touch {output}
"""