this is my code:

#!/usr/bin/env nextflow

nextflow.enable.dsl=2


process TRIMMOMATIC {

    cpus 6

    input:
        tuple val(sample), path(fastq)
        val metadata

    output:
        tuple val(sample), path("*.paired.trim*.fastq.gz"), emit: trim_paired

    script:
    """
    PREFIX=\$(awk -F'\t' '{print $5}' <(grep "SRR6170753" metadata.txt))
    
    trimmomatic \\
    PE \\
    -threads ${task.cpus} \\
    ${fastq[0]} ${fastq[1]} \\
    ${sample}.paired.trim_1.fastq.gz ${sample}.unpaired.trim_1.fastq.gz \\
    ${sample}.paired.trim_2.fastq.gz ${sample}.unpaired.trim_2.fastq.gz \\
    -phred33 \\
    SLIDINGWINDOW:4:20 MINLEN:30

    rm ${sample}.unpaired.trim_1.fastq.gz ${sample}.unpaired.trim_2.fastq.gz
    """
}

and I need to modify it to choose a trimmomatic adapter based on the prefix. The logic is taken from this script:

if [[ ${params} == DL_LTE_rn1_* ]]
then
# adaptor trimming
# single ends
java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar SE -phred33 -threads 1 data/fastq_files/${params}.R0.fastq.gz data/trimmed_fastq_files/${params}.R0.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/NexteraPE-PE.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.trim.unpaired.txt

# paired ends
java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar PE -phred33 -threads 1 data/fastq_files/${params}.R1.fastq.gz data/fastq_files/${params}.R2.fastq.gz data/trimmed_fastq_files/${params}.R1.fastq data/trimmed_fastq_files/${params}.R1.unpaired.fastq data/trimmed_fastq_files/${params}.R2.fastq data/trimmed_fastq_files/${params}.R2.unpaired.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/NexteraPE-PE.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.trim.paired.txt
fi

if [[ ${params} == ara* ]]
then

java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar PE -phred33 -threads 1 data/fastq_files/${params}.R1.fastq.gz data/fastq_files/${params}.R2.fastq.gz data/trimmed_fastq_files/${params}.R1.fastq data/trimmed_fastq_files/${params}.R1.unpaired.fastq data/trimmed_fastq_files/${params}.R2.fastq data/trimmed_fastq_files/${params}.R2.unpaired.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/NexteraPE-PE.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.trim.paired.txt

fi

if [[ ${params} == batch* ]]
then

java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar PE -phred33 -threads 1 data/fastq_files/${params}.R1.fastq.gz data/fastq_files/${params}.R2.fastq.gz data/trimmed_fastq_files/${params}.R1.fastq data/trimmed_fastq_files/${params}.R1.unpaired.fastq data/trimmed_fastq_files/${params}.R2.fastq data/trimmed_fastq_files/${params}.R2.unpaired.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/NexteraPE-PE.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.trim.paired.txt

fi

if [[ ${params} == CL* ]]
then

#lane 1
java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar PE -phred33 -threads 1 data/fastq_files/${params}.L1.R1.fastq.gz data/fastq_files/${params}.L1.R2.fastq.gz data/trimmed_fastq_files/${params}.L1.R1.fastq data/trimmed_fastq_files/${params}.L1.R1.unpaired.fastq data/trimmed_fastq_files/${params}.L1.R2.fastq data/trimmed_fastq_files/${params}.L1.R2.unpaired.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/NexteraPE-PE.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.L1.trim.paired.txt

#lane 2
java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar PE -phred33 -threads 1 data/fastq_files/${params}.L2.R1.fastq.gz data/fastq_files/${params}.L2.R2.fastq.gz data/trimmed_fastq_files/${params}.L2.R1.fastq data/trimmed_fastq_files/${params}.L2.R1.unpaired.fastq data/trimmed_fastq_files/${params}.L2.R2.fastq data/trimmed_fastq_files/${params}.L2.R2.unpaired.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/NexteraPE-PE.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.L2.trim.paired.txt

fi

if [[ ${params} == SRR* || ${params} == ERR* ]]
then

if [ ! -e "data/fastq_files/${sample_name}_2.fastq.gz" ]
then
    # single end

java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar SE -phred33 -threads 1 data/fastq_files/${params}_1.fastq.gz data/trimmed_fastq_files/${params}.R0.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/TruSeq3-PE-2.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.trim.unpaired.txt

else

java -jar ${TRIMMOMATIC}/trimmomatic-0.32.jar PE -phred33 -threads 1 data/fastq_files/${params}_1.fastq.gz data/fastq_files/${params}_2.fastq.gz data/trimmed_fastq_files/${params}.R1.fastq data/trimmed_fastq_files/${params}.R1.unpaired.fastq data/trimmed_fastq_files/${params}.R2.fastq data/trimmed_fastq_files/${params}.R2.unpaired.fastq ILLUMINACLIP:${TRIMMOMATIC}/adapters/TruSeq3-PE-2.fa:2:30:10:2:'false' LEADING:20 TRAILING:20 2> data/trimmed_fastq_files/${params}.trim.paired.txt

fi

fi

I am not working with single-end data so all the if statements checking for paired-end fastqs could be gone. This line in my code: \$(awk -F'\t' '{print $5}' <(grep "SRR6170753" metadata.txt)) produces this for a random sample: CL4_1_TAGGCATG-ATTGACAT