【问题标题】:Nextflow rename barcodes and concatenate reads within barcodesNextflow 重命名条形码并连接条形码内的读取
【发布时间】:2022-10-12 21:28:30
【问题描述】:

我当前的工作目录有以下子目录

我的 Bash 脚本

你好呀

我已经编译了上面的 Bash 脚本来执行以下任务:

  • 重命名从 metadata.csv 获取信息的子目录 (barcode01-12)
  • 连接子目录中的各个读取并将它们向上移动到 $PWD
  • 然后我将这些串联读取(每个条码一个)用于下面的 Nextflow 脚本:

询问:

如何获得上述预处理任务(重命名和连接)或在以下 Nextflow 脚本开头添加的 Bash 脚本?

【问题讨论】:

  • 嗨,请发布实际代码而不是代码截图。

标签: containers workflow pipeline bioinformatics nextflow


【解决方案1】:

根据我的经验,FASTQ 文件可能会变得非常大。在不了解太多细节的情况下,我的建议是将串联(和重命名)移至单独的进程。这样,所有的“工作”都可以在 Nextflow 的工作目录中完成。这是一个使用新的DSL 2 的解决方案。它使用splitCsv 运算符来解析元数据并识别FASTQ 文件。然后可以将集合传递到我们的“concat_reads”进程中。要处理可选的 gzip 压缩文件,您可以尝试以下操作:

params.metadata = './metadata.csv'
params.outdir = './results'
process concat_reads {

    tag { sample_name }

    publishDir "${params.outdir}/concat_reads", mode: 'copy'

    input:
    tuple val(sample_name), path(fastq_files)

    output:
    tuple val(sample_name), path("${sample_name}.${extn}")

    script:
    if( fastq_files.every { it.name.endsWith('.fastq.gz') } )
        extn = 'fastq.gz'
    else if( fastq_files.every { it.name.endsWith('.fastq') } )
        extn = 'fastq'
    else
        error "Concatentation of mixed filetypes is unsupported"

    """
    cat ${fastq_files} > "${sample_name}.${extn}"
    """
}
process pomoxis {

    tag { sample_name }

    publishDir "${params.outdir}/pomoxis", mode: 'copy'

    cpus 18

    input:
    tuple val(sample_name), path(fastq)

    """
    mini_assemble \
        -t ${task.cpus} \
        -i "${fastq}" \
        -o results \
        -p "${sample_name}"
    """
}
workflow {

    fastq_extns = [ '.fastq', '.fastq.gz' ]

    Channel.fromPath( params.metadata )
        | splitCsv()
        | map { dir, sample_name ->

            all_files = file(dir).listFiles()

            fastq_files = all_files.findAll { fn ->
                fastq_extns.find { fn.name.endsWith( it ) }
            }

            tuple( sample_name, fastq_files )
        }
        | concat_reads
        | pomoxis
}

【讨论】:

    猜你喜欢
    • 2012-01-27
    • 2020-01-27
    • 2011-06-16
    • 1970-01-01
    • 2013-06-24
    • 2011-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多