Skip to content

Commit e44d594

Browse files
authored
Merge pull request #603 from bigbio/format
Format
2 parents 937c011 + c33b46f commit e44d594

File tree

1 file changed

+87
-58
lines changed

1 file changed

+87
-58
lines changed

workflows/quantms.nf

Lines changed: 87 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55
*/
66

7-
include { paramsSummaryMap } from 'plugin/nf-schema'
8-
include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline'
7+
include { paramsSummaryMap } from 'plugin/nf-schema'
8+
include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline'
99
include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline'
1010
include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_quantms_pipeline'
1111

@@ -41,7 +41,7 @@ workflow QUANTMS {
4141
//
4242
// SUBWORKFLOW: Read in samplesheet, validate and stage input files
4343
//
44-
INPUT_CHECK (
44+
INPUT_CHECK(
4545
file(params.input)
4646
)
4747
ch_versions = ch_versions.mix(INPUT_CHECK.out.versions)
@@ -52,28 +52,28 @@ workflow QUANTMS {
5252
//
5353
// SUBWORKFLOW: Create input channel
5454
//
55-
CREATE_INPUT_CHANNEL (
55+
CREATE_INPUT_CHANNEL(
5656
INPUT_CHECK.out.ch_input_file,
57-
INPUT_CHECK.out.is_sdrf
57+
INPUT_CHECK.out.is_sdrf,
5858
)
5959
ch_versions = ch_versions.mix(CREATE_INPUT_CHANNEL.out.versions)
6060

6161
//
6262
// SUBWORKFLOW: File preparation
6363
//
64-
FILE_PREPARATION (
64+
FILE_PREPARATION(
6565
CREATE_INPUT_CHANNEL.out.ch_meta_config_iso.mix(CREATE_INPUT_CHANNEL.out.ch_meta_config_lfq).mix(CREATE_INPUT_CHANNEL.out.ch_meta_config_dia)
6666
)
6767

6868
ch_versions = ch_versions.mix(FILE_PREPARATION.out.versions)
6969

7070
FILE_PREPARATION.out.results
71-
.branch {
72-
dia: it[0].acquisition_method.contains("dia")
73-
iso: it[0].labelling_type.contains("tmt") || it[0].labelling_type.contains("itraq")
74-
lfq: it[0].labelling_type.contains("label free")
75-
}
76-
.set{ch_fileprep_result}
71+
.branch {
72+
dia: it[0].acquisition_method.contains("dia")
73+
iso: it[0].labelling_type.contains("tmt") || it[0].labelling_type.contains("itraq")
74+
lfq: it[0].labelling_type.contains("label free")
75+
}
76+
.set { ch_fileprep_result }
7777
//
7878
// WORKFLOW: Run main bigbio/quantms analysis pipeline based on the quantification type
7979
//
@@ -85,13 +85,20 @@ workflow QUANTMS {
8585
//
8686
// MODULE: Generate decoy database
8787
//
88-
if (params.database) { ch_db_for_decoy_creation = Channel.from(file(params.database, checkIfExists: true)) } else { exit 1, 'No protein database provided' }
88+
if (params.database) {
89+
ch_db_for_decoy_creation = Channel.from(file(params.database, checkIfExists: true))
90+
}
91+
else {
92+
exit(1, 'No protein database provided')
93+
}
8994

9095

91-
CREATE_INPUT_CHANNEL.out.ch_meta_config_iso.mix(CREATE_INPUT_CHANNEL.out.ch_meta_config_lfq).first() // Only run if iso or lfq have at least one file
92-
| combine( ch_db_for_decoy_creation ) // Combine it so now the channel has elements like [potential_trigger_channel_element, actual_db], [potential_trigger_channel_element, actual_db2], etc (there should only be one DB though)
93-
| map { it[-1] } // Remove the "trigger" part
94-
| set {ch_db_for_decoy_creation_or_null}
96+
CREATE_INPUT_CHANNEL.out.ch_meta_config_iso.mix(
97+
CREATE_INPUT_CHANNEL.out.ch_meta_config_lfq
98+
).first()
99+
| combine(ch_db_for_decoy_creation)
100+
| map { it[-1] }
101+
| set { ch_db_for_decoy_creation_or_null }
95102

96103
ch_searchengine_in_db = params.add_decoys ? Channel.empty() : Channel.fromPath(params.database)
97104
if (params.add_decoys) {
@@ -106,80 +113,102 @@ workflow QUANTMS {
106113
if (params.search_engines) {
107114
search_engines = params.search_engines.tokenize(',')
108115
if (search_engines.size() != search_engines.unique().size()) {
109-
error( "Duplicated search engines in the search_engines parameter: ${params.search_engines}" )
116+
error("Duplicated search engines in the search_engines parameter: ${params.search_engines}")
110117
}
111118
}
112119

113120
// Only performing id_only subworkflows .
114121
if (params.id_only) {
115-
DDA_ID(FILE_PREPARATION.out.results, ch_searchengine_in_db, FILE_PREPARATION.out.ms2_statistics, CREATE_INPUT_CHANNEL.out.ch_expdesign)
122+
DDA_ID(
123+
FILE_PREPARATION.out.results,
124+
ch_searchengine_in_db,
125+
FILE_PREPARATION.out.ms2_statistics,
126+
CREATE_INPUT_CHANNEL.out.ch_expdesign,
127+
)
116128
ch_versions = ch_versions.mix(DDA_ID.out.versions)
117129
ch_ids_pmultiqc = ch_ids_pmultiqc.mix(DDA_ID.out.ch_pmultiqc_ids)
118130
ch_consensus_pmultiqc = ch_consensus_pmultiqc.mix(DDA_ID.out.ch_pmultiqc_consensus)
119-
} else {
120-
TMT(ch_fileprep_result.iso, CREATE_INPUT_CHANNEL.out.ch_expdesign, ch_searchengine_in_db)
131+
}
132+
else {
133+
TMT(
134+
ch_fileprep_result.iso,
135+
CREATE_INPUT_CHANNEL.out.ch_expdesign,
136+
ch_searchengine_in_db,
137+
)
121138
ch_ids_pmultiqc = ch_ids_pmultiqc.mix(TMT.out.ch_pmultiqc_ids)
122139
ch_consensus_pmultiqc = ch_consensus_pmultiqc.mix(TMT.out.ch_pmultiqc_consensus)
123140
ch_pipeline_results = ch_pipeline_results.mix(TMT.out.final_result)
124141
ch_msstats_in = ch_msstats_in.mix(TMT.out.msstats_in)
125142
ch_versions = ch_versions.mix(TMT.out.versions)
126143

127-
LFQ(ch_fileprep_result.lfq, CREATE_INPUT_CHANNEL.out.ch_expdesign, ch_searchengine_in_db)
144+
LFQ(
145+
ch_fileprep_result.lfq,
146+
CREATE_INPUT_CHANNEL.out.ch_expdesign,
147+
ch_searchengine_in_db,
148+
)
128149
ch_ids_pmultiqc = ch_ids_pmultiqc.mix(LFQ.out.ch_pmultiqc_ids)
129150
ch_consensus_pmultiqc = ch_consensus_pmultiqc.mix(LFQ.out.ch_pmultiqc_consensus)
130151
ch_pipeline_results = ch_pipeline_results.mix(LFQ.out.final_result)
131152
ch_msstats_in = ch_msstats_in.mix(LFQ.out.msstats_in)
132153
ch_versions = ch_versions.mix(LFQ.out.versions)
133154

134-
DIA(ch_fileprep_result.dia, CREATE_INPUT_CHANNEL.out.ch_expdesign, FILE_PREPARATION.out.statistics)
155+
DIA(
156+
ch_fileprep_result.dia,
157+
CREATE_INPUT_CHANNEL.out.ch_expdesign,
158+
FILE_PREPARATION.out.statistics,
159+
)
135160
ch_pipeline_results = ch_pipeline_results.mix(DIA.out.diann_report)
136161
ch_pipeline_results = ch_pipeline_results.mix(DIA.out.diann_report_parquet)
137162
ch_msstats_in = ch_msstats_in.mix(DIA.out.msstats_in)
138163
ch_versions = ch_versions.mix(DIA.out.versions)
139164
}
140165

141166
// Other subworkflow will return null when performing another subworkflow due to unknown reason.
142-
ch_versions = ch_versions.filter{ it != null }
167+
ch_versions = ch_versions.filter { it != null }
143168

144169
softwareVersionsToYAML(ch_versions)
145170
.collectFile(
146171
storeDir: "${params.outdir}/pipeline_info",
147-
name: 'nf_core_' + 'quantms_software_' + 'mqc_' + 'versions.yml',
172+
name: 'nf_core_' + 'quantms_software_' + 'mqc_' + 'versions.yml',
148173
sort: true,
149-
newLine: true
150-
).set { ch_collated_versions }
151-
152-
ch_multiqc_files = Channel.empty()
153-
ch_multiqc_config = Channel.fromPath("$projectDir/assets/multiqc_config.yml", checkIfExists: true)
154-
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config, checkIfExists: true) : Channel.empty()
155-
ch_multiqc_logo = params.multiqc_logo ? Channel.fromPath(params.multiqc_logo, checkIfExists: true) : Channel.empty()
156-
summary_params = paramsSummaryMap(workflow, parameters_schema: "nextflow_schema.json")
157-
ch_workflow_summary = Channel.value(paramsSummaryMultiqc(summary_params))
158-
ch_multiqc_custom_methods_description = params.multiqc_methods_description ? file(params.multiqc_methods_description, checkIfExists: true) : file("$projectDir/assets/methods_description_template.yml", checkIfExists: true)
159-
ch_methods_description = Channel.value(methodsDescriptionText(ch_multiqc_custom_methods_description))
160-
ch_multiqc_files = ch_multiqc_files.mix(ch_multiqc_config)
161-
ch_multiqc_files = ch_multiqc_files.mix(ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml'))
162-
ch_multiqc_files = ch_multiqc_files.mix(FILE_PREPARATION.out.statistics)
163-
ch_multiqc_files = ch_multiqc_files.mix(ch_collated_versions)
164-
ch_multiqc_files = ch_multiqc_files.mix(ch_methods_description.collectFile(name: 'methods_description_mqc.yaml', sort: false))
165-
ch_multiqc_quantms_logo = file("$projectDir/assets/nf-core-quantms_logo_light.png")
166-
167-
SUMMARY_PIPELINE (
168-
CREATE_INPUT_CHANNEL.out.ch_expdesign
169-
.combine(ch_pipeline_results.ifEmpty([]).combine(ch_multiqc_files.collect())
170-
.combine(ch_ids_pmultiqc.collect().ifEmpty([]))
171-
.combine(ch_consensus_pmultiqc.collect().ifEmpty([])))
172-
.combine(ch_msstats_in.ifEmpty([])),
173-
ch_multiqc_quantms_logo
174+
newLine: true,
175+
)
176+
.set { ch_collated_versions }
177+
178+
179+
ch_multiqc_config = Channel.fromPath("${projectDir}/assets/multiqc_config.yml", checkIfExists: true)
180+
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config, checkIfExists: true) : Channel.empty()
181+
ch_multiqc_logo = params.multiqc_logo ? Channel.fromPath(params.multiqc_logo, checkIfExists: true) : Channel.empty()
182+
summary_params = paramsSummaryMap(workflow, parameters_schema: "nextflow_schema.json")
183+
ch_workflow_summary = Channel.value(paramsSummaryMultiqc(summary_params))
184+
ch_multiqc_custom_methods_description = params.multiqc_methods_description
185+
? file(params.multiqc_methods_description, checkIfExists: true)
186+
: file("${projectDir}/assets/methods_description_template.yml", checkIfExists: true)
187+
ch_methods_description = Channel.value(methodsDescriptionText(ch_multiqc_custom_methods_description))
188+
// concatenate multiqc input files
189+
ch_multiqc_files = Channel.empty()
190+
ch_multiqc_files = ch_multiqc_files.mix(ch_multiqc_config)
191+
ch_multiqc_files = ch_multiqc_files.mix(ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml'))
192+
ch_multiqc_files = ch_multiqc_files.mix(FILE_PREPARATION.out.statistics)
193+
ch_multiqc_files = ch_multiqc_files.mix(ch_collated_versions)
194+
ch_multiqc_files = ch_multiqc_files.mix(ch_methods_description.collectFile(name: 'methods_description_mqc.yaml', sort: false))
195+
ch_multiqc_quantms_logo = file("${projectDir}/assets/nf-core-quantms_logo_light.png")
196+
197+
// create cross product of all inputs
198+
multiqc_inputs = CREATE_INPUT_CHANNEL.out.ch_expdesign
199+
.mix(ch_pipeline_results.ifEmpty([]))
200+
.mix(ch_multiqc_files.collect())
201+
.mix(ch_ids_pmultiqc.collect().ifEmpty([]))
202+
.mix(ch_consensus_pmultiqc.collect().ifEmpty([]))
203+
.mix(ch_msstats_in.ifEmpty([]))
204+
.collect()
205+
206+
SUMMARY_PIPELINE(
207+
multiqc_inputs,
208+
ch_multiqc_quantms_logo,
174209
)
175210

176211
emit:
177-
multiqc_report = SUMMARY_PIPELINE.out.ch_pmultiqc_report.toList()
178-
versions = ch_versions
212+
multiqc_report = SUMMARY_PIPELINE.out.ch_pmultiqc_report.toList()
213+
versions = ch_versions
179214
}
180-
181-
/*
182-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183-
THE END
184-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185-
*/

0 commit comments

Comments
 (0)