I am trying to combine Snakemake with Singularity, and I noticed that a simple awk
command no longer works when using singularity. The $1
in the last line gets replaced by bash instead of being used as the first field by awk
.
Here is a minimal working example (Snakefile):
singularity: "docker://debian:stretch"
rule all:
input: "test.txt"
rule test:
output:
"test.txt"
shell:
"cat /etc/passwd | awk -F':' '{{print $1}}' > {output}"
When I run snakemake
without singularity, the output test.txt
looks as expected (containing only user names). When I run snakemake --use-singularity
, the file contains whole lines, e.g. root:x:0:0:root:/root:/bin/bash
.
This is the log from Snakemake:
$ snakemake --use-singularity --printshellcmd
Building DAG of jobs...
Using shell: /usr/bin/bash
Provided cores: 1
Rules claiming more threads will be scaled down.
Job counts:
count jobs
1 all
1 test
2
rule test:
output: test.txt
jobid: 1
cat /etc/passwd | awk -F':' '{print $1}' > test.txt
Activating singularity image /scratch/test/.snakemake/singularity/fa9c8c7220ff16e314142a5d78ad6cff.simg
Finished job 1.
1 of 2 steps (50%) done
localrule all:
input: test.txt
jobid: 0
Finished job 0.
2 of 2 steps (100%) done