@@ -135,7 +135,7 @@ workflow PREPARE_GENOME {
135135 }
136136
137137 CUSTOM_CATADDITIONALFASTA (
138- ch_fasta. combine(ch_gtf). map { f , g -> [ [:], f, g ] },
138+ ch_fasta. combine(ch_gtf). map { fasta , gtf -> [ [:], fasta, gtf ] },
139139 ch_add_fasta. map { [ [:], it ] },
140140 gencode ? " gene_type" : featurecounts_group_type
141141 )
@@ -224,11 +224,11 @@ workflow PREPARE_GENOME {
224224 // Build it from scratch if we have FASTA
225225 Channel
226226 .from(file(bbsplit_fasta_list, checkIfExists : true ))
227- .splitCsv()
228- .flatMap { id, fafile -> [ [ ' id' , id ], [ ' fasta' , file(fafile, checkIfExists : true ) ] ] }
227+ .splitCsv() // Read in 2 column csv file: short_name,path_to_fasta
228+ .flatMap { id, fafile -> [ [ ' id' , id ], [ ' fasta' , file(fafile, checkIfExists : true ) ] ] } // Flatten entries to be able to groupTuple by a common key
229229 .groupTuple()
230- .map { it -> it[1 ] }
231- .collect { [ it ] }
230+ .map { it -> it[1 ] } // Get rid of keys and keep grouped values
231+ .collect { [ it ] } // Collect entries as a list to pass as "tuple val(short_names), path(path_to_fasta)" to module
232232 .set { ch_bbsplit_fasta_list }
233233
234234 ch_bbsplit_index = BBMAP_BBSPLIT (
@@ -362,6 +362,30 @@ workflow PREPARE_GENOME {
362362 // 14) Salmon index -> can skip genome if transcript_fasta is enough
363363 // ------------------------------------------------------
364364 ch_salmon_index = Channel . empty()
365+ //
366+ // Uncompress Salmon index or generate from scratch if required
367+ //
368+ ch_salmon_index = Channel . empty()
369+ if (salmon_index) {
370+ if (salmon_index. endsWith(' .tar.gz' )) {
371+ ch_salmon_index = UNTAR_SALMON_INDEX ( [ [:], salmon_index ] ). untar. map { it[1 ] }
372+ ch_versions = ch_versions. mix(UNTAR_SALMON_INDEX . out. versions)
373+ } else {
374+ ch_salmon_index = Channel . value(file(salmon_index))
375+ }
376+ } else if (' salmon' in prepare_tool_indices) {
377+ if (ch_transcript_fasta && fasta_provided) {
378+ // build from transcript FASTA + genome FASTA
379+ ch_salmon_index = SALMON_INDEX (ch_fasta, ch_transcript_fasta). index
380+ ch_versions = ch_versions. mix(SALMON_INDEX . out. versions)
381+ }
382+ else if (ch_transcript_fasta) {
383+ // some Salmon module can run with just a transcript FASTA
384+ ch_salmon_index = SALMON_INDEX ([], ch_transcript_fasta). index
385+ ch_versions = ch_versions. mix(SALMON_INDEX . out. versions)
386+ }
387+ }
388+
365389 if (' salmon' in prepare_tool_indices) {
366390 if (salmon_index) {
367391 // use user-provided salmon index
@@ -388,18 +412,17 @@ workflow PREPARE_GENOME {
388412 // 15) Kallisto index -> only needs transcript FASTA
389413 // --------------------------------------------------
390414 ch_kallisto_index = Channel . empty()
391- if (' kallisto' in prepare_tool_indices) {
392- if (kallisto_index) {
393- if (kallisto_index. endsWith(' .tar.gz' )) {
394- ch_kallisto_index = UNTAR_KALLISTO_INDEX ([ [:], file(kallisto_index, checkIfExists : true ) ]). untar
395- ch_versions = ch_versions. mix(UNTAR_KALLISTO_INDEX . out. versions)
396- } else {
397- ch_kallisto_index = Channel . value([ [:], file(kallisto_index, checkIfExists : true ) ])
398- }
415+ if (kallisto_index) {
416+ if (kallisto_index. endsWith(' .tar.gz' )) {
417+ ch_kallisto_index = UNTAR_KALLISTO_INDEX ( [ [:], kallisto_index ] ). untar
418+ ch_versions = ch_versions. mix(UNTAR_KALLISTO_INDEX . out. versions)
419+ } else {
420+ ch_kallisto_index = Channel . value([[:], file(kallisto_index)])
399421 }
400- else if (ch_transcript_fasta) {
401- ch_kallisto_index = KALLISTO_INDEX (ch_transcript_fasta. map { [ [:], it ] }). index
402- ch_versions = ch_versions. mix(KALLISTO_INDEX . out. versions)
422+ } else {
423+ if (' kallisto' in prepare_tool_indices) {
424+ ch_kallisto_index = KALLISTO_INDEX ( ch_transcript_fasta. map { [ [:], it] } ). index
425+ ch_versions = ch_versions. mix(KALLISTO_INDEX . out. versions)
403426 }
404427 }
405428
0 commit comments