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

all intervals stuff in out of main.nf #247

Merged
merged 9 commits into from
Jul 17, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> **An open-source analysis pipeline to detect germline or somatic variants from whole genome or targeted sequencing**

[![Nextflow](https://img.shields.io/badge/nextflow-%E2%89%A520.04.1-brightgreen.svg)](https://www.nextflow.io/)
[![Nextflow](https://img.shields.io/badge/nextflow-%E2%89%A520.06.0--edge-brightgreen.svg)](https://www.nextflow.io/)
[![nf-core](https://img.shields.io/badge/nf--core-pipeline-brightgreen.svg)](https://nf-co.re/)
[![DOI](https://zenodo.org/badge/184289291.svg)](https://zenodo.org/badge/latestdoi/184289291)

Expand Down
2 changes: 1 addition & 1 deletion bin/scrape_software_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'AlleleCount': ['v_allelecount.txt', r"(\S+)"],
'ASCAT': ['v_ascat.txt', r"Version: (\S+)"],
'bcftools': ['v_bcftools.txt', r"bcftools (\S+)"],
'BWAMEM2': ['v_bwamem2.txt', r"Version: (\S+)"],
'BWA-MEM2': ['v_bwamem2.txt', r"(\S+)"],
'CNVkit': ['v_cnvkit.txt', r"(\S+)"],
'Control-FREEC': ['v_controlfreec.txt', r"Control-FREEC\s(\S+)"],
'FastQC': ['v_fastqc.txt', r"FastQC v(\S+)"],
Expand Down
69 changes: 27 additions & 42 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ if (params.help) {
include {
check_parameter_existence;
check_parameter_list;
define_skip_qc_list;
define_step_list;
define_tool_list;
extract_bam;
Expand Down Expand Up @@ -86,9 +87,9 @@ tools = params.tools ? params.tools.split(',').collect{it.trim().toLowerCase().r
if (step == 'controlfreec') tools = ['controlfreec']
if (!check_parameter_list(tools, tool_list)) exit 1, 'Unknown tool(s), see --help for more information'

// skip_qc_list = define_skip_qc_list()
// skip_qc = params.skip_qc ? params.skip_qc == 'all' ? skip_qc_list : params.skip_qc.split(',').collect{it.trim().toLowerCase().replaceAll('-', '').replaceAll('_', '')} : []
// if (!check_parameter_list(skip_qc, skip_qc_list)) exit 1, 'Unknown QC tool(s), see --help for more information'
skip_qc_list = define_skip_qc_list()
skip_qc = params.skip_qc ? params.skip_qc == 'all' ? skip_qc_list : params.skip_qc.split(',').collect{it.trim().toLowerCase().replaceAll('-', '').replaceAll('_', '')} : []
if (!check_parameter_list(skip_qc, skip_qc_list)) exit 1, 'Unknown QC tool(s), see --help for more information'

// anno_list = define_anno_list()
// annotate_tools = params.annotate_tools ? params.annotate_tools.split(',').collect{it.trim().toLowerCase().replaceAll('-', '')} : []
Expand Down Expand Up @@ -248,23 +249,31 @@ if (params.sentieon) log.warn "[nf-core/sarek] Sentieon will be used, only works

/*
================================================================================
INCLUDE LOCAL PIPELINE MODULES
INCLUDE LOCAL PIPELINE MODULES
================================================================================
*/

include { BWAMEM2_MEM } from './modules/local/bwamem2_mem.nf' addParams(params)
include { GET_SOFTWARE_VERSIONS } from './modules/local/get_software_versions' params(params)
include { OUTPUT_DOCUMENTATION } from './modules/local/output_documentation' params(params)
include { TRIM_GALORE } from './modules/local/trim_galore.nf' addParams(params)
include { BWAMEM2_MEM } from './modules/local/bwamem2_mem.nf'
include { GET_SOFTWARE_VERSIONS } from './modules/local/get_software_versions'
include { OUTPUT_DOCUMENTATION } from './modules/local/output_documentation'
include { TRIM_GALORE } from './modules/local/trim_galore.nf'

/*
================================================================================
INCLUDE LOCAL PIPELINE SUBWORKFLOWS
================================================================================
*/

include { BUILD_INDICES } from './modules/subworkflows/build_indices'

/*
================================================================================
INCLUDE nf-core PIPELINE MODULES
================================================================================
*/

include { FASTQC } from './modules/nf-core/fastqc' params(params)
include { MULTIQC } from './modules/nf-core/multiqc' params(params)
include { FASTQC } from './modules/nf-core/fastqc'
include { MULTIQC } from './modules/nf-core/multiqc'

// PREPARING CHANNELS FOR PREPROCESSING AND QC

Expand Down Expand Up @@ -313,8 +322,6 @@ include { MULTIQC } from './modules/nf-core/multiqc' params(params)
================================================================================
*/

include { BUILD_INDICES } from './modules/subworkflows/build_indices' addParams(params)

workflow {

BUILD_INDICES(
Expand All @@ -331,39 +338,17 @@ workflow {
dict = params.dict ?: BUILD_INDICES.out.dict
fai = params.fasta_fai ? params.fasta_fai : BUILD_INDICES.out.fai
germline_resource_tbi = params.germline_resource ? params.germline_resource_index ?: BUILD_INDICES.out.germline_resource_tbi : Channel.empty()
intervals_bed = params.no_intervals ? Channel.empty() : BUILD_INDICES.out.intervals_bed
known_indels_tbi = params.known_indels ? params.known_indels_index ?: BUILD_INDICES.out.known_indels_tbi : Channel.empty()
// known_indels_tbi = params.known_indels ? params.known_indels_index ?: BUILD_INDICES.out.known_indels_tbi.collect() : Channel.empty()
intervals_bed = BUILD_INDICES.out.intervals_bed
known_indels_tbi = params.known_indels ? params.known_indels_index ?: BUILD_INDICES.out.known_indels_tbi.collect() : Channel.empty()
pon_tbi = params.pon ? params.pon_index ?: BUILD_INDICES.out.pon_tbi : Channel.empty()

// PREPROCESSING

// BED INTERVAL CHANNEL TRANSFORMING
intervals_bed.flatten()
.map { intervalFile ->
def duration = 0.0
for (line in intervalFile.readLines()) {
final fields = line.split('\t')
if (fields.size() >= 5) duration += fields[4].toFloat()
else {
start = fields[1].toInteger()
end = fields[2].toInteger()
duration += (end - start) / params.nucleotides_per_second
}
}
[ duration, intervalFile]
}.toSortedList({ a, b -> b[0] <=> a[0] })
.flatten().collate(2)
.map{duration, intervalFile -> intervalFile}
intervals_bed.dump(tag:'bedintervals')

if (params.no_intervals && step != 'annotate') {
file("${params.outdir}/no_intervals.bed").text = "no_intervals\n"
intervals_bed = Channel.from(file("${params.outdir}/no_intervals.bed"))
}

// if(!('fastqc' in skip_qc))
FASTQC(input_sample)
if(!('fastqc' in skip_qc))
result_fastqc = FASTQC(input_sample)
else
result_fastqc = Channel.empty()

if (params.trim_fastq) {
TRIM_GALORE(input_sample)
Expand All @@ -382,11 +367,11 @@ workflow {
GET_SOFTWARE_VERSIONS()

MULTIQC(
FASTQC.out.ifEmpty([]),
result_fastqc.collect().ifEmpty([]),
multiqc_config,
multiqc_custom_config.ifEmpty([]),
GET_SOFTWARE_VERSIONS.out.yml,
result_trim_galore.ifEmpty([]),
result_trim_galore.collect().ifEmpty([]),
workflow_summary)
}

Expand Down
26 changes: 23 additions & 3 deletions modules/subworkflows/build_indices.nf
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,33 @@ workflow BUILD_INDICES{
else
result_pon_tbi = Channel.empty()

if (!('annotate' in step) && !('controlfreec' in step))
if (params.no_intervals) {
file("${params.outdir}/no_intervals.bed").text = "no_intervals\n"
result_intervals = Channel.from(file("${params.outdir}/no_intervals.bed"))
} else if (!('annotate' in step) && !('controlfreec' in step))
if (!params.intervals)
result_intervals = CREATE_INTERVALS_BED(BUILD_INTERVALS(SAMTOOLS_FAIDX.out))
else
result_intervals = CREATE_INTERVALS_BED(params.intervals)
else
result_intervals = Channel.empty()

if (!params.no_intervals) {
result_intervals = result_intervals.flatten()
.map { intervalFile ->
def duration = 0.0
for (line in intervalFile.readLines()) {
final fields = line.split('\t')
if (fields.size() >= 5) duration += fields[4].toFloat()
else {
start = fields[1].toInteger()
end = fields[2].toInteger()
duration += (end - start) / params.nucleotides_per_second
}
}
[duration, intervalFile]
}.toSortedList({ a, b -> b[0] <=> a[0] })
.flatten().collate(2)
.map{duration, intervalFile -> intervalFile}
}

emit:
bwa = result_bwa
Expand Down