Skip to content

Commit

Permalink
Separate files into segment directories
Browse files Browse the repository at this point in the history
* Capitalize L and S to match ingest
* Refactor and place intermediate files in segment directories
* Match segment capitalization in reference files and example files
  • Loading branch information
j23414 committed Jul 30, 2024
1 parent 689800e commit f818c4b
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 43 deletions.
7 changes: 5 additions & 2 deletions phylogenetic/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ workdir: workflow.current_basedir
# Use default configuration values. Override with Snakemake's --configfile/--config options.
configfile: "defaults/config.yaml"

SEGMENTS = ["l", "s"]
segments = ["L", "S"]

wildcard_constraints:
segment = "|".join(segments)

rule all:
input:
auspice_tree = expand("auspice/lassa_{segment}.json", segment=SEGMENTS)
auspice_tree = expand("auspice/lassa_{segment}.json", segment=segments)

include: "rules/prepare_sequences.smk"
include: "rules/construct_phylogeny.smk"
Expand Down
4 changes: 2 additions & 2 deletions phylogenetic/build-configs/ci/copy_example_data.smk
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ rule copy_example_data:
sequences="example_data/sequences_{segment}.fasta",
metadata="example_data/metadata_{segment}.tsv",
output:
sequences="data/sequences_{segment}.fasta",
metadata="data/metadata_{segment}.tsv",
sequences="data/{segment}/sequences.fasta",
metadata="data/{segment}/metadata.tsv",
shell:
"""
cp -f {input.sequences} {output.sequences}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions phylogenetic/rules/annotate_phylogeny.smk
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ to the ones produced by Augur commands.
rule ancestral:
"""Reconstructing ancestral sequences and mutations"""
input:
tree = "results/tree_{segment}.nwk",
alignment = "results/aligned_{segment}.fasta",
tree = "results/{segment}/tree.nwk",
alignment = "results/{segment}/aligned.fasta",
output:
node_data = "results/nt_muts_{segment}.json"
node_data = "results/{segment}/nt_muts.json"
params:
inference = "joint"
shell:
Expand All @@ -52,11 +52,11 @@ rule ancestral:
rule translate:
"""Translating amino acid sequences"""
input:
tree = "results/tree_{segment}.nwk",
node_data = "results/nt_muts_{segment}.json",
tree = "results/{segment}/tree.nwk",
node_data = "results/{segment}/nt_muts.json",
reference = "defaults/lassa_{segment}.gb"
output:
node_data = "results/aa_muts_{segment}.json"
node_data = "results/{segment}/aa_muts.json"
shell:
"""
augur translate \
Expand All @@ -69,10 +69,10 @@ rule translate:
rule traits:
"""Inferring ancestral traits for {params.columns!s}"""
input:
tree = "results/tree_{segment}.nwk",
metadata = "data/metadata_{segment}.tsv",
tree = "results/{segment}/tree.nwk",
metadata = "data/{segment}/metadata.tsv",
output:
node_data = "results/traits_{segment}.json",
node_data = "results/{segment}/traits.json",
params:
strain_id_field = config["strain_id_field"],
columns = config['traits']['columns']
Expand Down
14 changes: 7 additions & 7 deletions phylogenetic/rules/construct_phylogeny.smk
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ See Augur's usage docs for these commands for more details.
rule tree:
"""Building tree"""
input:
alignment = "results/aligned_{segment}.fasta"
alignment = "results/{segment}/aligned.fasta"
output:
tree = "results/tree_raw_{segment}.nwk"
tree = "results/{segment}/tree_raw.nwk"
params:
method = "iqtree"
shell:
Expand All @@ -44,12 +44,12 @@ rule refine:
- fix clock rate at {params.clock_rate}
"""
input:
tree = "results/tree_raw_{segment}.nwk",
alignment = "results/aligned_{segment}.fasta",
metadata = "data/metadata_{segment}.tsv",
tree = "results/{segment}/tree_raw.nwk",
alignment = "results/{segment}/aligned.fasta",
metadata = "data/{segment}/metadata.tsv",
output:
tree = "results/tree_{segment}.nwk",
node_data = "results/branch_lengths_{segment}.json"
tree = "results/{segment}/tree.nwk",
node_data = "results/{segment}/branch_lengths.json"
params:
strain_id_field = config["strain_id_field"],
coalescent = config['refine']['coalescent'],
Expand Down
24 changes: 12 additions & 12 deletions phylogenetic/rules/export.smk
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ rule colors:
input:
color_schemes = "defaults/color_schemes.tsv",
color_orderings = "defaults/color_orderings.tsv",
metadata = "data/metadata_{segment}.tsv",
metadata = "data/{segment}/metadata.tsv",
output:
colors = "results/colors_{segment}.tsv"
colors = "results/{segment}/colors.tsv"
shell:
"""
python3 scripts/assign-colors.py \
Expand All @@ -44,17 +44,17 @@ rule colors:
rule export:
"""Exporting data files for for auspice"""
input:
tree = "results/tree_{segment}.nwk",
metadata = "data/metadata_{segment}.tsv",
branch_lengths = "results/branch_lengths_{segment}.json",
traits = "results/traits_{segment}.json",
nt_muts = "results/nt_muts_{segment}.json",
aa_muts = "results/aa_muts_{segment}.json",
colors = "results/colors_{segment}.tsv",
tree = "results/{segment}/tree.nwk",
metadata = "data/{segment}/metadata.tsv",
branch_lengths = "results/{segment}/branch_lengths.json",
traits = "results/{segment}/traits.json",
nt_muts = "results/{segment}/nt_muts.json",
aa_muts = "results/{segment}/aa_muts.json",
colors = "results/{segment}/colors.tsv",
description = config['export']['description'],
auspice_config = config['export']['auspice_config'],
output:
auspice = "results/lassa_{segment}.json",
auspice = "results/{segment}/lassa.json",
params:
strain_id_field = config["strain_id_field"],
shell:
Expand All @@ -73,8 +73,8 @@ rule export:

rule final_strain_name:
input:
auspice_json="results/lassa_{segment}.json",
metadata="data/metadata_{segment}.tsv",
auspice_json="results/{segment}/lassa.json",
metadata="data/{segment}/metadata.tsv",
output:
auspice_json="auspice/lassa_{segment}.json",
params:
Expand Down
22 changes: 11 additions & 11 deletions phylogenetic/rules/prepare_sequences.smk
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ See Augur's usage docs for these commands for more details.
rule download:
"""Downloading sequences and metadata from data.nextstrain.org"""
output:
sequences = "data/sequences_{segment}.fasta.zst",
metadata = "data/metadata_{segment}.tsv.zst"
sequences = "data/{segment}/sequences.fasta.zst",
metadata = "data/{segment}/metadata.tsv.zst"
params:
sequences_url = config["sequences_url"],
metadata_url = config["metadata_url"],
Expand All @@ -38,11 +38,11 @@ rule download:
rule decompress:
"""Decompressing sequences and metadata"""
input:
sequences = "data/sequences_{segment}.fasta.zst",
metadata = "data/metadata_{segment}.tsv.zst"
sequences = "data/{segment}/sequences.fasta.zst",
metadata = "data/{segment}/metadata.tsv.zst"
output:
sequences = "data/sequences_{segment}.fasta",
metadata = "data/metadata_{segment}.tsv"
sequences = "data/{segment}/sequences.fasta",
metadata = "data/{segment}/metadata.tsv"
shell:
"""
zstd -d -c {input.sequences} > {output.sequences}
Expand All @@ -56,11 +56,11 @@ rule filter:
- excluding strains in {input.exclude}
"""
input:
sequences = "data/sequences_{segment}.fasta",
metadata = "data/metadata_{segment}.tsv",
sequences = "data/{segment}/sequences.fasta",
metadata = "data/{segment}/metadata.tsv",
exclude = config['filter']['exclude']
output:
sequences = "results/filtered_{segment}.fasta"
sequences = "results/{segment}/filtered.fasta"
params:
strain_id_field = config["strain_id_field"],
group_by = config['filter']['group_by'],
Expand All @@ -83,10 +83,10 @@ rule align:
- filling gaps with N
"""
input:
sequences = "results/filtered_{segment}.fasta",
sequences = "results/{segment}/filtered.fasta",
reference = "defaults/lassa_{segment}.gb"
output:
alignment = "results/aligned_{segment}.fasta"
alignment = "results/{segment}/aligned.fasta"
shell:
"""
augur align \
Expand Down

0 comments on commit f818c4b

Please sign in to comment.