From 547b3bf7892cb7008c8b39ff067d9db6fd61a562 Mon Sep 17 00:00:00 2001 From: Tianhao-Gu Date: Mon, 16 Oct 2023 17:37:48 -0500 Subject: [PATCH] add cell details entry keys --- src/common/product_models/heatmap_common_models.py | 2 ++ src/loaders/compute_tools/microtrait/microtrait.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/product_models/heatmap_common_models.py b/src/common/product_models/heatmap_common_models.py index d4e03c58c..0ed83b4fd 100644 --- a/src/common/product_models/heatmap_common_models.py +++ b/src/common/product_models/heatmap_common_models.py @@ -25,6 +25,8 @@ FIELD_HEATMAP_CATEGORY = "category" FIELD_HEATMAP_COLUMNS = "columns" FIELD_HEATMAP_CATEGORIES = "categories" +FIELD_HEATMAP_CELL_DETAIL_ENTRY_VALUE = "val" +FIELD_HEATMAP_CELL_DETAIL_ENTRY_ID = "id" _FLD_CELL_ID = Field( diff --git a/src/loaders/compute_tools/microtrait/microtrait.py b/src/loaders/compute_tools/microtrait/microtrait.py index 1246ad638..57f81c021 100644 --- a/src/loaders/compute_tools/microtrait/microtrait.py +++ b/src/loaders/compute_tools/microtrait/microtrait.py @@ -19,7 +19,9 @@ FIELD_HEATMAP_DESCR, FIELD_HEATMAP_TYPE, FIELD_HEATMAP_CATEGORY, - ColumnType) + FIELD_HEATMAP_CELL_DETAIL_ENTRY_ID, + FIELD_HEATMAP_CELL_DETAIL_ENTRY_VALUE, + ColumnType,) from src.common.storage.field_names import FLD_KBASE_ID from src.loaders.common import loader_common_names from src.loaders.compute_tools.tool_common import ( @@ -237,8 +239,9 @@ def _run_microtrait(tool_safe_data_id: str, data_id: str, fna_file: Path, genome trait_counts_df[_DETECTED_GENE_SCORE_COL] = trait_counts_df[ loader_common_names.UNWRAPPED_GENE_COL].apply( - lambda x: [{gene: detected_genes_score.get(gene) for gene in str(x).split(';') if - gene in detected_genes_score}]) + lambda x: [{FIELD_HEATMAP_CELL_DETAIL_ENTRY_ID: gene, + FIELD_HEATMAP_CELL_DETAIL_ENTRY_VALUE: detected_genes_score.get(gene)} for gene in + str(x).split(';') if gene in detected_genes_score]) else: raise ValueError('Please set environment variable MT_TRAIT_UNWRAPPED_FILE')