0
votes

I'm having the following problem: My Snakemake program does not recognise the output my python script generated. I tried both, writing the ouput to the stdout and from there into the correct output file and directly writing from the python script (which is the version below).

Setting --latency-wait to 600 did not help either. Other users reported that running ls helped which I tried while waiting for the latency but that didn't help either. Additionally, when running again,snakemake wants to run all input files again, despite some output files already existing. Does anyone have a suggestion what else I could try? This is the snakemake command I'm using:

snakemake -j 2 --use-conda

Below is my snakefile:

import os

dir = "my/data/dir"
cell_lines = os.listdir(dir)
files = os.listdir(dir+"GM12878/25kb_resolution_intrachromosomal")
chromosomes = [i.split("_")[0] for i in files]

rule all:
        input:
                expand("~/TADs/{cell_lines}_{chromosomes}_TADs.tsv", cell_lines = cell_lines, chromosomes = chromosomes)

rule tad_calling:
        input:
                "my/data/dir/{cell_lines}/25kb_resolution_intrachromosomal/{chromosomes}_25kb.RAWobserved"

        output:
                "~/TADs/{cell_lines}_{chromosomes}_TADs.tsv"

        benchmark:
              "benchmarks/{cell_lines}_{chromosomes}.txt"

        conda:
                "my_env.yaml"

        shell:
                """
                python ~/script.py {input} {output}
                """

1

1 Answers

2
votes

I think the problem is with the tilde (~), snakemake does not expand those (or e.g. $HOME). It takes those as the literal path. You could do something like:

from pathlib import Path
home = str(Path.home())

rule tad_calling:
    ...
    output:
        f"{home}/TADs/{cell_lines}_{chromosomes}_TADs.tsv"
    ...