Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Subworkflow Build_Indices for switch to DSL2 #238

Merged
merged 7 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [dsl2](https://github.com/nf-core/sarek/tree/dev)

- [#238](https://github.com/nf-core/sarek/pull/238) -Add subworkflow for building all the indices

## [dev](https://github.com/nf-core/sarek/tree/dev)

- [#234](https://github.com/nf-core/sarek/pull/234) -Switching to DSL2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this line to DSL2 too, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do in the next PR coming :)

Expand Down
42 changes: 25 additions & 17 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ if (tsvPath) {
*/

// Initialize each params in params.genomes, catch the command line first if it was defined
// params.fasta has to be the first one
params.fasta = params.genome && !('annotate' in step) ? params.genomes[params.genome].fasta ?: null : null

// The rest can be sorted
params.ac_loci = params.genome && 'ascat' in tools ? params.genomes[params.genome].ac_loci ?: null : null
params.ac_loci_gc = params.genome && 'ascat' in tools ? params.genomes[params.genome].ac_loci_gc ?: null : null
Expand All @@ -206,12 +205,8 @@ ch_ac_loci = params.ac_loci && 'ascat' in tools ? Channel.value(file(params.ac_l
ch_ac_loci_gc = params.ac_loci_gc && 'ascat' in tools ? Channel.value(file(params.ac_loci_gc)) : "null"
ch_chr_dir = params.chr_dir && 'controlfreec' in tools ? Channel.value(file(params.chr_dir)) : "null"
ch_chr_length = params.chr_length && 'controlfreec' in tools ? Channel.value(file(params.chr_length)) : "null"
ch_dbsnp = params.dbsnp && ('mapping' in step || 'preparerecalibration' in step || 'controlfreec' in tools || 'haplotypecaller' in tools || 'mutect2' in tools || params.sentieon) ? Channel.value(file(params.dbsnp)) : "null"
ch_fasta = params.fasta && !('annotate' in step) ? Channel.value(file(params.fasta)) : "null"
ch_fai = params.fasta_fai && !('annotate' in step) ? Channel.value(file(params.fasta_fai)) : "null"
ch_germline_resource = params.germline_resource && 'mutect2' in tools ? Channel.value(file(params.germline_resource)) : "null"
ch_intervals = params.intervals && !params.no_intervals && !('annotate' in step) ? Channel.value(file(params.intervals)) : "null"
ch_known_indels = params.known_indels && ('mapping' in step || 'preparerecalibration' in step) ? Channel.value(file(params.known_indels)) : "null"
ch_mappability = params.mappability && 'controlfreec' in tools ? Channel.value(file(params.mappability)) : "null"

ch_snpeff_cache = params.snpeff_cache ? Channel.value(file(params.snpeff_cache)) : "null"
Expand All @@ -224,7 +219,6 @@ ch_cadd_indels = params.cadd_indels ? Channel.value(file(params.cadd_indels)) :
ch_cadd_indels_tbi = params.cadd_indels_tbi ? Channel.value(file(params.cadd_indels_tbi)) : "null"
ch_cadd_wg_snvs = params.cadd_wg_snvs ? Channel.value(file(params.cadd_wg_snvs)) : "null"
ch_cadd_wg_snvs_tbi = params.cadd_wg_snvs_tbi ? Channel.value(file(params.cadd_wg_snvs_tbi)) : "null"
ch_pon = params.pon ? Channel.value(file(params.pon)) : "null"
ch_target_bed = params.target_bed ? Channel.value(file(params.target_bed)) : "null"

/*
Expand Down Expand Up @@ -313,12 +307,26 @@ include { MULTIQC } from './modules/nf-core/multiqc' params(params)
RUN THE WORKFLOW
================================================================================
*/
include { build_indices } from './modules/local/buildindices'
include { BUILD_INDICES } from './modules/subworkflows/build_indices' addParams(params)

// params.fasta has to be the first one
params.fasta = params.genome && !('annotate' in step) ? params.genomes[params.genome].fasta ?: null : null
ch_fasta = params.fasta && !('annotate' in step) ? Channel.value(file(params.fasta)) : "null"
ch_dbsnp = params.dbsnp && ('mapping' in step || 'preparerecalibration' in step || 'controlfreec' in tools || 'haplotypecaller' in tools || 'mutect2' in tools || params.sentieon) ? Channel.value(file(params.dbsnp)) : "null"
ch_germline_resource = params.germline_resource && 'mutect2' in tools ? Channel.value(file(params.germline_resource)) : "null"
ch_known_indels = params.known_indels && ('mapping' in step || 'preparerecalibration' in step) ? Channel.value(file(params.known_indels)) : "null"
ch_pon = params.pon ? Channel.value(file(params.pon)) : "null"


workflow {

//build_indices(ch_fasta, ch_dbsnp, ch_germline_resource, ch_known_indels)
BUILD_INDICES( step,
ch_fasta,
ch_dbsnp,
ch_germline_resource,
ch_known_indels,
ch_pon)

FASTQC(inputSample)

OUTPUT_DOCUMENTATION(
Expand All @@ -335,21 +343,21 @@ workflow {
ch_workflow_summary)
}

ch_bwa = params.bwa ? Channel.value(file(params.bwa)) : build_indices.out.BWAMEM2_INDEX.out
// ch_bwa = params.bwa ? Channel.value(file(params.bwa)) : build_indices.out.BWAMEM2_INDEX.out

ch_dict = params.dict ? Channel.value(file(params.dict)) : GATK_CREATE_SEQUENCE_DICTIONARY.out
// ch_dict = params.dict ? Channel.value(file(params.dict)) : GATK_CREATE_SEQUENCE_DICTIONARY.out

ch_fai = params.fasta_fai ? Channel.value(file(params.fasta_fai)) : SAMTOOLS_FAIDX.out
// ch_fai = params.fasta_fai ? Channel.value(file(params.fasta_fai)) : SAMTOOLS_FAIDX.out

ch_dbsnp_tbi = params.dbsnp ? params.dbsnp_index ? Channel.value(file(params.dbsnp_index)) : dbsnp_tbi : "null"
// ch_dbsnp_tbi = params.dbsnp ? params.dbsnp_index ? Channel.value(file(params.dbsnp_index)) : dbsnp_tbi : "null"

ch_germline_resource_tbi = params.germline_resource ? params.germline_resource_index ? Channel.value(file(params.germline_resource_index)) : germline_resource_tbi : "null"
// ch_germline_resource_tbi = params.germline_resource ? params.germline_resource_index ? Channel.value(file(params.germline_resource_index)) : germline_resource_tbi : "null"

ch_known_indels_tbi = params.known_indels ? params.known_indels_index ? Channel.value(file(params.known_indels_index)) : known_indels_tbi.collect() : "null"
// ch_known_indels_tbi = params.known_indels ? params.known_indels_index ? Channel.value(file(params.known_indels_index)) : known_indels_tbi.collect() : "null"

ch_pon_tbi = params.pon ? params.pon_index ? Channel.value(file(params.pon_index)) : pon_tbi : "null"
// ch_pon_tbi = params.pon ? params.pon_index ? Channel.value(file(params.pon_index)) : pon_tbi : "null"

ch_intervals = params.no_intervals ? "null" : params.intervals && !('annotate' in step) ? Channel.value(file(params.intervals)) : intervalBuilt
// ch_intervals = params.no_intervals ? "null" : params.intervals && !('annotate' in step) ? Channel.value(file(params.intervals)) : intervalBuilt

/*
================================================================================
Expand Down
40 changes: 0 additions & 40 deletions modules/local/buildindices.nf

This file was deleted.

2 changes: 0 additions & 2 deletions modules/local/gatk_dict.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ process GATK_CREATE_SEQUENCE_DICTIONARY {
output:
path file("${fasta.baseName}.dict")

//when: !(params.dict) && params.fasta && !('annotate' in step) && !('controlfreec' in step)

script:
"""
gatk --java-options "-Xmx${task.memory.toGiga()}g" \
Expand Down
2 changes: 0 additions & 2 deletions modules/nf-core/bwamem2_index.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ process BWAMEM2_INDEX {
output:
path file("${fasta}.*")

//when: !(params.bwa) && params.fasta && 'mapping' in step

script:
"""
bwa-mem2 index ${fasta}
Expand Down
70 changes: 70 additions & 0 deletions modules/subworkflows/build_indices.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
================================================================================
BUILDING INDEXES
================================================================================
*/

// And then initialize channels based on params or indexes that were just built


include { HTSLIB_TABIX as HTSLIB_TABIX_DBSNP } from '../nf-core/htslib_tabix'
include { HTSLIB_TABIX as HTSLIB_TABIX_GERMLINE_RESOURCE } from '../nf-core/htslib_tabix'
include { HTSLIB_TABIX as HTSLIB_TABIX_KNOWN_INDELS } from '../nf-core/htslib_tabix'
include { HTSLIB_TABIX as HTSLIB_TABIX_PON } from '../nf-core/htslib_tabix'
include { BWAMEM2_INDEX as BWAMEM2_INDEX } from '../nf-core/bwamem2_index.nf'
include { SAMTOOLS_FAIDX as SAMTOOLS_FAIDX } from '../nf-core/samtools_faidx.nf'
include { GATK_CREATE_SEQUENCE_DICTIONARY as GATK_CREATE_SEQUENCE_DICTIONARY } from '../local/gatk_dict.nf'
include { BUILD_INTERVALS } from '../local/build_intervals.nf'


workflow BUILD_INDICES{
take:
step
ch_fasta
ch_dbsnp
ch_germline_resource
ch_known_indels
ch_pon

main:

if(!(params.bwa) && params.fasta && 'mapping' in step)
BWAMEM2_INDEX(ch_fasta)

if(!(params.dict) && params.fasta && !('annotate' in step) && !('controlfreec' in step))
GATK_CREATE_SEQUENCE_DICTIONARY(ch_fasta)

if(!(params.fasta_fai) && params.fasta && !('annotate' in step))
SAMTOOLS_FAIDX(ch_fasta)

if(!(params.dbsnp_index) && params.dbsnp && ('mapping' in step || 'preparerecalibration' in step || 'controlfreec' in tools || 'haplotypecaller' in tools || 'mutect2' in tools || 'tnscope' in tools))
HTSLIB_TABIX_DBSNP(ch_dbsnp)

if(!(params.germline_resource_index) && params.germline_resource && 'mutect2' in tools)
HTSLIB_TABIX_GERMLINE_RESOURCE(ch_germline_resource)

if(!(params.known_indels_index) && params.known_indels && ('mapping' in step || 'preparerecalibration' in step))
HTSLIB_TABIX_KNOWN_INDELS(ch_known_indels)

if(!(params.pon_index) && params.pon && ('tnscope' in tools || 'mutect2' in tools))
HTSLIB_TABIX_PON(ch_pon)

if(!(params.intervals) && !('annotate' in step) && !('controlfreec' in step)){
ch_fai = params.fasta_fai ? Channel.value(file(params.fasta_fai)) : SAMTOOLS_FAIDX.out
BUILD_INTERVALS(ch_fai)
}


emit:
bwa_built = BWAMEM2_INDEX.out
dictBuilt = GATK_CREATE_SEQUENCE_DICTIONARY.out
fai_built = SAMTOOLS_FAIDX.out
dbsnp_tbi = HTSLIB_TABIX_DBSNP.out
germline_resource_tbi = HTSLIB_TABIX_GERMLINE_RESOURCE.out
known_indels_tbi = HTSLIB_TABIX_KNOWN_INDELS.out
pon_tbi = HTSLIB_TABIX_PON.out
intervalBuilt = BUILD_INTERVALS.out

}