2022-07-12 09:39:26 +00:00
|
|
|
//
|
2022-09-06 15:34:45 +00:00
|
|
|
// Standardise output files e.g. aggregation
|
2022-07-12 09:39:26 +00:00
|
|
|
//
|
|
|
|
|
2022-09-06 15:34:45 +00:00
|
|
|
include { KAIJU_KAIJU2TABLE } from '../../modules/nf-core/modules/kaiju/kaiju2table/main'
|
2022-07-12 09:39:26 +00:00
|
|
|
include { MOTUS_MERGE } from '../../modules/nf-core/modules/motus/merge/main'
|
|
|
|
|
|
|
|
workflow STANDARDISATION_PROFILES {
|
|
|
|
take:
|
|
|
|
classifications
|
|
|
|
profiles
|
|
|
|
databases
|
|
|
|
motu_version
|
|
|
|
|
|
|
|
main:
|
|
|
|
ch_standardised_tables = Channel.empty()
|
|
|
|
ch_versions = Channel.empty()
|
2022-09-06 15:34:45 +00:00
|
|
|
ch_multiqc_files = Channel.empty()
|
2022-07-12 09:39:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Split profile results based on tool they come from
|
|
|
|
*/
|
|
|
|
ch_input_profiles = profiles
|
|
|
|
.branch {
|
|
|
|
motus: it[0]['tool'] == 'motus'
|
|
|
|
unknown: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ch_input_classifications = classifications
|
|
|
|
.branch {
|
2022-09-06 15:34:45 +00:00
|
|
|
kaiju: it[0]['tool'] == 'kaiju'
|
2022-07-12 09:39:26 +00:00
|
|
|
unknown: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ch_input_databases = databases
|
|
|
|
.branch {
|
|
|
|
motus: it[0]['tool'] == 'motus'
|
2022-09-06 15:34:45 +00:00
|
|
|
kaiju: it[0]['tool'] == 'kaiju'
|
2022-07-12 09:39:26 +00:00
|
|
|
unknown: true
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Standardise and aggregate
|
|
|
|
*/
|
|
|
|
|
2022-09-06 15:34:45 +00:00
|
|
|
// Kaiju
|
|
|
|
|
|
|
|
// Collect and replace id for db_name for prefix
|
|
|
|
ch_profiles_for_kaiju = ch_input_classifications.kaiju
|
|
|
|
.map { [it[0]['db_name'], it[1]] }
|
|
|
|
.groupTuple()
|
|
|
|
.map {
|
|
|
|
[[id:it[0]], it[1]]
|
|
|
|
}
|
|
|
|
|
|
|
|
KAIJU_KAIJU2TABLE ( ch_profiles_for_kaiju, ch_input_databases.kaiju.map{it[1]}, params.kaiju_taxon_rank)
|
|
|
|
ch_standardised_tables = ch_standardised_tables.mix( KAIJU_KAIJU2TABLE.out.summary )
|
|
|
|
ch_multiqc_files = ch_multiqc_files.mix( KAIJU_KAIJU2TABLE.out.summary )
|
|
|
|
ch_versions = ch_versions.mix( KAIJU_KAIJU2TABLE.out.versions )
|
|
|
|
|
2022-07-12 09:39:26 +00:00
|
|
|
// mOTUs has a 'single' database, and cannot create custom ones.
|
|
|
|
// Therefore removing db info here, and publish merged at root mOTUs results
|
|
|
|
// directory
|
|
|
|
MOTUS_MERGE ( ch_input_profiles.motus.map{it[1]}.collect(), ch_input_databases.motus.map{it[1]}, motu_version, params.generate_biom_output )
|
|
|
|
if ( params.generate_biom_output ) {
|
|
|
|
ch_standardised_tables = ch_standardised_tables.mix ( MOTUS_MERGE.out.biom )
|
|
|
|
} else {
|
|
|
|
ch_standardised_tables = ch_standardised_tables.mix ( MOTUS_MERGE.out.txt )
|
|
|
|
}
|
|
|
|
ch_versions = ch_versions.mix( MOTUS_MERGE.out.versions )
|
|
|
|
|
|
|
|
emit:
|
2022-09-06 15:34:45 +00:00
|
|
|
tables = ch_standardised_tables
|
2022-07-12 09:39:26 +00:00
|
|
|
versions = ch_versions
|
2022-09-06 15:34:45 +00:00
|
|
|
mqc = ch_multiqc_files
|
2022-07-12 09:39:26 +00:00
|
|
|
}
|