This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Nextflow: absolute file path gets concatenated?

I am writing a nextflow workflow in DSL2 and running in the scratch directory of a HPC server. The process create_list has a simple goal: I would like to write a tsv file with two columns from an inputdir. The first column contains the file names for each file in inputdir and the second column contains the absolute path of each file.

I am passing in the absolute path /absolutepath/folder/data_folder however for some reason, nextflow (in the scratch directory) seems to be concatenating the path to just data_folder/

So instead of the desired output:

samplename    /absolutepath/folder/data_folder/chr1/samplename.chr1.vcf

the output file is:

samplename     data_folder/chr1/samplename.chr1.vcf

My code is below

params.inputdir = "/absolutepath/folder/data_folder"

process create_list {

    input:
    val(chrom)
    path inputdir

    output:
    tuple val(chrom), path("chr${chrom}_list.tsv")

    script:
    """
    chr_list="chr${chrom}_list.tsv"
    > \$chr_list

    for file_path in ${inputdir}/chr${chrom}/*.vcf; do
    column1=\$(basename "\$file_path" .chr${chrom}.vcf)
        column2="\$file_path"
        echo -e "\${column1}\\t\${column2}" >> "\$chr_list"
    done
    """
}
nextflow

hard to answer without seeing how create_list is invoked, but I would start with using

 val(inputdir)

instead of

 path inputdir

Thank you! @Pierre

I invoked it as:

 chrom_ch = Channel.from(1,2,3)
 create_list(chrom_ch, params.inputdir)

I am trying with val(inputdir)

Tthere seems to be some globbing issue perhaps? The output file is:

*.vcf    /absolutepath/folder/data_folder/chr1/samplename.chr1.vcf

0 answers

No answers yet.

Log in to answer this question.