SyntaxError in file /snakefile, line 22: invalid decimal literal: None
0
0
Entering edit mode
9 days ago
Ana ▴ 10

Hi,

I am doing a dry-run on a snakefile but I am getting an error:

SyntaxError in file /snakefile, line 22:
invalid decimal literal:
None

Line 22 looks like this:

expand(f'/{{CHR}}.merged.split.no_geno.annotated.vcf.gz', CHR = chrlist)

To clarify, chrlist comes from

chrlist = config['chromosomes']

in line 5. The path to the config file is also declared in line 1. Anyone knows what could be causing this issue? Thanks in advance.

python snakemake • 483 views
ADD COMMENT
0
Entering edit mode

I am not a SnakeMake person but what is the f supposed to be? f'/{{...

ADD REPLY
1
Entering edit mode

That's Python's f-string, which in this case just turns {{CHR}} into {CHR}, which is then in turn handled by Snakemake's expand function (which also happens to use curly braces) to do its own string templating with what's presumably a list of stuff to use in the filenames... which means there's no need for the f-string here, actually.

In an interactive Python interpreter, with Snakemake installed:

>>> from snakemake.io import expand
>>> chrlist = [1, 2, 3]
>>> expand(f'/{{CHR}}.merged.split.no_geno.annotated.vcf.gz', CHR = chrlist)
['/1.merged.split.no_geno.annotated.vcf.gz', '/2.merged.split.no_geno.annotated.vcf.gz', '/3.merged.split.no_geno.annotated.vcf.gz']

Or without the redundant f-string:

>>> expand('/{CHR}.merged.split.no_geno.annotated.vcf.gz', CHR = chrlist)

I can't think of why that line would give that error no matter what chrlist contains, but, Snakemake can sometimes report misleading line numbers when it runs into problems early in parsing files... Ana, I'd put some print calls in a few spots and see what things look like. Does chrlist look like you expect? What other code is around line 22? If you're stumped, make an as-small-as-possible Snakefile that gives the error and then you can share the whole thing verbatim. (Also, it's odd that you have a leading / on the path, but I'd say that's a separate potential issue.)

ADD REPLY
0
Entering edit mode

Thank you so much for this! I am going to add some print calls and see, as well as a toy snakefile. The redundancy between f and expand is not what's giving the error though (I' ve tried removing it and the same error arises). Also, the leading / is because I deleted the complete path and must have forgotten that!

ADD REPLY
0
Entering edit mode

That all makes sense! My best guess is something totally unexpected from somewhere else in the file and it's reporting the wrong line. (It looks like that error is what Python throws if you use an invalid name like 0variable = "something" in regular Python. So maybe it's a problem during Snakemake's parsing of your file, I wonder. Edit: the same error also comes up with variable = 0something, if that ends up looking relevant for your code somehow.)

ADD REPLY

Login before adding your answer.

Traffic: 3951 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6