-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
128 lines (104 loc) · 4.16 KB
/
main.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env nextflow
//
// MODULES
//
include {
MULTIQC
} from './modules/multiqc'
//
// SUBWORKFLOWS
//
include { INPUT_CHECK } from './subworkflows/input_check' //TODO Could possibly replace with nf-schema samplesheet parsing functionality?
include { CREATE_INDEX } from './subworkflows/create_index'
include { PROCESS_READS } from './subworkflows/process_reads'
include { MAPPING } from './subworkflows/mapping'
include { COUNT_READS } from './subworkflows/count_reads'
include { STRAND_SPECIFIC_COVERAGE } from './subworkflows/strand_specific_coverage'
//
// PLUGINS
//
include { validateParameters; paramsHelp; paramsSummaryLog; samplesheetToList } from 'plugin/nf-schema'
/*
========================================================================================
HELP
========================================================================================
*/
def logo = NextflowTool.logo(workflow, params.monochrome_logs)
log.info logo
if (params.help) {
log.info paramsHelp("nextflow run main.nf --manifest <manifest> --annotation <gff> --reference <fasta> --library_strandedness [reverse] --outdir [./results]")
exit(0)
}
/*
========================================================================================
VALIDATE INPUTS
========================================================================================
*/
// Nf-schema param validation
validateParameters()
// Validate parameters in ways not currently (easily) supported by nf-schema
def validate_custom_params(params, log, monochrome_logs) {
Map colors = NextflowTool.logColours(monochrome_logs)
def errors = 0
log.info("${colors.red}")
errors += ParamValidator.validate_no_invalid_args("--fastp_args", params.fastp_args, ["--in1", "--in2", "--out1", "--out2", "-h", "-j", "--thread"], log)
errors += ParamValidator.validate_no_invalid_args("--bowtie2_args", params.bowtie2_args, ["-x", "-1", "-2", "-p", "-S"], log)
errors += ParamValidator.validate_only_valid_args("--samtools_filter_args", params.samtools_filter_args, ["-f", "-F", "--rf", "-G", "-e"], log)
errors += ParamValidator.validate_no_invalid_args("--htseq_args", params.htseq_args, ["--samout", "--samout-format", "--order", "--stranded", "--counts_output"], log)
log.info("${colors.reset}")
if (errors > 0) {
log.error String.format("%d errors detected while validating parameters", errors)
exit 1
}
}
validate_custom_params(params, log, params.monochrome_logs)
/*
========================================================================================
RUN MAIN WORKFLOW
========================================================================================
*/
workflow {
main:
reference = file(params.reference, checkIfExists: true)
ch_manifest = file(params.manifest)
Channel.fromPath(params.annotation, checkIfExists: true).set { annotation }
CREATE_INDEX(
reference
)
INPUT_CHECK (
ch_manifest
)
INPUT_CHECK.out.shortreads
.dump(tag: 'ch_reads')
.set { ch_reads }
PROCESS_READS(
ch_reads
)
MAPPING(
PROCESS_READS.out.ch_processed_reads,
CREATE_INDEX.out.ch_bt2_index
)
COUNT_READS(
MAPPING.out.ch_reads_to_filter,
annotation
)
if (!params.skip_strand_specific_analysis) {
STRAND_SPECIFIC_COVERAGE(
CREATE_INDEX.out.ch_ref_index,
MAPPING.out.ch_reads_to_filter,
annotation
)
}
// MULTIQC SUMMARY
// TODO: FROM nf-core - to adapt
// ch_multiqc_config = Channel.fromPath("$projectDir/assets/multiqc_config.yml", checkIfExists: true)
// ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config) : Channel.empty()
MULTIQC(
PROCESS_READS.out.ch_fastqc_raw_zip.collect{it[1]}.ifEmpty([]),
PROCESS_READS.out.ch_fastqc_trim_zip.collect{it[1]}.ifEmpty([]),
PROCESS_READS.out.ch_fastp_reports.collect{it[1]}.ifEmpty([]),
MAPPING.out.ch_samtools_stats.collect{it[1]}.ifEmpty([]),
MAPPING.out.ch_dedup_metrics.collect{it[1]}.ifEmpty([]),
COUNT_READS.out.ch_samtools_stats.collect{it[1]}.ifEmpty([]),
)
}