Remove bcftools and ivar module customisations (#1217)

* Remove customisation from bcftools modules

* Add save_mpileup option to bcftools/mpileup

* Remove params.save_mpileup from ivar/consensus

* Update meta.ymls
This commit is contained in:
Harshil Patel 2022-01-18 16:04:56 +00:00 committed by GitHub
parent 4e9cc84514
commit bb90e4fb78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 112 additions and 32 deletions

View file

@ -18,9 +18,12 @@ process BCFTOOLS_CONSENSUS {
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
cat $fasta | bcftools consensus $vcf $args > ${prefix}.fa
header=\$(head -n 1 ${prefix}.fa | sed 's/>//g')
sed -i 's/\${header}/${meta.id}/g' ${prefix}.fa
cat $fasta \\
| bcftools \\
consensus \\
$vcf \\
$args \\
> ${prefix}.fa
cat <<-END_VERSIONS > versions.yml
"${task.process}":

View file

@ -9,12 +9,14 @@ process BCFTOOLS_MPILEUP {
input:
tuple val(meta), path(bam)
path fasta
path fasta
val save_mpileup
output:
tuple val(meta), path("*.gz") , emit: vcf
tuple val(meta), path("*.tbi") , emit: tbi
tuple val(meta), path("*stats.txt"), emit: stats
tuple val(meta), path("*.mpileup") , emit: mpileup, optional: true
path "versions.yml" , emit: versions
script:
@ -22,13 +24,16 @@ process BCFTOOLS_MPILEUP {
def args2 = task.ext.args2 ?: ''
def args3 = task.ext.args3 ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def mpileup = save_mpileup ? "| tee ${prefix}.mpileup" : ""
"""
echo "${meta.id}" > sample_name.list
bcftools mpileup \\
bcftools \\
mpileup \\
--fasta-ref $fasta \\
$args \\
$bam \\
$mpileup \\
| bcftools call --output-type v $args2 \\
| bcftools reheader --samples sample_name.list \\
| bcftools view --output-file ${prefix}.vcf.gz --output-type z $args3

View file

@ -26,6 +26,10 @@ input:
type: file
description: FASTA reference file
pattern: "*.{fasta,fa}"
- save_mpileup:
type: boolean
description: Save mpileup file generated by bcftools mpileup
patter: "*.mpileup"
output:
- meta:
type: map

View file

@ -9,7 +9,8 @@ process IVAR_CONSENSUS {
input:
tuple val(meta), path(bam)
path fasta
path fasta
val save_mpileup
output:
tuple val(meta), path("*.fa") , emit: fasta
@ -21,14 +22,16 @@ process IVAR_CONSENSUS {
def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def save_mpileup = params.save_mpileup ? "tee ${prefix}.mpileup |" : ""
def mpileup = save_mpileup ? "| tee ${prefix}.mpileup" : ""
"""
samtools mpileup \\
samtools \\
mpileup \\
--reference $fasta \\
$args2 \\
$bam | \\
$save_mpileup \\
ivar consensus \\
$bam \\
$mpileup \\
| ivar \\
consensus \\
$args \\
-p $prefix

View file

@ -25,6 +25,10 @@ input:
type: file
description: The reference sequence used for mapping and generating the BAM file
pattern: "*.fa"
- save_mpileup:
type: boolean
description: Save mpileup file generated by ivar consensus
patter: "*.mpileup"
output:
- meta:
type: map

View file

@ -23,14 +23,16 @@ process IVAR_VARIANTS {
def args2 = task.ext.args2 ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def features = gff ? "-g $gff" : ""
def mpileup = save_mpileup ? "tee ${prefix}.mpileup |" : ""
def mpileup = save_mpileup ? "| tee ${prefix}.mpileup" : ""
"""
samtools mpileup \\
samtools \\
mpileup \\
$args2 \\
--reference $fasta \\
$bam | \\
$mpileup \\
ivar variants \\
$bam \\
$mpileup \\
| ivar \\
variants \\
$args \\
$features \\
-r $fasta \\

View file

@ -32,6 +32,7 @@ input:
- save_mpileup:
type: boolean
description: Save mpileup file generated by ivar variants
patter: "*.mpileup"
output:
- meta:
type: map

View file

@ -5,11 +5,13 @@ nextflow.enable.dsl = 2
include { BCFTOOLS_CONSENSUS } from '../../../../modules/bcftools/consensus/main.nf'
workflow test_bcftools_consensus {
input = [ [ id:'test' ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true) ],
[ file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true) ],
[ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ]
]
input = [
[ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
BCFTOOLS_CONSENSUS ( input )
}

View file

@ -5,9 +5,25 @@ nextflow.enable.dsl = 2
include { BCFTOOLS_MPILEUP } from '../../../../modules/bcftools/mpileup/main.nf'
workflow test_bcftools_mpileup {
input = [ [ id:'test' ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]]
fasta = [ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ]
BCFTOOLS_MPILEUP ( input, fasta )
input = [
[ id:'test' ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_mpileup = false
BCFTOOLS_MPILEUP ( input, fasta, save_mpileup )
}
workflow test_bcftools_save_mpileup {
input = [
[ id:'test' ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_mpileup = true
BCFTOOLS_MPILEUP ( input, fasta, save_mpileup )
}

View file

@ -10,3 +10,18 @@
md5sum: ae0f17dcc2cb27034d848699b824c516
- path: output/bcftools/test.vcf.gz
md5sum: e9e520663875c66296f3bff0fa226c40
- name: bcftools mpileup test_bcftools_save_mpileup
command: nextflow run ./tests/modules/bcftools/mpileup -entry test_bcftools_save_mpileup -c ./tests/config/nextflow.config -c ./tests/modules/bcftools/mpileup/nextflow.config
tags:
- bcftools/mpileup
- bcftools
files:
- path: output/bcftools/test.bcftools_stats.txt
md5sum: 72c506e633413c6b439f95336933984e
- path: output/bcftools/test.vcf.gz.tbi
md5sum: ae0f17dcc2cb27034d848699b824c516
- path: output/bcftools/test.vcf.gz
md5sum: e9e520663875c66296f3bff0fa226c40
- path: output/bcftools/test.mpileup
md5sum: fe0e45a57ffdfb253ed6794f8356a3f0

View file

@ -2,14 +2,28 @@
nextflow.enable.dsl = 2
params.save_mpileup = true
include { IVAR_CONSENSUS } from '../../../../modules/ivar/consensus/main.nf'
workflow test_ivar_consensus {
input = [ [ id:'test'],
file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true)
]
input = [
[ id:'test'],
file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true)
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
IVAR_CONSENSUS ( input, fasta )
save_mpileup = false
IVAR_CONSENSUS ( input, fasta, save_mpileup)
}
workflow test_ivar_consensus_mpileup {
input = [
[ id:'test'],
file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true)
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
save_mpileup = true
IVAR_CONSENSUS ( input, fasta, save_mpileup)
}

View file

@ -1,5 +1,16 @@
- name: ivar consensus
- name: ivar consensus test_ivar_consensus
command: nextflow run ./tests/modules/ivar/consensus -entry test_ivar_consensus -c ./tests/config/nextflow.config -c ./tests/modules/ivar/consensus/nextflow.config
tags:
- ivar
- ivar/consensus
files:
- path: output/ivar/test.fa
md5sum: 9e21a64818f4302b4dece5480fa5e8b8
- path: output/ivar/test.qual.txt
md5sum: 68b329da9893e34099c7d8ad5cb9c940
- name: ivar consensus test_ivar_consensus_mpileup
command: nextflow run ./tests/modules/ivar/consensus -entry test_ivar_consensus_mpileup -c ./tests/config/nextflow.config -c ./tests/modules/ivar/consensus/nextflow.config
tags:
- ivar
- ivar/consensus