# How to parse nested tuples in process input?

**URL:** <https://community.seqera.io/t/how-to-parse-nested-tuples-in-process-input/1340>\
**Category:** Ask for help\
**Tags:** nextflow\
**Created:** [October 29, 2024, 2:38am UTC](https://community.seqera.io/t/how-to-parse-nested-tuples-in-process-input/1340 "2024-10-29T02:38:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spaceturtle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/spaceturtle/32/1162_2.png) [@spaceturtle](https://community.seqera.io/u/spaceturtle)\
**Post date:** [October 29, 2024, 2:38am UTC](https://community.seqera.io/t/how-to-parse-nested-tuples-in-process-input/1340/1 "2024-10-29T02:38:06Z")

</div>

Hi, I generate a output channel emission from a process like the following:  
[id, [ [R1, id\_R1.fastq.gz], [R2, id\_R2.fastq.gz] ] ]. How to parse all elements in this emission separately in the input of the next process? I want to get something like this:  
input:  
tuple id, tuple(r1, r1file), tuple(r2, r2file) #Of course, this doesn’t work, but how to do it correctly?

---

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [October 29, 2024, 9:23am UTC](https://community.seqera.io/t/how-to-parse-nested-tuples-in-process-input/1340/2 "2024-10-29T09:23:48Z")

</div>

It’s not possible to do nested tuples in process output.

You should generally use a `.map` operator on the process output in order to make this kind of output.

There are two options. The first, which is uncommon, is to use `env` type to capture any string defined as an environment variable.  
The output then would be like:

```nextflow
output:
tuple val(meta), env('R1'), path('*_R1.fastq.gz'), env('R2'), path('*_R2.fastq.gz')

```

The other more common way to use Groovy to form the R1 and R2 strings

```nextflow
tuple val(meta), path('*_R1.fastq.gz'), path('*_R2.fastq.gz')

```

and then after the process is called

```nextflow
PROCESS.out.fastq
    .map { meta, r1_fq, r2_fq ->
        tuple( meta, tuple( r1_fq.simpleName, r1_fq ), tuple( r2_fq.simpleName, r2_fq) )
    }

```

Note: In `map` you can do nested `tuple`’s
