Created
March 28, 2025 19:51
-
-
Save tsibley/9556377ba6f38f16eaed13a19335470a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rules/config.smk | 22 ---------------------- | |
rules/genome.smk | 11 +++-------- | |
rules/main.smk | 11 +++-------- | |
3 files changed, 6 insertions(+), 38 deletions(-) | |
diff --git a/rules/config.smk b/rules/config.smk | |
index 38cc55e..89ea2dd 100644 | |
--- a/rules/config.smk | |
+++ b/rules/config.smk | |
@@ -179,28 +179,6 @@ def resolve_config_path(*fields): | |
return resolve | |
-def script(path): | |
- """ | |
- Resolve a provided script *path* (string) | |
- | |
- Search order (first match returned): | |
- 1. Relative to the 'scripts' directory in the avian-flu repo (`AVIAN_FLU_DIR`) | |
- 2. Relative to the avian-flu repo (`AVIAN_FLU_DIR`) | |
- | |
- An `InvalidConfigError` is raised if a match is not found | |
- """ | |
- | |
- if os.path.exists(p:=os.path.join(AVIAN_FLU_DIR, "scripts", path)): | |
- return p | |
- | |
- if os.path.exists(p:=os.path.join(AVIAN_FLU_DIR, path)): | |
- return p | |
- | |
- raise InvalidConfigError(f"Unable to resolve the provided script {path!r}. " | |
- f"The following directories were searched:\n" | |
- f"\t1. {os.path.join(AVIAN_FLU_DIR, 'scripts')}\n" | |
- f"\t2. {AVIAN_FLU_DIR}\n") | |
- | |
def as_list(x): | |
return x if isinstance(x, list) else [x] | |
diff --git a/rules/genome.smk b/rules/genome.smk | |
index 62d64c3..e8bb427 100644 | |
--- a/rules/genome.smk | |
+++ b/rules/genome.smk | |
@@ -66,11 +66,9 @@ rule join_segments: | |
subtype = 'h5n1-cattle-outbreak|h5n1-d1.1', | |
segment = 'genome', | |
time = 'default', | |
- params: | |
- script = script("join-segments.py"), | |
shell: | |
r""" | |
- python {params.script} \ | |
+ python {workflow.current_basedir}/../scripts/join-segments.py \ | |
--segments {input.alignment} \ | |
--output {output.alignment} | |
""" | |
@@ -82,14 +80,13 @@ rule mask_genome: | |
alignment = "results/{subtype}/{segment}/{time}/aligned.fasta", | |
params: | |
percentage = resolve_config_value('mask', 'min_support'), | |
- script = script("mask.py"), | |
wildcard_constraints: | |
subtype = 'h5n1-cattle-outbreak|h5n1-d1.1', | |
segment = 'genome', | |
time = 'default', | |
shell: | |
r""" | |
- python {params.script} \ | |
+ python {workflow.current_basedir}/../scripts/mask.py \ | |
--alignment {input.alignment} \ | |
--percentage {params.percentage} \ | |
--output {output.alignment} | |
@@ -153,11 +150,9 @@ rule prune_tree: | |
wildcard_constraints: | |
subtype='h5n1-cattle-outbreak|h5n1-d1.1', | |
time="default", | |
- params: | |
- script = script("restrict-via-common-ancestor.py") | |
shell: | |
""" | |
- python3 {params.script} \ | |
+ python {workflow.current_basedir}/../scripts/restrict-via-common-ancestor.py \ | |
--tree {input.tree} \ | |
--strains {input.strains} \ | |
--output-tree {output.tree} \ | |
diff --git a/rules/main.smk b/rules/main.smk | |
index 5347e7e..183a6e5 100755 | |
--- a/rules/main.smk | |
+++ b/rules/main.smk | |
@@ -270,11 +270,9 @@ rule add_h5_clade: | |
clades_file = resolve_config_path('clades_file') | |
output: | |
metadata= "results/{subtype}/metadata-with-clade.tsv" | |
- params: | |
- script = script("clade-labeling/add-clades.py") | |
shell: | |
r""" | |
- python {params.script} \ | |
+ python {workflow.current_basedir}/../clade-labeling/add-clades.py \ | |
--metadata {input.metadata} \ | |
--output {output.metadata} \ | |
--clades {input.clades_file} | |
@@ -546,11 +544,9 @@ rule cleavage_site: | |
output: | |
cleavage_site_annotations = "results/{subtype}/ha/{time}/cleavage-site.json", | |
cleavage_site_sequences = "results/{subtype}/ha/{time}/cleavage-site-sequences.json" | |
- params: | |
- script = script("annotate-ha-cleavage-site.py") | |
shell: | |
r""" | |
- python {params.script} \ | |
+ python {workflow.current_basedir}/../scripts/annotate-ha-cleavage-site.py \ | |
--alignment {input.alignment} \ | |
--furin_site_motif {output.cleavage_site_annotations} \ | |
--cleavage_site_sequence {output.cleavage_site_sequences} | |
@@ -633,11 +629,10 @@ rule colors: | |
colors = "results/{subtype}/{segment}/{time}/colors.tsv", | |
params: | |
duplications = lambda w: ["=".join(pair) for pair in resolve_config_value('colors', 'duplications')(w)], | |
- script = script("assign-colors.py"), | |
shell: | |
r""" | |
cp {input.colors} {output.colors} && \ | |
- python3 {params.script} \ | |
+ python {workflow.current_basedir}/../scripts/assign-colors.py \ | |
--metadata {input.metadata} \ | |
--ordering {input.ordering} \ | |
--color-schemes {input.schemes} \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment