snakefmt icon indicating copy to clipboard operation
snakefmt copied to clipboard

snakefmt moves interspersed comments

Open hepcat72 opened this issue 2 years ago • 1 comments

I intentionally changed some triple quoted shell strings to separate concatenated strings so that I could intersperse comments, but even though the code works, snakefmt moved the comments to the beginning and end.

Desired (note the space between the + and the "):

    shell:
        # Concatenate all the files together
        "cat {input:q} 2> {log.cat:q} | "
        # Coordinate sort everything
        + "sortBed 2> {log.sort:q} | "
        # Merge overlapping coordinates into individual expanded records
        + "mergeBed 2> {log.merge:q} 1> {output:q}"

snakefmt's munge:

    shell:
        # Concatenate all the files together
        "cat {input:q} 2> {log.cat:q} | "

        +"sortBed 2> {log.sort:q} | "

        +"mergeBed 2> {log.merge:q} 1> {output:q}"
        # Coordinate sort everything
        # Merge overlapping coordinates into individual expanded records

It also requires that the + be at the beginning of the next line and won't let them be at the end. If they are at the end, it gived a confusing syntax error.

Desired:

    shell:
        # Concatenate all the files together
        "cat {input:q} 2> {log.cat:q} | " +
        # Coordinate sort everything
        "sortBed 2> {log.sort:q} | " +
        # Merge overlapping coordinates into individual expanded records
        "mergeBed 2> {log.merge:q} 1> {output:q}"

snakefmt error:

snakefmt.exceptions.InvalidPython: Black error:
Cannot parse: 17:35: "cat {input:q} 2> {log.cat:q} | " +

How can I intersperse comments in multi-line shell strings without snakefmt moving them?

hepcat72 avatar May 25 '23 22:05 hepcat72

This is related to #129

mbhall88 avatar Jun 19 '23 23:06 mbhall88