Skip to content

Commit

Permalink
[export, num_date] use inferred / raw_date attrs
Browse files Browse the repository at this point in the history
These provide two important pieces of information for Auspice:

1. A way to unambiguously know if a tip date was inferred or not.
2. When a tip date was inferred we can now display the raw (ambiguous)
   date string.

Note that the new output would validate on the old schema as additional
properties are allowed (by default).
  • Loading branch information
jameshadfield committed Feb 18, 2025
1 parent 8bda439 commit bf1c02d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions augur/data/schema-export-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@
{"type": "number"},
{"type": "number"}
]
},
"inferred": {
"type": "boolean",
"description": "[terminal nodes only] was the 'value' inferred or known?"
},
"raw_value": {
"type": "string",
"description": "[terminal nodes only, and only if inferred=true] the known (ambiguous) date string"
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions augur/export_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,13 @@ def _transfer_num_date(node, raw_data):
if is_valid(raw_data.get("num_date", None)): # it's ok not to have temporal information
node["node_attrs"]["num_date"] = {"value": format_number(raw_data["num_date"])}
node["node_attrs"]["num_date"].update(attr_confidence(node["name"], raw_data, "num_date"))
# For tips, transfer information about whether the date was inferred or known
# and if it was inferred then store the underlying (ambiguous) date string
if len(node.get('children', []))==0 and 'date_inferred' in raw_data:
node["node_attrs"]["num_date"]["inferred"] = raw_data['date_inferred']
if raw_data['date_inferred'] and raw_data.get('raw_date', False):
node["node_attrs"]["num_date"]["raw_value"] = raw_data['raw_date']


def _transfer_url_accession(node, raw_data):
for prop in ["url", "accession"]:
Expand Down Expand Up @@ -918,6 +925,7 @@ def node_data_prop_is_normal_trait(name):
'clock_length',
'mutation_length',
'date',
'date_inferred',
'muts',
'aa_muts',
'sequence',
Expand Down

0 comments on commit bf1c02d

Please sign in to comment.