forked from uclahs-cds/pipeline-align-DNA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
122 lines (109 loc) · 5.45 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
nextflow.enable.dsl=2
log.info """\
===================================
P I P E L I N E - A L I G N - D N A
===================================
Boutros Lab
Current Configuration:
- pipeline:
name: ${workflow.manifest.name}
version: ${workflow.manifest.version}
- input:
sample_id: ${params.sample_id}
input_csv: ${(params.containsKey("input_csv") && params.input_csv) ? params.input_csv : "YAML input used"}
reference_fasta_bwa: ${params.aligner.contains("BWA-MEM2") ? params.reference_fasta_bwa : "None"}
reference_fasta_index_files_bwa: ${params.aligner.contains("BWA-MEM2") ? params.reference_fasta_index_files_bwa : "None"}
reference_fasta_hisat2: ${params.aligner.contains("HISAT2") ? params.reference_fasta_hisat2 : "None"}
reference_fasta_index_files_hisat2: ${params.aligner.contains("HISAT2") ? params.reference_fasta_index_files_hisat2 : "None"}
- output:
work_dir: ${params.work_dir}
output_dir: ${params.output_dir}
output_dir_base_bwa: ${(params.ucla_cds_registered_dataset_output) ? params["output_dir_base_bwa-mem2"] : params["output_dir_base"]}
output_dir_base_hisat2: ${(params.ucla_cds_registered_dataset_output) ? params["output_dir_base_hisat2"] : params["output_dir_base"]}
log_output_dir_bwa: ${(params.ucla_cds_registered_dataset_output) ? params["log_output_dir_bwa-mem2"] : params["log_output_dir"]}
log_output_dir_hisat2: ${(params.ucla_cds_registered_dataset_output) ? params["log_output_dir_hisat2"] : params["log_output_dir"]}
- options:
save_intermediate_files = ${params.save_intermediate_files}
cache_intermediate_pipeline_steps = ${params.cache_intermediate_pipeline_steps}
ucla_cds_registered_dataset_input = ${params.ucla_cds_registered_dataset_input}
ucla_cds_registered_dataset_output = ${params.ucla_cds_registered_dataset_output}
Tools Used:
- BWA-MEM2: ${params.aligner.contains("BWA-MEM2") ? params.docker_image_bwa_and_samtools : "None"}
- HISAT2: ${params.aligner.contains("HISAT2") ? params.docker_image_hisat2_and_samtools : "None"}
- Picard Tools: ${params.docker_image_picardtools}
- validate: ${params.docker_image_validate}
- GATK: ${params.docker_image_gatk}
------------------------------------
Starting workflow...
------------------------------------
"""
.stripIndent()
include { generate_standard_filename } from './external/nextflow-modules/modules/common/generate_standardized_filename/main.nf'
include { align_DNA_BWA_MEM2_workflow } from './module/align_DNA_BWA_MEM2.nf' addParams(
bam_output_filename: "${generate_standard_filename(params.bwa_version, params.dataset_id, params.sample_id, [:])}.bam",
output_dir_base: (params.ucla_cds_registered_dataset_output) ? params["output_dir_base_bwa-mem2"] : params["output_dir_base"],
log_output_dir: (params.ucla_cds_registered_dataset_output) ? params["log_output_dir_bwa-mem2"] : params["log_output_dir"]
)
include { align_DNA_HISAT2_workflow } from './module/align_DNA_HISAT2.nf' addParams(
bam_output_filename: "${generate_standard_filename(params.hisat2_version, params.dataset_id, params.sample_id, [:])}.bam",
output_dir_base: (params.ucla_cds_registered_dataset_output) ? params["output_dir_base_hisat2"] : params["output_dir_base"],
log_output_dir: (params.ucla_cds_registered_dataset_output) ? params["log_output_dir_hisat2"] : params["log_output_dir"]
)
workflow {
if (!(params.aligner.contains("BWA-MEM2") || params.aligner.contains("HISAT2"))) {
throw new Exception('ERROR: Please specify at least one valid aligner! Options: BWA-MEM2, HISAT2')
}
// get the input fastq pairs
Channel
.from(params.input.FASTQ)
.map { row ->
// the library, sample and lane are used as keys downstream to group into
// sets of the same key for downstream merging
return tuple(row.library_identifier,
row,
row.lane,
row.read1_fastq,
row.read2_fastq
)
}
.set{ ich_samples }
ich_samples
.flatMap { library, header, lane, read1_fastq, read2_fastq ->
[read1_fastq, read2_fastq]
}
.set { ich_samples_validate }
// Only create input channels for files which aligners are using
if (params.aligner.contains("BWA-MEM2")) {
Channel
.fromPath(params.reference_fasta_bwa, checkIfExists: true)
.set { ich_reference_fasta_bwa }
Channel
.fromPath(params.reference_fasta_index_files_bwa, checkIfExists: true)
.set { ich_bwa_reference_index_files }
align_DNA_BWA_MEM2_workflow(
ich_samples,
ich_samples_validate,
ich_reference_fasta_bwa,
ich_bwa_reference_index_files
)
bwa_mem2_complete_signal = align_DNA_BWA_MEM2_workflow.out.complete_signal
}
else {// If only running HISAT2, generate dummy signal
bwa_mem2_complete_signal = "bwa_mem2_complete"
}
if (params.aligner.contains("HISAT2")) {
Channel
.fromPath(params.reference_fasta_hisat2, checkIfExists: true)
.set { ich_reference_fasta_hisat2 }
Channel
.fromPath(params.reference_fasta_index_files_hisat2, checkIfExists: true)
.set { ich_hisat2_reference_index_files }
align_DNA_HISAT2_workflow(
bwa_mem2_complete_signal,
ich_samples,
ich_samples_validate,
ich_reference_fasta_hisat2,
ich_hisat2_reference_index_files
)
}
}