Nextflow: absolute file path gets concatenated?
0
0
Entering edit mode
8 months ago
Eliveri ▴ 350

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 • 901 views
ADD COMMENT
2
Entering edit mode

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

 val(inputdir)

instead of

 path inputdir
ADD REPLY
0
Entering edit mode

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
ADD REPLY

Login before adding your answer.

Traffic: 2937 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6