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

Top level meta #769

Merged
merged 3 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions cli/server/convertJsonSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
};
Expand Down
216 changes: 109 additions & 107 deletions examples/minimal.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
32 changes: 16 additions & 16 deletions src/actions/recomputeReduxState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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;
}


Expand Down