Skip to content

Commit

Permalink
fetch-from-ncbi-virus: Add github_repo argument
Browse files Browse the repository at this point in the history
Add github_repo argument to allow customization of the User-Agent
request header.

Following the pattern of other scripts in this repo that requires the
repo owner and name.
  • Loading branch information
joverlee521 committed Aug 24, 2023
1 parent c5ad366 commit aee5613
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fetch-from-ncbi-virus
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# usage: fetch-from-ncbi-virus [options] <ncbi_taxon_id>
# usage: fetch-from-ncbi-virus [options] <ncbi_taxon_id> <github_repo>
#
# Fetch metadata and nucleotide sequences from [NCBI Virus](https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/)
# and output NDJSON records to stdout.
Expand Down Expand Up @@ -38,16 +38,18 @@ main() {
done

local ncbi_taxon_id="${1:?NCBI taxon id is required.}"
local github_repo="${2:?A GitHub repository with owner and repository name is required as the second argument}"

local ncbi_virus_url
ncbi_virus_url="$("$bin"/ncbi-virus-url --ncbi-taxon-id "$ncbi_taxon_id" --filters "${filters[@]}" --fields "${fields[@]}")"

fetch "$ncbi_virus_url" | "$bin"/csv-to-ndjson
fetch "$ncbi_virus_url" "$github_repo" | "$bin"/csv-to-ndjson
}

fetch() {
curl "$1" \
--fail --silent --show-error --http1.1 \
--header 'User-Agent: https://github.com/nextstrain/monkeypox ([email protected])'
--header "User-Agent: https://github.com/$2 ([email protected])"
}

main "$@"

0 comments on commit aee5613

Please sign in to comment.