From 05a968dc3ab002ead08a2cc0d86300191e97f720 Mon Sep 17 00:00:00 2001 From: Richard Challis Date: Tue, 23 Mar 2021 12:17:55 +0000 Subject: [PATCH] include ancestral rank in aggregation source Fixes #51 --- src/genomehubs/lib/fill.py | 10 +++++++--- src/genomehubs/templates/taxon.json | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/genomehubs/lib/fill.py b/src/genomehubs/lib/fill.py index a25ed1aa..17b7c1b4 100644 --- a/src/genomehubs/lib/fill.py +++ b/src/genomehubs/lib/fill.py @@ -323,10 +323,14 @@ def track_missing_attribute_values( for child_id, obj in missing_attributes[node["_source"]["taxon_id"]].items(): for key, attribute in attr_dict.items(): if key in obj["keys"]: - # update aggregation source here - # TODO: #51 include ancestral rank in aggregation source + # update aggregation source to include ancestral rank obj["attributes"].append( - {**attribute, "aggregation_source": "ancestor"} + { + **attribute, + "aggregation_source": "ancestor", + "aggregation_rank": node["_source"]["taxon_rank"], + "aggregation_taxon_id": node["_source"]["taxon_id"], + } ) obj["keys"].remove(key) if obj["keys"]: diff --git a/src/genomehubs/templates/taxon.json b/src/genomehubs/templates/taxon.json index 103d5a9d..27f28cf5 100644 --- a/src/genomehubs/templates/taxon.json +++ b/src/genomehubs/templates/taxon.json @@ -280,6 +280,22 @@ "description": "Summary source (direct, ancestor, descendant)" } }, + "aggregation_rank": { + "type": "keyword", + "ignore_above": 16, + "normalizer": "lowercase", + "meta": { + "description": "Source rank for ancestor derived values" + } + }, + "aggregation_taxon_id": { + "type": "keyword", + "ignore_above": 16, + "normalizer": "lowercase", + "meta": { + "description": "Source taxon_id for ancestor derived values" + } + }, "comment": { "type": "text", "index": false