Skip to content

Commit

Permalink
phylo: update rule inputs to literal paths
Browse files Browse the repository at this point in the history
Follow the Nextstrain Snakemake style guide¹ to use literal path strings
as inputs for the core workflow rules.

This will make it possible for users to override the default workflow
with `custom_rules`.

¹ https://docs.nextstrain.org/en/latest/reference/snakemake-style-guide.html#define-input-paths-with-literal-path-strings
  • Loading branch information
joverlee521 committed Feb 14, 2024
1 parent bc1c957 commit 38441eb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions phylogenetic/rules/annotate_phylogeny.smk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rule ancestral:
Reconstructing ancestral sequences and mutations
"""
input:
tree=rules.refine.output.tree,
tree=build_dir + "/{build_name}/tree.nwk",
alignment=build_dir + "/{build_name}/masked.fasta",
output:
node_data=build_dir + "/{build_name}/nt_muts.json",
Expand All @@ -46,8 +46,8 @@ rule translate:
Translating amino acid sequences
"""
input:
tree=rules.refine.output.tree,
node_data=rules.ancestral.output.node_data,
tree=build_dir + "/{build_name}/tree.nwk",
node_data=build_dir + "/{build_name}/nt_muts.json",
genemap=config["genemap"],
output:
node_data=build_dir + "/{build_name}/aa_muts.json",
Expand All @@ -67,7 +67,7 @@ rule traits:
- increase uncertainty of reconstruction by {params.sampling_bias_correction} to partially account for sampling bias
"""
input:
tree=rules.refine.output.tree,
tree=build_dir + "/{build_name}/tree.nwk",
metadata=build_dir + "/{build_name}/metadata.tsv",
output:
node_data=build_dir + "/{build_name}/traits.json",
Expand All @@ -93,9 +93,9 @@ rule clades:
Adding internal clade labels
"""
input:
tree=rules.refine.output.tree,
aa_muts=rules.translate.output.node_data,
nuc_muts=rules.ancestral.output.node_data,
tree=build_dir + "/{build_name}/tree.nwk",
aa_muts=build_dir + "/{build_name}/aa_muts.json",
nuc_muts=build_dir + "/{build_name}/nt_muts.json",
clades=config["clades"],
output:
node_data=build_dir + "/{build_name}/clades_raw.json",
Expand All @@ -113,7 +113,7 @@ rule clades:

rule rename_clades:
input:
rules.clades.output.node_data,
build_dir + "/{build_name}/clades_raw.json",
output:
node_data=build_dir + "/{build_name}/clades.json",
shell:
Expand All @@ -126,7 +126,7 @@ rule rename_clades:

rule mutation_context:
input:
tree=rules.refine.output.tree,
tree=build_dir + "/{build_name}/tree.nwk",
node_data=build_dir + "/{build_name}/nt_muts.json",
output:
node_data=build_dir + "/{build_name}/mutation_context.json",
Expand Down
6 changes: 3 additions & 3 deletions phylogenetic/rules/construct_phylogeny.smk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ rule fix_tree:
Fixing tree
"""
input:
tree=rules.tree.output.tree,
tree=build_dir + "/{build_name}/tree_raw.nwk",
alignment=build_dir + "/{build_name}/masked.fasta",
output:
tree=build_dir + "/{build_name}/tree_fixed.nwk",
Expand All @@ -66,9 +66,9 @@ rule refine:
- filter tips more than {params.clock_filter_iqd} IQDs from clock expectation
"""
input:
tree=rules.fix_tree.output.tree
tree=build_dir + "/{build_name}/tree_fixed.nwk"
if config["fix_tree"]
else rules.tree.output.tree,
else build_dir + "/{build_name}/tree_raw.nwk",
alignment=build_dir + "/{build_name}/masked.fasta",
metadata=build_dir + "/{build_name}/metadata.tsv",
output:
Expand Down
14 changes: 7 additions & 7 deletions phylogenetic/rules/export.smk
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ rule export:
Exporting data files for auspice
"""
input:
tree=rules.refine.output.tree,
tree=build_dir + "/{build_name}/tree.nwk",
metadata=build_dir + "/{build_name}/metadata.tsv",
branch_lengths="results/{build_name}/branch_lengths.json"
if config.get("timetree", False)
else "results/{build_name}/branch_lengths_no_time.json",
traits=rules.traits.output.node_data,
nt_muts=rules.ancestral.output.node_data,
aa_muts=rules.translate.output.node_data,
traits=build_dir + "/{build_name}/traits.json",
nt_muts=build_dir + "/{build_name}/nt_muts.json",
aa_muts=build_dir + "/{build_name}/aa_muts.json",
clades=build_dir + "/{build_name}/clades.json",
mutation_context=rules.mutation_context.output.node_data,
recency=rules.recency.output.node_data if config.get("recency", False) else [],
colors=rules.colors.output.colors,
mutation_context=build_dir + "/{build_name}/mutation_context.json",
recency=build_dir + "/{build_name}/recency.json" if config.get("recency", False) else [],
colors=build_dir + "/{build_name}/colors.tsv",
lat_longs=config["lat_longs"],
description=config["description"],
auspice_config=config["auspice_config"],
Expand Down
8 changes: 4 additions & 4 deletions phylogenetic/rules/prepare_sequences.smk
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ rule filter:

rule subsample:
input:
metadata=rules.filter.output.metadata,
metadata=build_dir + "/{build_name}/good_metadata.tsv",
output:
strains=build_dir + "/{build_name}/{sample}_strains.txt",
log=build_dir + "/{build_name}/{sample}_filter.log",
Expand Down Expand Up @@ -117,8 +117,8 @@ rule combine_samples:
f"{build_dir}/{w.build_name}/{sample}_strains.txt"
for sample in config["subsample"]
],
sequences=rules.filter.output.sequences,
metadata=rules.filter.output.metadata,
sequences=build_dir + "/{build_name}/good_sequences.fasta",
metadata=build_dir + "/{build_name}/good_metadata.tsv",
include=config["include"],
output:
sequences=build_dir + "/{build_name}/filtered.fasta",
Expand Down Expand Up @@ -159,7 +159,7 @@ rule align:
- filling gaps with N
"""
input:
sequences=rules.reverse_reverse_complements.output,
sequences=build_dir + "/{build_name}/reversed.fasta",
reference=config["reference"],
genemap=config["genemap"],
output:
Expand Down

0 comments on commit 38441eb

Please sign in to comment.