Skip to content

Conversation

@standage
Copy link
Member

@standage standage commented May 1, 2025

This PR implements support for Snakemake version 8.


Comment on lines +55 to +67
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)
Copy link
Member Author

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.

Comment on lines -273 to +275
"analysis/{}/03typing/callplots".format(wildcards.sample),
f"analysis/{wildcards.sample}/03typing/callplots",
Copy link
Member Author

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.

Comment on lines -214 to +216
threshfile="" if config["thresh_file"] == "" else f"--config {config['thresh_file']}",
threshfile=(
"" if config["thresh_file"] in ("", None) else f"--config {config['thresh_file']}"
),
Copy link
Member Author

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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another reinstated f-string.

Comment on lines +34 to +37
mhrefr=str(Path(args.markerrefr).resolve()),
mhdefn=str(Path(args.markerdefn).resolve()),
hg38path=str(Path(args.hg38).resolve()),
hg38index=str(Path(args.hg38idx).resolve()),
Copy link
Member Author

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. 🤷‍♂️

@standage standage merged commit ee77753 into main May 1, 2025
3 checks passed
@standage standage deleted the smk branch May 1, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants