Nextflow报告错误:No such variable: from



我正在努力学习nextflow,但它不是很顺利。我使用基于ngs的双端测序数据,使用Nextflow构建了从fastq文件到vcf文件的分析流。然而,我在一开始就卡住了,如代码所示。第一个进程soapnuke工作正常,但是当将文件从通道(clean_fq1 clean_fq2)传递到下一个进程时,会出现ERROR: No such变量:from。如下图所示。我该怎么办?谢谢你的帮助。

输入图片描述

params.fq1 = "/data/mPCR/220213_I7_V350055104_L3_SZPVL22000812-81/*1.fq.gz"
params.fq2 = "/data/mPCR/220213_I7_V350055104_L3_SZPVL22000812-81/*2.fq.gz"
params.index = "/home/duxu/project/data/index.list"
params.primer = “/home/duxu/project/data/primer_*.fasta"
params.output='results'
fq1 = Channel.frompath(params.fq1)
fq2 = Channel.frompath(params.fq2)
index = Channel.frompath(params.index)
primer = Channel.frompath(params.primer)
process soapnuke{
conda'soapnuke'
tag{"soapnuk ${fq1} ${fq2}"}
publishDir "${params.outdir}/SOAPnuke", mode: 'copy'
input:
file rawfq1 from fq1
file rawfq2 from fq2    
output:
file 'clean1.fastq.gz' into clean_fq1
file 'clean2.fastq.gz' into clean_fq2

script:
"""
SOAPnuke filter -1 $rawfq1 -2 $rawfq2 -l 12 -q 0.5 -Q 2 -o . 
-C clean1.fastq.gz -D clean2.fastq.gz
"""
}

我被这个卡住了:

process barcode_splitter{
conda'barcode_splitter'
tag{"barcode_splitter ${fq1} ${fq2}"}
publishDir "${params.outdir}/barcode_splitter", mode: 'copy'
input:
file split1 from clean_fq1
file split2 from clean_fq2
index from params.index
output:
file '*-read-1.fastq.gz' into trimmed_index1
file '*-read-2.fastq.gz' into trimmed_index2
script:
"""
barcode_splitter --bcfile $index $split1 $split2  --idxread 1 2 --mismatches 1 --suffix .fastq --gzipout
"""
}

下面的代码将产生如下错误:

index = Channel.fromPath( params.index )
process barcode_splitter {
...
input:
index from params.index
...
}

你想要的是:

index = file( params.index )
process barcode_splitter {
...
input:
path index
...
}

注意,当文件输入名称与通道名称相同时,可以省略from通道声明。我还使用了上面的path限定符,因为在使用Nextflow 19.10.0或更高版本时,它应该优于file限定符。

你可能还想考虑重构以使用fromFilePairs工厂方法。这里有一种方法,当然是未经测试的:

params.reads = "/data/mPCR/220213_I7_V350055104_L3_SZPVL22000812-81/*_{1,2}.fq.gz"
params.index = "/home/duxu/project/data/index.list"
params.output = 'results'
reads_ch = Channel.fromFilePairs( params.reads )
index = file( params.index )

process soapnuke {
tag { sample }
publishDir "${params.outdir}/SOAPnuke", mode: 'copy'
conda 'soapnuke'
input:
tuple val(sample), path(reads) from reads_ch
output:
tuple val(sample), path('clean{1,2}.fastq.gz') into clean_reads_ch
script:
def (rawfq1, rawfq2) = reads
"""
SOAPnuke filter \
-1 "${rawfq1}" \
-2 "${rawfq2}" \
-l 12 \
-q 0.5 \
-Q 2 \
-o . \
-C "clean1.fastq.gz" \
-D "clean2.fastq.gz"
"""
}
process barcode_splitter {
tag { sample }
publishDir "${params.outdir}/barcode_splitter", mode: 'copy'
conda 'barcode_splitter'
input:
tuple val(sample), path(reads) from clean_reads_ch
path index
output:
tuple val(sample), path('*-read-{1,2}.fastq.gz') into trimmed_index
script:
def (splitfq1, splitfq2) = reads
"""
barcode_splitter \
--bcfile \
"${index}" \
"${split1}" \
"${split2}" \
--idxread 1 2 \
--mismatches 1 \
--suffix ".fastq" \
--gzipout
"""
}

最新更新