-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up Cram tests, fix fetch-from-ncbi-virus
#17
Conversation
d6cb670
to
7e56655
Compare
We definitely don't need "the system bash", which is what /bin/bash is. We want "the bash the user wants", which will often be the system bash, but not always. The main motivation is that /bin/bash on macOS is stuck on an ancient version due to licensing issues, and users might prefer another Bash in their environments.
7e56655
to
34089c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the Cram tests!
$ $TESTDIR/../../fetch-from-ncbi-virus 12637 nextstrain/ingest \ | ||
> --filters 'CreateDate_dt:([1987-11-29T00:00:00Z TO 1987-11-29T00:00:01Z])' \ | ||
> --fields 'viruslineage_ids:VirusLineageId_ss' | ||
{"genbank_accession":"X05375","genbank_accession_rev":"X05375.1","database":"GenBank","strain":"","region":"","location":"","collected":"","submitted":"1987-11-29T00:00:00Z","updated":"2016-07-26T00:00:00Z","length":"360","host":"","isolation_source":"","bioproject_accession":"","biosample_accession":"","sra_accession":"","title":"Dengue virus type 2 genomic RNA for envelope protein E N-term","authors":"Biedrzycka,A., Cauchi,M.R., Bartholomeusz,A., Gorman,J.J., Wright,P.J.","submitting_organization":"","publications":"2952760","sequence":"GTAACTTATGGGACGTGTACCACCACAGGAGAACACAGAAGAGAAAAAAGATCAGTGGCACTCGTTCCACATGTGGGAATGGGACTGGAGACACGAACTGAAACATGGATGTCATCAGAAGGGGCCTGGAAACATGCCCAGAGAATTGAAACTTGGATCTTGAGACATCCAGGCTTTACCATAATGGCAGCAATCCTGGCATACACCATAGGAACGACACATTTCCAAAGAGCCCTGATTTTCATCTTACTGACAGCTGTCGCTCCTTCAATGACAATGCGTTGCATAGGAATATCAAATAGAGACTTTGTAGAAGGGGTTTCAGGAGGAAGCTGGGTTGACATAGTCTTAGAACATGGA","viruslineage_ids":"10239,2559587,2732396,2732406,2732462,2732545,11050,11051,12637,11060"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how we can guard against these values changing in the future, but hopefully that won't happen any time soon since this was last updated in 2016!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like jq
to check only a few JSON keys would be ideal, but I don't want to add another dev dependency right now.
34089c4
to
993f3ab
Compare
Simplify the bash script by directly passing these options to the script that uses them. This requires changing the order so that required arguments are specified before options. This also removes reliance on the Bash ≥4 feature that allows unset arrays to be accessed by [@] with -u.
993f3ab
to
966ebcf
Compare
@victorlin noted in review that the previous construct threw an "unbound variable" error on macOS's system Bash 3.2.57.¹ This is because after 3.2.57 and at least by 4.4.20 (but maybe earlier), Bash stopped treating the "@" and "*" parameters as unset under -u when empty.² Use an array slice³ (i.e. substring expansion, ${parameter:offset}, applied to an array) as a workaround. Note that testing if "docker_args" is empty, e.g. "${docker_args:+${docker_args[@]}}", won't work because it leaves us with an empty string argument when unset. ¹ <#857 (comment)> ² <nextstrain/ingest#17 (comment)> ³ <https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion>
Description of proposed changes
Currently there's a gap in testing the scripts in this repo. Maybe Cram can help (partially) fill that gap. At the least, I've provided an example showing how it can be useful for
fetch-from-ncbi-virus
.Related issue(s)
Fixing bugs surfaced by nextstrain/mpox#175
Checklist
If adding a script, add an entry for it in the README.fetch-from-ncbi-virus
to allow skipping--filter
and--field
on older Bash versions