【发布时间】:2020-03-31 17:16:31
【问题描述】:
我正在编写一个snakemake,它将为多个输入样本运行生物信息学管道。这些输入文件(每个分析两个,一个与部分字符串匹配R1,第二个与部分字符串匹配R2)以一个模式开始,以扩展名.fastq.gz 结束。不过,最终我想执行多个操作,对于这个示例,我只想使用 bwa mem 将 fastq 读取与参考基因组对齐。所以对于这个例子,我的输入文件是NIPT-N2002394-LL_S19_R1_001.fastq.gz,我想生成NIPT-N2002394-LL.bam(参见下面的代码,指定输入和输出所在的目录)。
我的config.yaml 文件如下所示:
# Run_ID
run: "200311_A00154_0454_AHHHKMDRXX"
# Base directory: the analysis directory from which I will fetch the samples
bd: "/nexusb/nipt/"
# Define the prefix
# will be used to subset the folders in bd
prefix: "NIPT"
# Reference:
ref: "/nexus/bhinckel/19/ONT_projects/PGD_breakpoint/ref_hg19_local/hg19_chr1-y.fasta"
下面是我的蛇文件
import os
import re
#############
# config file
#############
configfile: "config.yaml"
#######################################
# Parsing variables from config.yaml
#######################################
RUN = config['run']
BD = config['bd']
PREFIX = config['prefix']
FQDIR = f'/nexusb/Novaseq/{RUN}/Unaligned/'
BASEDIR = BD + RUN
SAMPLES = [sample for sample in os.listdir(BASEDIR) if sample.startswith(PREFIX)]
# explanation: in BASEDIR I have multiple subdirectories. The names of the subdirectories starting with PREFIX will be the name of the elements I want to have in the list SAMPLES, which eventually shall be my {sample} wildcard
#############
# RULES
#############
rule all:
input:
expand("aligned/{sample}.bam", sample = SAMPLES)
rule bwa_map:
input:
REF = config['ref'],
R1 = FQDIR + "{sample}_S{s}_R1_001.fastq.gz",
R2 = FQDIR + "{sample}_S{s}_R2_001.fastq.gz"
output:
"aligned/{sample}.bam"
shell:
"bwa mem {input.REF} {input.R1} {input.R2}| samtools view -Sb - > {output}"
但我得到了:
Building DAG of jobs...
WildcardError in line 55 of /nexusb/nipt/200311_A00154_0454_AHHHKMDRXX/testMetrics/snakemake/Snakefile:
Wildcards in input files cannot be determined from output files:
's'
拨打snakemake -np时
我相信我的错误在于输入指令中R1 和R2 的定义。我觉得它令人费解,因为根据official documentationsnakemake 应该将任何通配符解释为正则表达式.+。但是对于示例NIPT-PearlPPlasma-05-PPx 并没有这样做,其R1 和R2 应该分别为NIPT-PearlPPlasma-05-PPx_S5_R1_001.fastq.gz 和NIPT-PearlPPlasma-05-PPx_S5_R2_001.fastq.gz。
【问题讨论】:
标签: python-3.x snakemake