A while back I wrote the nf-core module for PoolSN...
# modules
a
A while back I wrote the nf-core module for PoolSNP (https://github.com/nf-core/modules/tree/master/modules/nf-core/poolsnp). Since PoolSNP itself relies on specifying the full path of the inut files when the executable is called, I had to rely on using
$PWD
prefixed to the input files for the module to work fine. On previous runs, this would generate the
command.sh
as shown below with the
$PWD
variable expanding correctly to the work directory assigned to the POOLSNP process -
Copy code
#!/bin/bash -euo pipefail
PoolSNP.sh \
    mpileup=$PWD/S100817_EDSW200002471-1a_H2MKLDSXY_L2.mpileup.gz \
    output=$PWD/S100817_EDSW200002471-1a_H2MKLDSXY_L2 \
    names=S100817_EDSW200002471-1a_H2MKLDSXY_L2 \
    reference=$PWD/dmel-all-chromosome-r6.57.fasta \
    jobs=4 \
    max-cov=0.7 \
    min-cov=4 min-count=4 min-freq=0.01 miss-frac=0.5 badsites=1 allsites=1

cat <<-END_VERSIONS > versions.yml
ABHILESH_POOLSEQFREQ:POOLSEQFREQ:POOLSNP:
    poolsnp: "1.0.1"
END_VERSIONS
However, after a recent update (I don't know which one),
$PWD
is getting expanded earlier and is substituted with the path of the directory where the nextflow command is called from -
Copy code
#!/usr/bin/env bash

set -e # Exit if a tool returns a non-zero status/exit code
set -u # Treat unset variables and parameters as an error
set -o pipefail # Returns the status of the last command to exit with a non-zero status or zero if all successfully execute
set -C # No clobber - prevent output redirection from overwriting files.

PoolSNP.sh \\
    mpileup=\/Users/abhilesh/Documents/Github_projects/poolseqfreq/test.mpileup.gz \\
    output=\/Users/abhilesh/Documents/Github_projects/poolseqfreq/test \\
    names=test \\
    reference=\/Users/abhilesh/Documents/Github_projects/poolseqfreq/genome.fasta \\
    jobs=2 \\
    max-cov=0.7 \\
    min-cov=4 min-count=4 min-freq=0.01 miss-frac=0.5 badsites=1 allsites=1

cat <<-END_VERSIONS > versions.yml
ABHILESH_POOLSEQFREQ:POOLSEQFREQ:POOLSNP:
    poolsnp: "1.0.1"
END_VERSIONS
This breaks the execution of the POOLSNP process as it can no longer find the correct input files. How should I go about resolving this? Any tips are very much appreciated
Just adding that the first
.command.sh
was run using Nextflow v24.04.4, while the latter was run using Nextflow v24.10.0
n
I think you need to escape
\$PWD
to make sure that it is expanded when command.sh is executed and not when it is created. I dont think this is new behaviour though?
a
The
\$PWD
is indeed escaped in the module - https://github.com/nf-core/modules/blob/685fbead1e7082e7439bf7972d336ad1a90ce4e1/modules/nf-core/poolsnp/main.nf#L31C2-L38C14 I haven't made any code changes and simply ran the pipeline with the updated version of nextflow
n
I see,.. There seems to be more off with escapes in the second
.command.sh
, e.g. there should only be a single
\
at the end of each line. Maybe what causes the wrongly expanded variable is related to the containerization (if you are using any) not unsetting the user env before starting the container, but that should not be module specific and I think this would happen later, your command.sh should contain
$PWD
a
Ah, yes that was it! I installed the nf-core-extensionpack for VS Code, which formatted the file and treated those as comment lines, adding the extra \. It's resolved now! Thanks a lot for your help!