-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.nf
More file actions
executable file
·194 lines (169 loc) · 7.27 KB
/
Copy pathmain.nf
File metadata and controls
executable file
·194 lines (169 loc) · 7.27 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/env nextflow
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Arcadia-Science/noveltree
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Github : https://github.com/Arcadia-Science/noveltree
----------------------------------------------------------------------------------------
*/
nextflow.enable.dsl = 2
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VALIDATE & PRINT PARAMETER SUMMARY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
// Validate input parameters
WorkflowMain.initialize(workflow, params, log)
def summary_params = NfcoreSchema.paramsSummaryMap(workflow, params)
// Check input path parameters to see if they exist
def checkPathParamList = [params.input]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// Check mandatory parameters
if (params.input) {
ch_input = file(params.input)
} else {
exit 1, 'Input samplesheet not specified!'
}
if (params.mcl_inflation) {
mcl_inflation = params.mcl_inflation.toString().split(",").collect { it.trim() }
} else {
exit 1, 'MCL Inflation parameter(s) not specified!'
}
// Check if zoogle mode has required parameters for time calibration
if (params.zoogle && (!params.reference_time_tree || params.reference_time_tree == 'none')) {
if (!params.ncbi_email || params.ncbi_email == 'none') {
exit 1, 'Zoogle mode without --reference_time_tree requires --ncbi_email to auto-build a reference chronogram from TimeTree.org. Please provide --ncbi_email or --reference_time_tree.'
}
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT SUBWORKFLOWS AND MODULES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
include { INPUT_CHECK } from './subworkflows/local/input_check'
include { PREPARE_INPUTS } from './subworkflows/local/prepare_inputs'
include { INFER_ORTHOGROUPS } from './subworkflows/local/infer_orthogroups'
include { INFER_GENE_TREES as SPECIESTREE_GENE_FAMILIES } from './subworkflows/local/infer_gene_trees'
include { INFER_GENE_TREES as REMAINING_GENE_FAMILIES } from './subworkflows/local/infer_gene_trees'
include { RECONCILE_TREES } from './subworkflows/local/reconcile_trees'
include { RECONCILIATION_SUMMARIES } from './subworkflows/local/reconciliation_summaries'
if (params.zoogle) {
include { ZOOGLE } from './subworkflows/local/zoogle'
}
if (params.busco) {
include { BUSCO as BUSCO_SHALLOW } from './modules/nf-core-modified/busco'
include { BUSCO as BUSCO_BROAD } from './modules/nf-core-modified/busco'
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
workflow NOVELTREE {
// 1. Validate samplesheet
ch_all_data = INPUT_CHECK(ch_input)
// Normalize ref_species to hyphens (users may pass underscores or spaces)
// Set to 'none' for centroid-only analysis (no reference species)
def ref_species = (params.ref_species && params.ref_species != 'none')
? params.ref_species.replace('_', '-').replace(' ', '-')
: 'none'
// 2. Download, preprocess, rename
PREPARE_INPUTS(ch_all_data.remote_prots, ch_all_data.local_prots)
ch_renamed_prots = PREPARE_INPUTS.out.renamed_prots
// These value channels are consumed by multiple downstream subworkflows
species_name_list = ch_renamed_prots.collect { it[0].id }
complete_prots_list = ch_renamed_prots.collect { it[1] }
// Warn if ref_species is set but not found in the dataset
if (params.zoogle && ref_species != 'none') {
species_name_list.collect().subscribe { names ->
if (!names.contains(ref_species)) {
log.warn "WARNING: ref_species '${ref_species}' not found in input dataset. " +
"Reference-based analyses will be skipped. Only centroid-based outputs will be produced."
}
}
}
// 3. BUSCO (optional, independent — no downstream consumers)
if (params.busco) {
BUSCO_SHALLOW(
ch_renamed_prots.filter{ it[0].busco_shallow != "NA" },
"shallow",
[],
[]
)
BUSCO_BROAD(
ch_renamed_prots.filter{ it[0].busco_broad != "NA" },
"broad",
[],
[]
)
}
// 4. Orthogroup inference (--test_run filters to all-species OGs only)
if (params.test_run) {
log.info "── TEST MODE: only gene families containing ALL species will be processed ──"
}
INFER_ORTHOGROUPS(
ch_renamed_prots,
complete_prots_list,
mcl_inflation,
INPUT_CHECK.out.complete_samplesheet
)
// 5. Gene tree inference (alignment → trimming → phylogeny)
SPECIESTREE_GENE_FAMILIES(INFER_ORTHOGROUPS.out.spptree_fas)
REMAINING_GENE_FAMILIES(INFER_ORTHOGROUPS.out.genetree_fas)
// 6. Species tree + gene-tree/species-tree reconciliation
RECONCILE_TREES(
species_name_list,
SPECIESTREE_GENE_FAMILIES.out.phylogeny,
SPECIESTREE_GENE_FAMILIES.out.map_link,
SPECIESTREE_GENE_FAMILIES.out.cleaned_msas,
REMAINING_GENE_FAMILIES.out.phylogeny,
REMAINING_GENE_FAMILIES.out.map_link,
REMAINING_GENE_FAMILIES.out.cleaned_msas
)
// 7. Reconciliation summaries (phylo profiles, HOG parsing)
RECONCILIATION_SUMMARIES(
RECONCILE_TREES.out.event_counts,
RECONCILE_TREES.out.species_event_counts,
RECONCILE_TREES.out.species_coverage,
INFER_ORTHOGROUPS.out.inflation_dir,
RECONCILE_TREES.out.generax_nhx,
RECONCILE_TREES.out.labeled_species_tree
)
// 8. Zoogle: physicochemical properties + phylogenetic distance analysis (conditional)
if (params.zoogle) {
ZOOGLE(
INFER_ORTHOGROUPS.out.spptree_fas,
INFER_ORTHOGROUPS.out.genetree_fas,
RECONCILE_TREES.out.all_clean_msas,
RECONCILE_TREES.out.generax_per_spp_gfts,
RECONCILE_TREES.out.speciesrax_tree,
species_name_list,
ref_species,
RECONCILIATION_SUMMARIES.out.orthologs,
RECONCILIATION_SUMMARIES.out.paralogs
)
}
}
//
// WORKFLOW: Execute a single named workflow for the pipeline
// See: https://github.com/nf-core/rnaseq/issues/619
//
workflow {
NOVELTREE()
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPLETION EMAIL AND SUMMARY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
workflow.onComplete {
if (params.email || params.email_on_fail) {
NfcoreTemplate.email(workflow, params, summary_params, projectDir, log)
}
NfcoreTemplate.summary(workflow, params, log)
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/