From eb33fac11e720498d71ab753034df74d788f85bf Mon Sep 17 00:00:00 2001 From: maxulysse Date: Thu, 25 Apr 2024 13:57:39 +0200 Subject: [PATCH] better map --- workflows/imcyto/main.nf | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/workflows/imcyto/main.nf b/workflows/imcyto/main.nf index 1786de8..9f607fa 100644 --- a/workflows/imcyto/main.nf +++ b/workflows/imcyto/main.nf @@ -88,7 +88,8 @@ workflow IMCYTO { // Group full stack files by sample and roi_id // IMCTOOLS.out.full_stack_tiff - .map { flattenTiff(it) } + .map{ meta, tiff -> [ [meta + [roi:tiff[0].getParent().getParent().getName()]], tiff ]} + .transpose(by: [1]) .flatten() .collate(2) .groupTuple() @@ -100,7 +101,8 @@ workflow IMCYTO { // IMCTOOLS.out.ilastik_stack - .map { flattenTiff(it) } + .map{ meta, tiff -> [ [meta + [roi:tiff[0].getParent().getParent().getName()]], tiff ]} + .transpose(by: [1]) .flatten() .collate(2) .groupTuple() @@ -167,27 +169,6 @@ workflow IMCYTO { } -/* -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - FUNCTIONS -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*/ - -// Function to get list of [ [ id: sample_id, roi: roi_id ], path_to_file ] -def flattenTiff(ArrayList channel) { - def new_array = [] - def file_list = channel[1] - for (int i=0; i