Skip to content

Commit

Permalink
fix: use csvtk instead of wrangle script nextstrain/zika#25 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
j23414 committed Mar 25, 2023
1 parent 11b2ac2 commit 040c503
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,12 @@ rule wrangle_metadata:
output:
metadata="results/wrangled_metadata_{serotype}.tsv",
params:
strain_id=lambda w: config.get("strain_id_field", "strain"),
strain_id=lambda w: config.get("strain_id_field", "strain"), #accession
wrangle_metadata_url="https://raw.githubusercontent.com/nextstrain/monkeypox/644d07ebe3fa5ded64d27d0964064fb722797c5d/scripts/wrangle_metadata.py",
shell:
"""
# (1) Pick curl or wget based on availability
if which curl > /dev/null; then
download_cmd="curl -fsSL --output"
elif which wget > /dev/null; then
download_cmd="wget -O"
else
echo "ERROR: Neither curl nor wget found. Please install one of them."
exit 1
fi
# (2) Download the required scripts if not already present
[[ -d bin ]] || mkdir bin
[[ -f bin/wrangle_metadata.py ]] || $download_cmd bin/wrangle_metadata.py {params.wrangle_metadata_url}
chmod +x bin/*
# (3) Run the script
python3 ./bin/wrangle_metadata.py --metadata {input.metadata} \
--strain-id {params.strain_id} \
--output {output.metadata}
csvtk -t rename -f strain -n strain_original {input.metadata} \
| csvtk -t mutate -f {params.strain_id} -n strain > {output.metadata}
"""

rule filter:
Expand Down

0 comments on commit 040c503

Please sign in to comment.