首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Snakemake使用所有样本作为porechop的一个输入

Snakemake使用所有样本作为porechop的一个输入
EN

Stack Overflow用户
提问于 2021-07-22 22:02:02
回答 1查看 25关注 0票数 1

我正在尝试通过Snakemake工作流对几个数据使用porechop。

在我的Snakefile中,除了all规则之外,还有三个规则,一个fastqc规则和一个porechop规则。fastqc规则工作得很好,我的三个fastq都用到了。但对于porechop,它不是运行命令三次,而是同时为所有三个文件运行一次带有-i标志的命令:

代码语言:javascript
复制
Error in rule porechop:
    jobid: 2
    output: /ngs/prod/nanocea_project/test/prod/porechop/25022021_2_pore.fastq.gz, /ngs/prod/nanocea_project/test/prod/porechop/02062021_1_pore.fastq.gz, /ngs/prod/nanocea_project/test/prod/porechop/02062021_2_pore.fastq.gz
    conda-env: /ngs/prod/nanocea_project/test/.snakemake/conda/a72fb141b37718b7c37d9f32d597faeb
    shell:
        porechop -i /ngs/prod/nanocea_project/test/reads/25022021_2.fastq.gz /ngs/prod/nanocea_project/test/reads/02062021_1.fastq.gz /ngs/prod/nanocea_project/test/reads/02062021_2.fastq.gz -o /ngs/prod/nanocea_project/test/prod/porechop/25022021_2_pore.fastq.gz /ngs/prod/nanocea_project/test/prod/porechop/02062021_1_pore.fastq.gz /ngs/prod/nanocea_project/test/prod/porechop/02062021_2_pore.fastq.gz -t 40 --discard_middle
        (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

但是,当我将它与单个样本一起使用时,程序可以正常工作。

下面是我的代码:

代码语言:javascript
复制
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}_fastqc.{ext}", sample=SAMPLES, ext=FORMATS),
                expand("/ngs/prod/nanocea_project/test/prod/porechop/{sample}_pore.fastq.gz", sample=SAMPLES)
rule fastqc:
        input:
                expand(DIR_FASTQ+"/{sample}.fastq.gz", sample=SAMPLES)
        output:
                expand("/ngs/prod/nanocea_project/test/stats/fastqc/{sample}_fastqc.{ext}", sample=SAMPLES, ext=FORMATS)
        threads:
                16
        conda:
                "envs/fastqc.yaml"
        shell:
                "fastqc {input} -o /ngs/prod/nanocea_project/test/stats/fastqc/ -t {threads}"

rule porechop:
        input:
                expand(DIR_FASTQ+"/{sample}.fastq.gz", sample=SAMPLES)
        output:
                expand("/ngs/prod/nanocea_project/test/prod/porechop/{sample}_pore.fastq.gz", sample=SAMPLES)
        threads:
                40
        conda:
                "envs/porechop.yaml"
        shell:
                "porechop -i {input} -o {output} -t {threads} --discard_middle"

你知道出什么事了吗?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-23 16:19:24

这个问题经常被提出来。如果您在input:output:中使用expand(),那么您将向规则提供所有文件的列表。这和写作是一样的:

代码语言:javascript
复制
input:
    ['sample1.fastq', 'sample2.fastq', ..., 'sampleN.fastq'],
output:
    ['sample1.pore.fastq', 'sample2.pore.fastq', ..., 'sampleN.pore.fastq'],

要在每个输入/输出上运行规则,只需删除展开:

代码语言:javascript
复制
rule porechop:
    input:
        DIR_FASTQ+"/{sample}.fastq.gz"
    output:               
        "/ngs/prod/nanocea_project/test/prod/porechop/{sample}_pore.fastq.gz",
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68486202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档