Skip to content
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

Improve validation of Auspice JSONs #621

Merged
merged 3 commits into from
Oct 21, 2020
Merged

Improve validation of Auspice JSONs #621

merged 3 commits into from
Oct 21, 2020

Conversation

jameshadfield
Copy link
Member

This improves augur validate export-v2 in two important ways:

(1) Stops validation failing on trees with (internal) nodes with a single child. Such trees are allowed - in fact we use this ability for our nCoV trees to encode travel history!
(2) Trees with identical node names cause Auspice to crash, however they currently pass validation without any warnings. They now result in an error message such as:

$ augur validate export-v2 X.json
Validating schema of 'X.json'...
Validating that the JSON is internally consistent...
FATAL ERROR: Node T38080 appears multiple times in the tree.

cc @batson

Auspice has no problem rendering (internal) nodes with a single
child (we use this in our SARS-CoV-2 build to encode travel
history). This updates the schema so that such builds pass.
Auspice (v2) JSONs are not allowed to have duplicate names (it causes
Auspice to crash). This modifies the vlidate functionality so that it
identifies this (previously there was no warning).
@codecov
Copy link

codecov bot commented Oct 15, 2020

Codecov Report

Merging #621 into master will increase coverage by 0.26%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #621      +/-   ##
==========================================
+ Coverage   28.37%   28.64%   +0.26%     
==========================================
  Files          39       39              
  Lines        5332     5342      +10     
  Branches     1306     1309       +3     
==========================================
+ Hits         1513     1530      +17     
+ Misses       3766     3756      -10     
- Partials       53       56       +3     
Impacted Files Coverage Δ
augur/validate_export.py 9.27% <90.00%> (+4.38%) ⬆️
augur/export_v2.py 11.22% <0.00%> (+1.40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efcc8be...1cd2177. Read the comment docs.

Adds minimal tests for validation of no duplicate names. Instead of
mocking up the tree JSON directly, these tests build a minimal BioPython
tree and use augur's own tree-to-JSON function to make the more verbose
JSON structure expected by the validation function.
Copy link
Contributor

@huddlej huddlej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I added unit tests for the new validation function and learned a bit about the validation code in the process. :)

@huddlej huddlej merged commit e209103 into master Oct 21, 2020
@huddlej huddlej deleted the improve-validate branch October 21, 2020 22:59
@huddlej huddlej added this to the Feature release 10.1.0 milestone Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants