Search code examples
pythonsnakemakerawstring

Syntax warning for escaped period in triple-quoted shell rule


I get the following warning:

SyntaxWarning: invalid escape sequence '\.'

when the following shell block is present in a rule:

        """
        curl {params.ua} -L {params.url} \
        | gzip -dc \
        | sd '^.*gene_id "([A-Z0-9\.]+).*"; transcript_id "([A-Z0-9\.]+)".*;.*' '$2\t$1' \
        | uniq | gzip > {output}
        """

The warning gives me a line number in another rule, commenting out the other rule doesn't resolve the warning (and the other rule doesn't have a '.'). Commenting out the rule with the above shell block does resolve the warning. The shell code seems to work as intended, so maybe I just need to format it differently such that Snakemake is happy and it still does what I want it to, but I can't figure this out so far.


Solution

  • It's possible to specify that this is a raw string:

       r"""
       ... \. ...
       """