Skip to content

Commit e52f17e

Browse files
committed
Carousel up to 5 example images for class/dataset rows
AlignedDatasets, AllDatasets, AnatomyExpressedIn (get_expression_overlaps_here) and TransgeneExpressionHere bound a single representative example image (LIMIT 1) into the Images cell, so each row showed only one thumbnail even when the class/dataset has many examples. These four queries aggregate one-to-many example individuals into a single row, so they now collect up to 5 example images and emit them as a ' | '-joined [![alt](url 'title')](ref) list -- the same carousel shape the V2 imageMarkdownToVariableJson splits into a SlideshowImageComponent. Per-individual queries (instances, templates, NBLAST similarity, connectivity partners, dataset image listings, terms-for-pub) are one-image-per-row by design and are left unchanged. Validated read-only against prod pdb: AlignedDatasets=5, medulla=4, EP=2.
1 parent 9dde31a commit e52f17e

1 file changed

Lines changed: 57 additions & 12 deletions

File tree

src/vfbquery/vfb_queries.py

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,9 +2882,22 @@ def get_expression_overlaps_here(expression_pattern_short_form: str, return_data
28822882
WITH anat
28832883
OPTIONAL MATCH (anat)<-[:has_source|SUBCLASSOF|INSTANCEOF*]-(i:Individual)<-[:depicts]-(channel:Individual)-[irw:in_register_with]->(template:Individual)-[:depicts]->(template_anat:Individual)
28842884
OPTIONAL MATCH (channel)-[:is_specified_output_of]->(technique:Class)
2885-
WITH i, template, template_anat, channel, technique, irw
2886-
LIMIT 1
2887-
RETURN i, template, template_anat, channel, technique, irw
2885+
WITH anat, i, template_anat, technique, irw
2886+
WHERE i IS NOT NULL
2887+
WITH anat, i, template_anat, technique, irw LIMIT 5
2888+
WITH anat, collect({{i: i, template_anat: template_anat, technique: technique, irw: irw}}) AS imgs
2889+
WITH anat, imgs, head(imgs) AS rep
2890+
RETURN
2891+
rep.template_anat AS template_anat,
2892+
rep.technique AS technique,
2893+
apoc.text.join([x IN imgs |
2894+
REPLACE(apoc.text.format("[![%s](%s '%s')](%s)",
2895+
[coalesce(x.i.label, 'image') + " aligned to " + CASE WHEN x.template_anat.symbol[0] <> '' THEN x.template_anat.symbol[0] ELSE x.template_anat.label END,
2896+
REPLACE(COALESCE(x.irw.thumbnail[0], ''), 'thumbnailT.png', 'thumbnail.png'),
2897+
coalesce(x.i.label, 'image') + " aligned to " + CASE WHEN x.template_anat.symbol[0] <> '' THEN x.template_anat.symbol[0] ELSE x.template_anat.label END,
2898+
x.template_anat.short_form + "," + coalesce(x.i.short_form, anat.short_form)]),
2899+
"[![null]( 'null')](null)", "")
2900+
], ' | ') AS thumbnail
28882901
}}
28892902
RETURN
28902903
anat.short_form AS id,
@@ -2894,7 +2907,7 @@ def get_expression_overlaps_here(expression_pattern_short_form: str, return_data
28942907
stages,
28952908
REPLACE(apoc.text.format("[%s](%s)", [CASE WHEN template_anat.symbol[0] <> '' THEN template_anat.symbol[0] ELSE template_anat.label END, template_anat.short_form]), '[null](null)', '') AS template,
28962909
coalesce(technique.label, '') AS technique,
2897-
REPLACE(apoc.text.format("[![%s](%s '%s')](%s)", [coalesce(i.label, 'image') + " aligned to " + CASE WHEN template_anat.symbol[0] <> '' THEN template_anat.symbol[0] ELSE template_anat.label END, REPLACE(COALESCE(irw.thumbnail[0], ''), 'thumbnailT.png', 'thumbnail.png'), coalesce(i.label, 'image') + " aligned to " + CASE WHEN template_anat.symbol[0] <> '' THEN template_anat.symbol[0] ELSE template_anat.label END, template_anat.short_form + "," + coalesce(i.short_form, anat.short_form)]), "[![null]( 'null')](null)", "") AS thumbnail
2910+
thumbnail
28982911
"""
28992912

29002913
results = vc.nc.commit_list([main_query])
@@ -5356,8 +5369,12 @@ def _dataset_enrichment_cypher(ds_var: str = "ds") -> str:
53565369
pubs — "; "-joined per-pub `[label](short_form)` markdown so the
53575370
Reference column links each publication (FBrf)
53585371
license — `[label](short_form)` markdown link
5359-
template/technique/thumbnail — one representative channel-image
5360-
(matches prod's `apoc.cypher.run('… LIMIT 5')` shape)
5372+
template/technique — taken from a representative channel-image
5373+
thumbnail — up to 5 example channel-images as `' | '`-joined
5374+
`[![alt](url 'title')](ref)` markdown, so the Images
5375+
cell carousels (matches prod's `… LIMIT 5` shape).
5376+
The V2 imageMarkdownToVariableJson splits the joined
5377+
markdown into a SlideshowImageComponent.
53615378
image_count — DISTINCT count of individuals sourced to the dataset
53625379
53635380
Each branch is wrapped in its own CALL so the outer carrier row stays
@@ -5379,8 +5396,22 @@ def _dataset_enrichment_cypher(ds_var: str = "ds") -> str:
53795396
WITH {ds_var}
53805397
OPTIONAL MATCH ({ds_var})<-[:has_source]-(i:Individual)<-[:depicts]-(channel:Individual)-[irw:in_register_with]->(:Template)-[:depicts]->(templ:Template)
53815398
OPTIONAL MATCH (channel)-[:is_specified_output_of]->(technique:Class)
5382-
WITH i, templ, technique, irw, channel LIMIT 1
5383-
RETURN i, templ, technique, irw
5399+
WITH {ds_var}, i, templ, technique, irw
5400+
WHERE i IS NOT NULL
5401+
WITH {ds_var}, i, templ, technique, irw LIMIT 5
5402+
WITH {ds_var}, collect({{i: i, templ: templ, technique: technique, irw: irw}}) AS imgs
5403+
WITH {ds_var}, imgs, head(imgs) AS rep
5404+
RETURN
5405+
rep.templ AS templ,
5406+
rep.technique AS technique,
5407+
apoc.text.join([x IN imgs |
5408+
REPLACE(apoc.text.format("[![%s](%s '%s')](%s)",
5409+
[coalesce(x.i.label, 'image') + " aligned to " + CASE WHEN x.templ.symbol[0] <> '' THEN x.templ.symbol[0] ELSE x.templ.label END,
5410+
REPLACE(COALESCE(x.irw.thumbnail[0], ''), 'thumbnailT.png', 'thumbnail.png'),
5411+
coalesce(x.i.label, 'image') + " aligned to " + CASE WHEN x.templ.symbol[0] <> '' THEN x.templ.symbol[0] ELSE x.templ.label END,
5412+
x.templ.short_form + "," + coalesce(x.i.short_form, {ds_var}.short_form)]),
5413+
"[![null]( 'null')](null)", "")
5414+
], ' | ') AS thumbnail
53845415
}}
53855416
CALL {{
53865417
WITH {ds_var}
@@ -5412,7 +5443,7 @@ def _dataset_return_clause(ds_var: str = "ds") -> str:
54125443
license,
54135444
REPLACE(apoc.text.format("[%s](%s)", [CASE WHEN templ.symbol[0] <> '' THEN templ.symbol[0] ELSE templ.label END, templ.short_form]), '[null](null)', '') AS template,
54145445
coalesce(technique.label, '') AS technique,
5415-
REPLACE(apoc.text.format("[![%s](%s '%s')](%s)", [coalesce(i.label, 'image') + " aligned to " + CASE WHEN templ.symbol[0] <> '' THEN templ.symbol[0] ELSE templ.label END, REPLACE(COALESCE(irw.thumbnail[0], ''), 'thumbnailT.png', 'thumbnail.png'), coalesce(i.label, 'image') + " aligned to " + CASE WHEN templ.symbol[0] <> '' THEN templ.symbol[0] ELSE templ.label END, templ.short_form + "," + coalesce(i.short_form, {ds_var}.short_form)]), "[![null]( 'null')](null)", "") AS thumbnail,
5446+
thumbnail,
54165447
image_count
54175448
"""
54185449

@@ -5716,8 +5747,22 @@ def get_transgene_expression_here(anatomy_short_form: str, return_dataframe=True
57165747
WITH ep
57175748
OPTIONAL MATCH (ep)<-[:has_source|SUBCLASSOF|INSTANCEOF*]-(i:Individual)<-[:depicts]-(channel:Individual)-[irw:in_register_with]->(:Template)-[:depicts]->(templ:Template)
57185749
OPTIONAL MATCH (channel)-[:is_specified_output_of]->(technique:Class)
5719-
WITH i, templ, technique, irw LIMIT 1
5720-
RETURN i, templ, technique, irw
5750+
WITH ep, i, templ, technique, irw
5751+
WHERE i IS NOT NULL
5752+
WITH ep, i, templ, technique, irw LIMIT 5
5753+
WITH ep, collect({{i: i, templ: templ, technique: technique, irw: irw}}) AS imgs
5754+
WITH ep, imgs, head(imgs) AS rep
5755+
RETURN
5756+
rep.templ AS templ,
5757+
rep.technique AS technique,
5758+
apoc.text.join([x IN imgs |
5759+
REPLACE(apoc.text.format("[![%s](%s '%s')](%s)",
5760+
[coalesce(x.i.label, 'image') + " aligned to " + CASE WHEN x.templ.symbol[0] <> '' THEN x.templ.symbol[0] ELSE x.templ.label END,
5761+
REPLACE(COALESCE(x.irw.thumbnail[0], ''), 'thumbnailT.png', 'thumbnail.png'),
5762+
coalesce(x.i.label, 'image') + " aligned to " + CASE WHEN x.templ.symbol[0] <> '' THEN x.templ.symbol[0] ELSE x.templ.label END,
5763+
x.templ.short_form + "," + coalesce(x.i.short_form, ep.short_form)]),
5764+
"[![null]( 'null')](null)", "")
5765+
], ' | ') AS thumbnail
57215766
}}
57225767
RETURN
57235768
ep.short_form AS id,
@@ -5727,7 +5772,7 @@ def get_transgene_expression_here(anatomy_short_form: str, return_dataframe=True
57275772
pubs,
57285773
REPLACE(apoc.text.format("[%s](%s)", [CASE WHEN templ.symbol[0] <> '' THEN templ.symbol[0] ELSE templ.label END, templ.short_form]), '[null](null)', '') AS template,
57295774
coalesce(technique.label, '') AS technique,
5730-
REPLACE(apoc.text.format("[![%s](%s '%s')](%s)", [coalesce(i.label, 'image') + " aligned to " + CASE WHEN templ.symbol[0] <> '' THEN templ.symbol[0] ELSE templ.label END, REPLACE(COALESCE(irw.thumbnail[0], ''), 'thumbnailT.png', 'thumbnail.png'), coalesce(i.label, 'image') + " aligned to " + CASE WHEN templ.symbol[0] <> '' THEN templ.symbol[0] ELSE templ.label END, templ.short_form + "," + coalesce(i.short_form, ep.short_form)]), "[![null]( 'null')](null)", "") AS thumbnail
5775+
thumbnail
57315776
"""
57325777

57335778
results = vc.nc.commit_list([main_query])

0 commit comments

Comments
 (0)