-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fetch-from-ncbi-virus: Add github_repo argument
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
1 parent
c5ad366
commit aee5613
Showing
1 changed file
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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 "$@" |