-
Hi, I have the following use case but I cannot wrap my mind around how to achieve in NF, any suggestions are welcome: USE CASEInitial conditions: I process multiple samples at a single run. Every sample is being represented by a sample name and a variable-sized list of files, e.g, [sample1, [file1, file2,..,file15]], [sample2, [file1, file2,..,file310]] . This list is dynamically computed during runtime, by scanning a directory for files that starts with sample1, sample2, etc. I guess I need something combining transpose and buffer, but I have not yet managed to get to the expected solution. This is what I have already done:
which clearly does not respect the groups boundaries, therefore I am getting something like [sample1, [file11,..file15,file1,..file5]] , following the example provided before. Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It is not quite clear what you are trying to achieve, so the suggestion below may or may not be appropriate. If I've misunderstood, would you be able to provide a small example workflow showing the problem? Given input data:
We can generate a channel that meets your input requirements: workflow {
Channel.fromPath("data/sample*/*.dat")
| map { [it.getParent().name, it] }
| groupTuple
| view
} Which emits a channel with contents:
Now let's say that we want to split up the List of files into chunks of at most 3 files. We can use the workflow {
Channel.fromPath("data/sample*/*.dat")
| map { [it.getParent().name, it] }
| groupTuple
| flatMap { id, files -> files.collate(3).collect { chunk -> [id, chunk] } }
| view
} Which returns a channel that emits:
Is this close to what you were looking for? |
Beta Was this translation helpful? Give feedback.
It is not quite clear what you are trying to achieve, so the suggestion below may or may not be appropriate. If I've misunderstood, would you be able to provide a small example workflow showing the problem?
Given input data:
We can generate a channel that meets your input requirements:
Which emits a channel with contents: