我绝对是蛇咬牙的初学者。据我所知,我正在建造一条管道。我的问题是,是否将Snakefile与我想要处理的NameError:发生的数据文件放在一起,但是如果我将Snakefile移动到父目录并编辑输入:和输出的路径信息:代码可以工作。我遗漏了什么?
rule sra_convert:
input:
"rna/{id}.sra"
output:
"rna/fastq/{id}.fastq"
shell:
"fastq-dump {input} -O {output}"当我运行时,上面的代码运行良好。
snakemake -p rna/fastq/SRR873382.fastq但是,如果我将该文件移到SRR873382.sra文件所在的"rna“目录中,并按以下方式编辑代码
rule sra_convert:
input:
"{id}.sra"
output:
"fastq/{id}.fastq"
message:
"Converting from {id}.sra to {id}.fastq"
shell:
"fastq-dump {input} -O {output}"然后跑
snakemake -p fastq/SRR873382.fastq我得到以下错误
Building DAG of jobs...
Job counts:
count jobs
1 sra_convert
1
RuleException in line 7 of /home/sarc/Data/rna/Snakefile:
NameError: The name 'id' is unknown in this context. Please make sure that you defined that variable. Also note that braces not used for variable access have to be escaped by repeating them, i.e. {{print $1}}溶液
rule sra_convert:
input:
"{id}.sra"
output:
"fastq/{id}.fastq"
message:
"Converting from {wildcards.id}.sra to {wildcards.id}.fastq"
shell:
"fastq-dump {input} -O {output}"以上代码运行良好,没有错误。
发布于 2019-05-21 06:50:24
我认为,回答你实际问题的最佳来源是:
https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#wildcards
如果规则的输出与请求的文件匹配,则将通配符匹配的子字符串传播到输入文件和变量通配符,这也在shell命令中使用。通配符对象可以以与输入和输出相同的方式访问,这一点在上面已经描述过了。
https://stackoverflow.com/questions/56184801
复制相似问题