Skip to content

Commit

Permalink
fixup: move hard-coded columns to a shared workflow variable or confi…
Browse files Browse the repository at this point in the history
…g params so they don't get out of sync between rules
  • Loading branch information
j23414 committed Apr 10, 2024
1 parent 213a11e commit d16edc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ingest/defaults/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ nextclade:
min_length: 1000 # E gene length is approximately 1400nt
min_seed_cover: 0.1
nextclade_field: 'nextclade_subtype'
gene: ['E','NS1']
gene: ['E','NS1']
input_nextclade_fields: "seqName,clade,alignmentStart,alignmentEnd,coverage,failedCdses"
output_nextclade_fields: "alignmentStart,alignmentEnd,genome_coverage,failedCdses"
9 changes: 6 additions & 3 deletions ingest/rules/nextclade.smk
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ rule concat_nextclade_subtype_results:
params:
id_field=config["curate"]["id_field"],
nextclade_field=config["nextclade"]["nextclade_field"],
input_nextclade_fields=config["nextclade"]["input_nextclade_fields"],
output_nextclade_fields=config["nextclade"]["output_nextclade_fields"],
shell:
"""
echo "{params.id_field},{params.nextclade_field},alignmentStart,alignmentEnd,genome_coverage,failedCdses" \
echo "{params.id_field},{params.nextclade_field},{params.output_nextclade_fields}" \
| tr ',' '\t' \
> {output.nextclade_subtypes}
tsv-select -H -f "seqName,clade,alignmentStart,alignmentEnd,coverage,failedCdses" {input.nextclade_results_files} \
tsv-select -H -f "{params.input_nextclade_fields}" {input.nextclade_results_files} \
| awk 'NR>1 {{print}}' \
>> {output.nextclade_subtypes}
"""
Expand All @@ -86,12 +88,13 @@ rule append_nextclade_columns:
params:
id_field=config["curate"]["id_field"],
nextclade_field=config["nextclade"]["nextclade_field"],
output_nextclade_fields=config["nextclade"]["output_nextclade_fields"],
shell:
"""
tsv-join -H \
--filter-file {input.nextclade_subtypes} \
--key-fields {params.id_field} \
--append-fields {params.nextclade_field},alignmentStart,alignmentEnd,genome_coverage,failedCdses \
--append-fields {params.nextclade_field},{params.output_nextclade_fields} \
--write-all ? \
{input.metadata} \
> {output.metadata_all}
Expand Down

0 comments on commit d16edc0

Please sign in to comment.