2022-06-27 13:22:47 +00:00
|
|
|
//
|
|
|
|
// Create Krona visualizations
|
|
|
|
//
|
|
|
|
|
2022-06-27 14:23:20 +00:00
|
|
|
include { KAIJU_KAIJU2KRONA } from '../../modules/nf-core/modules/kaiju/kaiju2krona/main'
|
2022-06-27 13:22:47 +00:00
|
|
|
include { KRAKENTOOLS_KREPORT2KRONA } from '../../modules/nf-core/modules/krakentools/kreport2krona/main'
|
|
|
|
include { KRONA_CLEANUP } from '../../modules/local/krona_cleanup'
|
|
|
|
include { KRONA_KTIMPORTTEXT } from '../../modules/nf-core/modules/krona/ktimporttext/main'
|
|
|
|
|
|
|
|
workflow VISUALIZATION_KRONA {
|
|
|
|
take:
|
2022-06-27 17:12:16 +00:00
|
|
|
classifications
|
2022-06-27 13:22:47 +00:00
|
|
|
profiles
|
2022-06-27 14:23:20 +00:00
|
|
|
databases
|
2022-06-27 13:22:47 +00:00
|
|
|
|
|
|
|
main:
|
|
|
|
ch_krona_text = Channel.empty()
|
|
|
|
ch_krona_html = Channel.empty()
|
|
|
|
ch_versions = Channel.empty()
|
|
|
|
|
|
|
|
/*
|
|
|
|
Split profile results based on tool they come from
|
|
|
|
*/
|
|
|
|
ch_input_profiles = profiles
|
|
|
|
.branch {
|
2022-06-27 13:52:29 +00:00
|
|
|
centrifuge: it[0]['tool'] == 'centrifuge'
|
2022-06-27 13:22:47 +00:00
|
|
|
kraken2: it[0]['tool'] == 'kraken2'
|
|
|
|
unknown: true
|
|
|
|
}
|
2022-06-27 17:12:16 +00:00
|
|
|
ch_input_classifications = classifications
|
|
|
|
.branch {
|
|
|
|
kaiju: it[0]['tool'] == 'kaiju'
|
|
|
|
unknown: true
|
|
|
|
}
|
2022-06-27 13:22:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Convert Kraken2 formatted reports into Krona text files
|
|
|
|
*/
|
|
|
|
ch_kraken_reports = ch_input_profiles.kraken2
|
2022-06-27 13:52:29 +00:00
|
|
|
.mix( ch_input_profiles.centrifuge )
|
2022-06-27 13:22:47 +00:00
|
|
|
KRAKENTOOLS_KREPORT2KRONA ( ch_kraken_reports )
|
|
|
|
ch_krona_text = ch_krona_text.mix( KRAKENTOOLS_KREPORT2KRONA.out.txt )
|
|
|
|
ch_versions = ch_versions.mix( KRAKENTOOLS_KREPORT2KRONA.out.versions.first() )
|
|
|
|
|
2022-06-27 14:23:20 +00:00
|
|
|
/*
|
|
|
|
Combine Kaiju profiles with their databases
|
|
|
|
*/
|
2022-06-27 17:12:16 +00:00
|
|
|
ch_input_for_kaiju2krona = ch_input_classifications.kaiju
|
2022-06-27 14:23:20 +00:00
|
|
|
.map{ [it[0]['db_name'], it[0], it[1]] }
|
|
|
|
.combine( databases.map{ [it[0]['db_name'], it[1]] }, by: 0 )
|
|
|
|
.multiMap{
|
|
|
|
it ->
|
|
|
|
profiles: [it[1], it[2]]
|
|
|
|
db: it[3]
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Convert Kaiju formatted reports into Krona text files
|
|
|
|
*/
|
|
|
|
KAIJU_KAIJU2KRONA( ch_input_for_kaiju2krona.profiles, ch_input_for_kaiju2krona.db )
|
|
|
|
ch_krona_text = ch_krona_text.mix( KAIJU_KAIJU2KRONA.out.txt )
|
|
|
|
ch_versions = ch_versions.mix( KAIJU_KAIJU2KRONA.out.versions.first() )
|
|
|
|
|
2022-06-27 13:22:47 +00:00
|
|
|
/*
|
|
|
|
Remove taxonomy level annotations from the Krona text files
|
|
|
|
*/
|
|
|
|
KRONA_CLEANUP( ch_krona_text )
|
|
|
|
ch_cleaned_krona_text = KRONA_CLEANUP.out.txt
|
|
|
|
ch_versions = ch_versions.mix( KRONA_CLEANUP.out.versions.first() )
|
|
|
|
|
|
|
|
/*
|
|
|
|
Convert Krona text files into html Krona visualizations
|
|
|
|
*/
|
|
|
|
ch_krona_text_for_import = ch_cleaned_krona_text
|
|
|
|
.map{[[id: it[0]['db_name']], it[1]]}
|
|
|
|
.groupTuple()
|
|
|
|
KRONA_KTIMPORTTEXT( ch_krona_text_for_import )
|
|
|
|
ch_krona_html = ch_krona_html.mix( KRONA_KTIMPORTTEXT.out.html )
|
|
|
|
ch_versions = ch_versions.mix( KRONA_KTIMPORTTEXT.out.versions.first() )
|
|
|
|
|
|
|
|
emit:
|
|
|
|
html = ch_krona_html
|
|
|
|
versions = ch_versions
|
|
|
|
}
|