Skip to content

Commit

Permalink
Update get_view_config_builder to use get_assaytype instead of `g…
Browse files Browse the repository at this point in the history
…et_assay`
  • Loading branch information
NickAkhmetov committed Dec 12, 2023
1 parent ac8e4c3 commit 17ce62c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/portal_visualization/assays.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
SCATAC_SEQ_SCI = "sc_atac_seq_sci"
SCATAC_SEQ_SNARE = "sc_atac_seq_snare"
SCATAC_SEQ_SN = "sn_atac_seq"
SALMON_RNASSEQ_SLIDE = "salmon_rnaseq_slideseq"
39 changes: 27 additions & 12 deletions src/portal_visualization/builder_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,33 @@
from .assays import (
SEQFISH,
MALDI_IMS,
NANODESI
NANODESI,
SALMON_RNASSEQ_SLIDE
)

# get_assaytype response example:
# {
# "assaytype": "image_pyramid",
# "description": "Image Pyramid",
# "vitessce_hints": [
# "is_image",
# "pyramid"
# ]
# }

def get_view_config_builder(entity, get_assay):
data_types = entity["data_types"]
assay_objs = [get_assay(dt) for dt in data_types]
assay_names = [assay.name for assay in assay_objs]
hints = [hint for assay in assay_objs for hint in assay.vitessce_hints]

def get_ancestor_assaytypes(entity, get_assaytype):
return [get_assaytype(ancestor.get('uuid')).get('assaytype') for ancestor in entity['immediate_ancestors']]


def get_view_config_builder(entity, get_assaytype):
assay = get_assaytype(entity.get('uuid'))
assay_name = assay.get('assaytype')
hints = assay.get('vitessce_hints', [])
dag_provenance_list = entity.get('metadata', {}).get('dag_provenance_list', [])
dag_names = [dag['name']
for dag in dag_provenance_list if 'name' in dag]
print(entity.get('uuid'), assay_name)
if "is_image" in hints:
if 'sprm' in hints and 'anndata' in hints:
return MultiImageSPRMAnndataViewConfBuilder
Expand All @@ -40,17 +55,17 @@ def get_view_config_builder(entity, get_assay):
# Both SeqFISH and IMS were submitted very early on, before the
# special image pyramid datasets existed. Their assay names should be in
# the `entity["data_types"]` while newer ones, like NanoDESI, are in the parents
if SEQFISH in assay_names:
if assay_name == SEQFISH:
return SeqFISHViewConfBuilder
if MALDI_IMS in assay_names:
if assay_name == MALDI_IMS:
return IMSViewConfBuilder
if NANODESI in [dt for e in entity["immediate_ancestors"] for dt in e["data_types"]]:
if NANODESI in [assaytype for assaytype in get_ancestor_assaytypes(entity, get_assaytype)]:
return NanoDESIViewConfBuilder
return ImagePyramidViewConfBuilder
if "rna" in hints:
# This is the zarr-backed anndata pipeline.
if "anndata-to-ui.cwl" in dag_names:
if "salmon_rnaseq_slideseq" in data_types:
if assay_name == SALMON_RNASSEQ_SLIDE:
return SpatialRNASeqAnnDataZarrViewConfBuilder
return RNASeqAnnDataZarrViewConfBuilder
return RNASeqViewConfBuilder
Expand All @@ -59,6 +74,6 @@ def get_view_config_builder(entity, get_assay):
return NullViewConfBuilder


def has_visualization(entity, get_assay):
builder = get_view_config_builder(entity, get_assay)
def has_visualization(entity, get_assaytype):
builder = get_view_config_builder(entity, get_assaytype)
return builder != NullViewConfBuilder

0 comments on commit 17ce62c

Please sign in to comment.