Dear all, I have been wrestling with a workflow th...
# help
m
Dear all, I have been wrestling with a workflow that I can't get to work for weeks now and nothing I try seems to work. Hopefully somebody here can tell me what (obvious 🙂 ) solution I'm missing here... the workflow is part of a larger pipeline for Oxford Nanopore basecalling. In the step that I can't get to work, NF needs to copy and rename randomly named .fastq files from two different folders, by prefixing them with a pre-configured run name ( ${params.RunInput} and moving them to a new folder. I made channels from the 2 folders, But I can't figure out how to isolate only the file name, in stead of the whole path. Any ideas are welcome at this point. If it helps, this is the code as it is now:
Copy code
#! /usr/bin/env nextflow

params.SaveLocation = '/processing/allfiles/${params.RunInput}'

 

process FileCleanupduplex {

fileduplex = file('${filelocduplex}')

        input:
        val filelocduplex
 
       script:
        """
        cp "${filelocduplex}" "${params.SaveLocation}/${params.RunInput}_duplex_${fileduplex}"
        """
}

process FileCleanupsimplex {

filesimplex = file('${filelocsimplex}')

        input:
        val filelocsimplex
        script:
        """
        cp "${filelocsimplex}" "${params.SaveLocation}/${params.RunInput}_simplex_${filesimplex}"
        """
}

workflow {

         filelocduplex = channel.fromPath('/processing/demux/duplex/*.fastq')
         filelocsimplex = channel.fromPath('/processing/demux/simplex/*.fastq')
         FileCleanupduplex(filelocduplex, fileduplex)
         FileCleanupsimplex(filelocsimplex, fileduplex)
}
n
Hi what you are trying to do here is definitely not the optimal way to achieve the file renaming. I would suggest you try to rename the files while staging them in the process where they are needed. You can use
name
or
stageAs
to do that for you (https://www.nextflow.io/docs/latest/reference/process.html#inputs-and-outputs-legacy)
Copy code
input:
path(duplex_fastqs, name: "${params.RunInput}_duplex_*")
should normally do what you want (not 100% sure though since it's been a while)
t
I would definitely use `stageAs`/`name` whenever you can. If you really need the basename or extension of a file, have a look at the attributes in the documentation of the Path type.