This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Snakemake's SyntaxError positional argument follows keyword argument

Hello all,

I'm trying to dry-run a snakemake pipeline but I get a SyntaxError in line 75 "positional argument follows keyword argument". The thing is, it's pointing towards a benchmark line (*) in an intermediate rule, that follows the same pattern as previous rules... I don't understand what might be the problem.

This is the structure of the rules I'm writing:

rule name:
    input:
        i1 = "...",
        i2 = "..."
    output:
        a = "...",
        b = "...",
        c = "..."
    threads:
        n
    log:
        "..."
    *benchmark:
        "benchmarks/(...).benchmark.txt"
    message:
        "(...)"
    shell:
        """
        (...)
        """

All the input and output files are named and separated by commas. Nevertheless, the error points to 'benchmark:' (*). Does anyone know why this is happening?

EDIT: If I remove the benchmark line, the error simply points to the previous or the next line in the rule, and if I keep chipping away at the rule, (leaving only the input lines), eventually the error points to an empty line. If I add/remove empty lines between rules, the error points to different empty lines or, when there are none, to any line in the closest rule. I have no idea what this is.

Thank you.

snakemake

Please explain how this is related to bioinformatics.

2 answers

Hello again,

In the meantime I fixed the code. This SyntaxError in particular wasn't real. I went ahead and fixed some minor errors in the code (mistyping, extra commas and whatnot) and this specific SyntaxError eventually disappeared. This was most likely a bug on Snakemake's part, not being able to locate the real error. It's a shame because it made me waste a lot of time.

It's unlikely it is a bug in snakemake. My guess is that you had something like this:

rule one:
    output:
        'done.txt',
    params:
        a='x', # <- Keyword argument
        'y',   # <- Positional argument

This would be ok:

rule one:
    output:
        'done.txt',
    params:
        'y',
        a='x',

Log in to answer this question.