Skip to content

Commit b403d83

Browse files
authored
Merge pull request #965 from hubmapconsortium/nickakhmetov/add-is-integrated
NickAkhmetov/Add `is_integrated` to portal index transformations
2 parents 20d282d + 0405df6 commit b403d83

File tree

3 files changed

+242
-127
lines changed

3 files changed

+242
-127
lines changed

src/hubmap_translation/addl_index_transformations/portal/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from yaml import safe_load as load_yaml
99
import jsonschema
1010

11+
from hubmap_translation.addl_index_transformations.portal.add_is_integrated import add_is_integrated
1112
from hubmap_translation.addl_index_transformations.portal.translate import (
1213
translate, TranslationException
1314
)
@@ -76,6 +77,7 @@ def transform(doc, transformation_resources, batch_id='unspecified'):
7677
return None
7778
sort_files(doc_copy)
7879
add_counts(doc_copy)
80+
add_is_integrated(doc_copy)
7981
add_partonomy(doc_copy, organ_map)
8082
reset_entity_type(doc_copy)
8183
if len(doc_copy['transformation_errors']) == 0:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from hubmap_translation.addl_index_transformations.portal.add_assay_details import (
2+
CreationAction,
3+
)
4+
5+
6+
# Determines whether to display the raw dataset-focused UI or the processed outline-focused UI
7+
# Must be run after add_counts transformation, since it relies on ancestor_counts
8+
def add_is_integrated(doc):
9+
# only datasets can be integrated
10+
if doc.get("entity_type") != "Dataset":
11+
return
12+
13+
# EPIC datasets are always considered integrated (including segmentation masks):
14+
# - they can be derived from multiple datasets
15+
# - they are always processed
16+
# - they always have visualization support
17+
# - they have their own list of contributors that may differ from the base dataset's contributors
18+
if doc.get("creation_action") == CreationAction.EPIC:
19+
doc["is_integrated"] = True
20+
return
21+
22+
# If a dataset is immediately descended from multiple datasets, it is considered integrated
23+
# This covers Snare-Seq2 experiments
24+
if doc.get("ancestor_counts"):
25+
if doc["ancestor_counts"].get("entity_type", {}).get("Dataset", 0) > 1:
26+
doc["is_integrated"] = True
27+
return
28+
29+
doc["is_integrated"] = False

0 commit comments

Comments
 (0)