-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.nf
110 lines (90 loc) · 3.58 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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
import org.yaml.snakeyaml.Yaml
/*
* Generic multiplatform genome assembly pipeline (MpGAP)
*/
/*
========================================================================================
VALIDATE & PRINT PARAMETER SUMMARY
========================================================================================
*/
WorkflowMpGAP.initialise(params, log)
WorkflowMain.initialise(workflow, params, log)
/*
========================================================================================
LOAD WORKFLOWS
========================================================================================
*/
include { PARSE_SAMPLESHEET } from './workflows/parse_samples.nf'
include { ASSEMBLY_QC } from './workflows/assembly_qc.nf'
include { SHORTREADS_ONLY } from './workflows/short-reads-only.nf'
include { LONGREADS_ONLY } from './workflows/long-reads-only.nf'
include { HYBRID } from './workflows/hybrid.nf'
/*
========================================================================================
DEFINE MAIN WORKFLOW
========================================================================================
*/
workflow {
// Message to user
println("""
Launching defined workflows!
By default, all workflows will appear in the console "log" message.
However, the processes of each workflow will be launched based on the inputs received.
You can see that processes that were not launched have an empty [- ].
""")
// Load YAML
samplesheet_yaml = file(params.input)
parameter_yaml = samplesheet_yaml.readLines().join("\n")
new Yaml().load(parameter_yaml).each { k, v -> params[k] = v }
// Copy YAML samplesheet to output directory so user has a copy of it
file(params.output).mkdir()
samplesheet_yaml.copyTo(params.output + "/" + "${samplesheet_yaml.getName()}")
// ch for versions
ch_versions = Channel.empty()
// Parse YAML file
PARSE_SAMPLESHEET( params.samplesheet )
// short reads only samples
SHORTREADS_ONLY( PARSE_SAMPLESHEET.out.shortreads )
ch_versions = ch_versions.mix(SHORTREADS_ONLY.out.versions)
// long reads only samples
LONGREADS_ONLY( PARSE_SAMPLESHEET.out.longreads )
ch_versions = ch_versions.mix(LONGREADS_ONLY.out.versions)
// hybrid samples
HYBRID( PARSE_SAMPLESHEET.out.hybrid )
ch_versions = ch_versions.mix(HYBRID.out.versions)
// QC
ch_all_assemblies = SHORTREADS_ONLY.out.results.mix( LONGREADS_ONLY.out.results, HYBRID.out.results )
ASSEMBLY_QC(
ch_all_assemblies,
ch_versions
)
// generate bacannot samplesheet
def final_outdir = file(params.output).toUriString()
Channel.value( 'samplesheet:' )
.mix(
ch_all_assemblies
.map{
def sample = it[0].toString()
def asm_type = it[2].toString()
def assembly = it[1].toString().split('/')[-1]
def asm_path = "${final_outdir}/final_assemblies/${sample}_${assembly}"
def final_string = "\s\s- id: ${sample}_${asm_type}\n\s\s\s\sassembly: ${asm_path}\n"
},
Channel.value("\n")
)
.collectFile( name: 'bacannot_samplesheet.yml', storeDir: params.output, sort: false, newLine: false )
}
/*
* Completition message
*/
workflow.onComplete {
println "Pipeline completed at: $workflow.complete"
println "Execution status: ${ workflow.success ? 'OK' : 'failed' }"
println "Execution duration: $workflow.duration"
println ""
println "${ workflow.success ? 'I wish you nice results!' : 'Do not give up, we can fix it!' }"
println "${ workflow.success ? 'Thank you for using fmalmeida/mpgap pipeline!' : '' }"
println ""
}