diff --git a/cli/server/convertJsonSchemas.js b/cli/server/convertJsonSchemas.js index ccd8ec32d..3941196cb 100644 --- a/cli/server/convertJsonSchemas.js +++ b/cli/server/convertJsonSchemas.js @@ -88,8 +88,6 @@ const setAuthorInfo = (v2, meta, tree) => { const setMiscMetaProperties = (v2, meta) => { // TITLE (required) v2.title = meta.title; - // VERSION (not required) - v2.version = "2.0-alpha.0"; // UPDATED (required) v2.updated = meta.updated; if (!v2.updated) { @@ -271,14 +269,17 @@ const storeTreeAsV2 = (v2, tree) => { const convertFromV1 = ({tree, meta, treeName}) => { - const v2 = {}; - setColorings(v2, meta); - setMiscMetaProperties(v2, meta); - setAuthorInfo(v2, meta, tree); + const v2 = { + "version": "2.0", + "meta": {} + }; + setColorings(v2["meta"], meta); + setMiscMetaProperties(v2["meta"], meta); + setAuthorInfo(v2["meta"], meta, tree); setVaccineChoicesOnNodes(meta, tree); storeTreeAsV2(v2, tree); if (treeName) { - v2.tree_name = treeName; + v2["meta"].tree_name = treeName; } return v2; }; diff --git a/examples/minimal.json b/examples/minimal.json index 5669c26b3..0e754452e 100644 --- a/examples/minimal.json +++ b/examples/minimal.json @@ -1,120 +1,122 @@ { - "title": "Minimal (v2) auspice spec based on Zika pipeline", - "updated": "02 Apr 2019", "version": "2.0", - "maintainers": [ - { - "url": "http://bedford.io/team/trevor-bedford/", - "name": "Trevor Bedford" - } - ], - "panels": [ - "tree", - "map" - ], - "filters": [ - "country", - "region" - ], - "display_defaults": { - "color_by": "country" - }, - "geographic_info": { - "country": { - "american_samoa": { - "latitude": -14.27806, - "longitude": -170.7025 - }, - "brazil": { - "latitude": -10.3333332, - "longitude": -53.1999999 - }, - "honduras": { - "latitude": 15.0610686, - "longitude": -84.5978533 - }, - "dominican_republic": { - "latitude": 18.50012, - "longitude": -69.98857 - }, - "usa": { - "latitude": 39.7837304, - "longitude": -100.4458824 - }, - "singapore": { - "latitude": 1.2904527, - "longitude": 103.852038 - }, - "venezuela": { - "latitude": 8, - "longitude": -66 - }, - "panama": { - "latitude": 8.3096067, - "longitude": -81.3066245 - }, - "puerto_rico": { - "latitude": 18.2459121, - "longitude": -66.4164147 - }, - "guatemala": { - "latitude": 15.6356088, - "longitude": -89.8988086 - }, - "colombia": { - "latitude": 2.893108, - "longitude": -73.7845142 - }, - "french_polynesia": { - "latitude": -17.6797, - "longitude": -149.4068 - }, - "thailand": { - "latitude": 14.8971921, - "longitude": 100.83273 - }, - "nicaragua": { - "latitude": 13, - "longitude": -85 - }, - "ecuador": { - "latitude": -1.3397667, - "longitude": -79.3666964 + "meta":{ + "title": "Minimal (v2) auspice spec based on Zika pipeline", + "updated": "02 Apr 2019", + "maintainers": [ + { + "url": "http://bedford.io/team/trevor-bedford/", + "name": "Trevor Bedford" } + ], + "panels": [ + "tree", + "map" + ], + "filters": [ + "country", + "region" + ], + "display_defaults": { + "color_by": "country" }, - "region": { - "southeast_asia": { - "latitude": 3.020567, - "longitude": 112.390683 + "geographic_info": { + "country": { + "american_samoa": { + "latitude": -14.27806, + "longitude": -170.7025 + }, + "brazil": { + "latitude": -10.3333332, + "longitude": -53.1999999 + }, + "honduras": { + "latitude": 15.0610686, + "longitude": -84.5978533 + }, + "dominican_republic": { + "latitude": 18.50012, + "longitude": -69.98857 + }, + "usa": { + "latitude": 39.7837304, + "longitude": -100.4458824 + }, + "singapore": { + "latitude": 1.2904527, + "longitude": 103.852038 + }, + "venezuela": { + "latitude": 8, + "longitude": -66 + }, + "panama": { + "latitude": 8.3096067, + "longitude": -81.3066245 + }, + "puerto_rico": { + "latitude": 18.2459121, + "longitude": -66.4164147 + }, + "guatemala": { + "latitude": 15.6356088, + "longitude": -89.8988086 + }, + "colombia": { + "latitude": 2.893108, + "longitude": -73.7845142 + }, + "french_polynesia": { + "latitude": -17.6797, + "longitude": -149.4068 + }, + "thailand": { + "latitude": 14.8971921, + "longitude": 100.83273 + }, + "nicaragua": { + "latitude": 13, + "longitude": -85 + }, + "ecuador": { + "latitude": -1.3397667, + "longitude": -79.3666964 + } }, - "oceania": { - "latitude": -25.0562891, - "longitude": 152.008576 + "region": { + "southeast_asia": { + "latitude": 3.020567, + "longitude": 112.390683 + }, + "oceania": { + "latitude": -25.0562891, + "longitude": 152.008576 + }, + "north_america": { + "latitude": 28.2367447, + "longitude": -97.738017 + }, + "south_america": { + "latitude": -13.083583, + "longitude": -58.470721 + } + } + }, + "colorings": { + "country": { + "type": "categorical", + "title": "country" }, - "north_america": { - "latitude": 28.2367447, - "longitude": -97.738017 + "region": { + "type": "categorical", + "title": "region" }, - "south_america": { - "latitude": -13.083583, - "longitude": -58.470721 + "num_date": { + "type": "continuous", + "title": "Sampling date" } } }, - "colorings": { - "country": { - "type": "categorical", - "title": "country" - }, - "region": { - "type": "categorical", - "title": "region" - }, - "num_date": { - "type": "continuous", - "title": "Sampling date" - } - }, "tree": { "name": "NODE_0000031", "div": 0, diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index 8352f22d5..7bd7b9cce 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -489,29 +489,29 @@ const modifyControlsViaTreeToo = (controls, name) => { }; /** - * TODO -- this will change with https://github.com/nextstrain/auspice/issues/755 + * * A lot of this is simply changing augur's snake_case to auspice's camelCase */ const createMetadataStateFromJSON = (json) => { const metadata = {}; - if (json.colorings) { - metadata.colorings = json.colorings; + if (json.meta.colorings) { + metadata.colorings = json.meta.colorings; } - metadata.title = json.title; - metadata.updated = json.updated; + metadata.title = json.meta.title; + metadata.updated = json.meta.updated; if (json.version) { metadata.version = json.version; } - if (json.genome_annotations) { - metadata.genomeAnnotations = json.genome_annotations; + if (json.meta.genome_annotations) { + metadata.genomeAnnotations = json.meta.genome_annotations; } - if (json.filters) { - metadata.filters = json.filters; + if (json.meta.filters) { + metadata.filters = json.meta.filters; } - if (json.panels) { - metadata.panels = json.panels; + if (json.meta.panels) { + metadata.panels = json.meta.panels; } - if (json.display_defaults) { + if (json.meta.display_defaults) { metadata.displayDefaults = {}; const jsonKeyToAuspiceKey = { color_by: "colorBy", @@ -521,13 +521,13 @@ const createMetadataStateFromJSON = (json) => { layout: "layout" }; for (const [jsonKey, auspiceKey] of Object.entries(jsonKeyToAuspiceKey)) { - if (json.display_defaults[jsonKey]) { - metadata.displayDefaults[auspiceKey] = json.display_defaults[jsonKey]; + if (json.meta.display_defaults[jsonKey]) { + metadata.displayDefaults[auspiceKey] = json.meta.display_defaults[jsonKey]; } } } - if (json.geographic_info) { - metadata.geographicInfo = json.geographic_info; + if (json.meta.geographic_info) { + metadata.geographicInfo = json.meta.geographic_info; }