簡體   English   中英

Snakemake:缺少所有規則的輸入文件

[英]Snakemake : Missing input files for rule all

我正在開發我的第一個 Snakemake 工作流程,但由於錯誤而陷入困境。

我想先從一個規則開始來測試我的代碼。 我創建了 fastQC 規則。 但是,當我運行我的 snakemake 時,我收到以下錯誤消息:

MissingInputException in line 24 of /ngs/prod/nanocea_project/test/Snakefile:
Missing input files for rule all:
stats/fastqc/02062021_1/02062021_1_fastqc.html
stats/fastqc/02062021_1/02062021_1_fastqc.zip
stats/fastqc/02062021_2/02062021_2_fastqc.html
stats/fastqc/25022021_2/25022021_2_fastqc.zip
stats/fastqc/25022021_2/25022021_2_fastqc.html
stats/fastqc/02062021_2/02062021_2_fastqc.zip

這是我的代碼:

import glob
import os

###Global Variables###

FORMATS=["zip", "html"]
OUTDIR="/ngs/prod/nanocea_project/test/stats/fastqc"
DIR_FASTQ="/ngs/prod/nanocea_project/test/reads"

###FASTQ Files###

def list_samples(DIR_FASTQ):
        SAMPLES=[]
        for file in glob.glob(DIR_FASTQ+"/*.fastq.gz"):
                base=os.path.basename(file)
                sample=(base.replace('.fastq.gz', ''))
                SAMPLES.append(sample)
        return(SAMPLES)

SAMPLES=list_samples(DIR_FASTQ)

###Rules###

rule all:
        input:
                expand("stats/fastqc/{sample}/{sample}_fastqc.{ext}", sample=SAMPLES, ext=FORMATS)

rule fastqc:
        input:
                expand(DIR_FASTQ+"/{sample}.fastq.gz", sample=SAMPLES)
        output:
                expand(OUTDIR+"/{sample}_fastqc.{ext}", sample=SAMPLES, ext=FORMATS)
        threads:
                16
        conda:
                "envs/fastqc.yaml"
        shell:
                """
                mkdir stats/fastqc/{sample}
                fastqc {input} -o {OUTDIR}/{sample} -t {threads}
                """

這是我的文件的結構:

|
|_ Snakefile
|
|_/reads
|   |
|   |_25022021_2.fastq.gz
|   |
|   |_02062021_1.fastq.gz
|   |
|   |_02062021_2.fastq.gz
|
|_/envs
|   |
|   |_fastqc.yaml
|
|_/stats
|   |
|   |_/fastqc

我搜索了其他主題以尋找我的問題的解決方案,但我的工作流程無法正常工作。

你有什么想法?

謝謝!

在 dariober 回答后編輯

謝謝你的回答。 經過多次嘗試,唯一有效的解決方案是直接在 all 中編碼,fastqc 規則完整路徑。

第一個問題:為什么我的全局變量雖然修改為匹配我的所有規則,但不起作用?

第二個問題:既然第一個問題解決了,運行我的程序又出現一個新問題: snakemake --use-conda --cores 40

RuleException in line 28 of /ngs/prod/nanocea_project/test/Snakefile: NameError: The name 'sample' 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, ie {{print $1}}

我嘗試使用雙括號,但是當 mkdir 函數啟動時,它會創建一個名為 {sample} 的文件夾。 我不明白它為什么創建這個文件夾。

新代碼:

import glob
import os

###Global Variables###

FORMATS=["zip", "html"]
DIR_FASTQ="/ngs/prod/nanocea_project/test/reads"

###FASTQ Files###

def list_samples(DIR_FASTQ):
        SAMPLES=[]
        for file in glob.glob(DIR_FASTQ+"/*.fastq.gz"):
                base=os.path.basename(file)
                sample=(base.replace('.fastq.gz', ''))
                SAMPLES.append(sample)
        return(SAMPLES)

SAMPLES=list_samples(DIR_FASTQ)

###Rules###

rule all:
        input:
                expand("/ngs/prod/nanocea_project/test/stats/fastqc/{sample}/{sample}_fastqc.{ext}", sample=SAMPLES, ext=FORMATS)

rule fastqc:
        input:
                expand(DIR_FASTQ+"/{sample}.fastq.gz", sample=SAMPLES)
        output:
                expand("/ngs/prod/nanocea_project/test/stats/fastqc/{sample}/{sample}_fastqc.{ext}", sample=SAMPLES, ext=FORMATS)
        threads:
                16
        conda:
                "envs/fastqc.yaml"
        shell:
                """
                mkdir stats/fastqc/{sample}
                fastqc {input} -o /ngs/prod/nanocea_project/test/stats/fastqc/{sample} -t {threads}
                """

在規則中,您擁有的一切:

stats/fastqc/...

但在規則 fastqc 中,在擴展 OUTDIR 變量后,您有:

/ngs/prod/nanocea_project/test/stats/fastqc/...

即使它們指向同一個目錄,這兩個字符串也不匹配,snakemake 會給出錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM