-
Notifications
You must be signed in to change notification settings - Fork 1
Snakemake version 8+ support #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| def run_snakemake(config, workdir, cores=1, dryrun=False): | ||
| outcfg = smk_types.OutputSettings(printshellcmds=True) | ||
| with smk_api(outcfg) as smk: | ||
| workflow = smk.workflow( | ||
| config_settings=smk_types.ConfigSettings(config=config), | ||
| storage_settings=smk_types.StorageSettings(), | ||
| resource_settings=smk_types.ResourceSettings(cores=cores), | ||
| snakefile=files("microhapulator") / "workflows" / "analysis.smk", | ||
| workdir=Path(workdir), | ||
| ) | ||
| dag = workflow.dag(smk_types.DAGSettings(targets=["report"])) | ||
| mode = "dryrun" if dryrun else "local" | ||
| dag.execute_workflow(executor=mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is close to the minimal code required to replicate the flags I commonly used with the snakemake.snakemake command in version 7 and below.
| "analysis/{}/03typing/callplots".format(wildcards.sample), | ||
| f"analysis/{wildcards.sample}/03typing/callplots", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reinstating f-strings since they don't break Python 3.12 in Snakemake 9.
| threshfile="" if config["thresh_file"] == "" else f"--config {config['thresh_file']}", | ||
| threshfile=( | ||
| "" if config["thresh_file"] in ("", None) else f"--config {config['thresh_file']}" | ||
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the newer versions of Snakemake were converting the empty string in the config dictionary into None, so this change just accounts for both.
| outfile = Path(outfile) | ||
| # Snakemake f-strings break with Python 3.12: https://github.com/snakemake/snakemake/issues/2648 | ||
| linkfile = "{}/R{}-fastqc.html".format(params.outdir, end) | ||
| linkfile = f"{params.outdir}/R{end}-fastqc.html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another reinstated f-string.
| mhrefr=str(Path(args.markerrefr).resolve()), | ||
| mhdefn=str(Path(args.markerdefn).resolve()), | ||
| hg38path=str(Path(args.hg38).resolve()), | ||
| hg38index=str(Path(args.hg38idx).resolve()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing paths here also caused an issue with newer versions of Snakemake where they didn't with version 7. 🤷♂️
This PR implements support for Snakemake version 8.