Snakemake 删除 --config 值中的下划线?
Snakemake removes underscores in --config values?
我正在尝试将一个名为 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 /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 中的配置字典,所有结果都会产生这样的结果(注意最后的 samples 参数。
{'__default__': OrderedDict([('__comment1', 'running_locally=[True,False] ~ type=[PE,SE,tagseq]'), ('running_locally', 'False'), ('type', 'tagseq'), ('__comment2', 'Path to the file containing a column of sample names'), ('samples_file', '/share/biocore/keith/dennislab/rhesus_tagseq/samples.txt')]), 'project': OrderedDict([('basename', '/share/biocore/keith/dennislab'), ('id', 'PE'), ('fastqs', 'rhesus_tagseq'), ('human_rrna_ref', '/share/biocore/keith/workshop/rnaseq_examples/References/human_rrna.fasta'), ('star_ref', '/share/biocore/keith/dennislab/star.overlap100.gencode')]), 'hts_star': OrderedDict([('__comment', 'This is for running one sample for htspreproc > star'), ('job-name', 'hts_star_'), ('n', 1), ('ntasks', 9), ('partition', 'production'), ('time', '120'), ('mem', '32000'), ('__comment2', 'The name of the sample and analysis type will be inserted before .out and .err'), ('output', 'slurm_out/hts_star_.out'), ('error', 'slurm_out/hts_star_.err'), ('mail-type', 'NONE'), ('mail-user', 'kgmitchell@ucdavis.edu')]), 'samples': (6036,)}
Snakemake 通过将 --config
key/value 对的值作为输入传递给 this list 中的每个函数来求值,依次为:
parsers = [int, float, eval, str]
计算 Python 中的数字文字时 [u]nderscores are ignored for determining the numeric value of the literal.
因此,60_3_6
被评估为整数,因为 int
在 str
:
之前被尝试
>>> for p in parsers:
... print(p('60_3_6'))
...
6036
6036.0
6036
60_3_6
(在问题的第一个示例中,60_3_6,
作为值传递;在本例中,eval
returns 一个包含 6036
作为其唯一值的元组元素,如配置值的转储所示)。
要解决这个问题,您需要传递一个只能由 str
成功处理的值。
另一种可能的解决方法是传递一个可调用的
lambda : '60_3_6'
因为 snakemake 将使用 callable instead of the result of processing parsers 但是我看不到如何从配置文件或命令行完成此操作,我认为您需要直接调用 snakemake 的 main
函数来自 python 代码(也许创建一个包装脚本?)。
这个"double quoting"似乎有效:
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}
"""
我正在尝试将一个名为 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 /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 中的配置字典,所有结果都会产生这样的结果(注意最后的 samples 参数。
{'__default__': OrderedDict([('__comment1', 'running_locally=[True,False] ~ type=[PE,SE,tagseq]'), ('running_locally', 'False'), ('type', 'tagseq'), ('__comment2', 'Path to the file containing a column of sample names'), ('samples_file', '/share/biocore/keith/dennislab/rhesus_tagseq/samples.txt')]), 'project': OrderedDict([('basename', '/share/biocore/keith/dennislab'), ('id', 'PE'), ('fastqs', 'rhesus_tagseq'), ('human_rrna_ref', '/share/biocore/keith/workshop/rnaseq_examples/References/human_rrna.fasta'), ('star_ref', '/share/biocore/keith/dennislab/star.overlap100.gencode')]), 'hts_star': OrderedDict([('__comment', 'This is for running one sample for htspreproc > star'), ('job-name', 'hts_star_'), ('n', 1), ('ntasks', 9), ('partition', 'production'), ('time', '120'), ('mem', '32000'), ('__comment2', 'The name of the sample and analysis type will be inserted before .out and .err'), ('output', 'slurm_out/hts_star_.out'), ('error', 'slurm_out/hts_star_.err'), ('mail-type', 'NONE'), ('mail-user', 'kgmitchell@ucdavis.edu')]), 'samples': (6036,)}
Snakemake 通过将 --config
key/value 对的值作为输入传递给 this list 中的每个函数来求值,依次为:
parsers = [int, float, eval, str]
计算 Python 中的数字文字时 [u]nderscores are ignored for determining the numeric value of the literal.
因此,60_3_6
被评估为整数,因为 int
在 str
:
>>> for p in parsers:
... print(p('60_3_6'))
...
6036
6036.0
6036
60_3_6
(在问题的第一个示例中,60_3_6,
作为值传递;在本例中,eval
returns 一个包含 6036
作为其唯一值的元组元素,如配置值的转储所示)。
要解决这个问题,您需要传递一个只能由 str
成功处理的值。
另一种可能的解决方法是传递一个可调用的
lambda : '60_3_6'
因为 snakemake 将使用 callable instead of the result of processing parsers 但是我看不到如何从配置文件或命令行完成此操作,我认为您需要直接调用 snakemake 的 main
函数来自 python 代码(也许创建一个包装脚本?)。
这个"double quoting"似乎有效:
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}
"""