diff --git a/src/test/test_term_info_parity.py b/src/test/test_term_info_parity.py index fe56c83..ce705f4 100644 --- a/src/test/test_term_info_parity.py +++ b/src/test/test_term_info_parity.py @@ -134,7 +134,14 @@ def test_splits_targeting_returns_count_and_rows(self): self.assertIsInstance(r, dict) self.assertGreater(r.get("count", 0), 0, "expected splits targeting MBON") self.assertTrue(r.get("rows"), "no preview rows") - self.assertTrue(all(k in r["rows"][0] for k in ("id", "label", "tags", "thumbnail"))) + self.assertTrue(all(k in r["rows"][0] + for k in ("id", "label", "tags", "template", "technique", "thumbnail"))) + # Template_Space / Imaging_Technique columns must actually be populated + # (the query declares them; they were previously always blank). + self.assertTrue(any(row.get("template") for row in r["rows"]), + "Template column empty for all splits") + self.assertTrue(any(row.get("technique") for row in r["rows"]), + "Imaging Technique column empty for all splits") def test_neurons_targeted_by_split_returns_count(self): r = q.get_neurons_targeted_by_split("VFBexp_FBtp0129935FBtp0129968", return_dataframe=False, limit=5) diff --git a/src/vfbquery/vfb_queries.py b/src/vfbquery/vfb_queries.py index 9543632..71b4580 100644 --- a/src/vfbquery/vfb_queries.py +++ b/src/vfbquery/vfb_queries.py @@ -3989,11 +3989,15 @@ def _targeting_rows(base_match, var, short_form, return_dataframe, limit): main_query = base_match + ( f" WITH DISTINCT {var} " f"CALL {{ WITH {var} OPTIONAL MATCH ({var})<-[:INSTANCEOF]-(:Individual)<-[:depicts]-" - "(:Individual)-[irw:in_register_with]->(:Template)-[:depicts]->(templ:Template) " - "RETURN irw, templ LIMIT 1 } " + "(channel:Individual)-[irw:in_register_with]->(:Template)-[:depicts]->(templ:Template) " + "OPTIONAL MATCH (channel)-[:is_specified_output_of]->(technique:Class) " + "RETURN irw, templ, technique LIMIT 1 } " f"RETURN {var}.short_form AS id, " f"apoc.text.format(\"[%s](%s)\",[{var}.label, {var}.short_form]) AS label, " f"apoc.text.join(coalesce({var}.uniqueFacets,[]),'|') AS tags, " + "CASE WHEN templ IS NULL THEN '' ELSE " + "apoc.text.format(\"[%s](%s)\", [templ.label, templ.short_form]) END AS template, " + "coalesce(technique.label, '') AS technique, " f"REPLACE(apoc.text.format(\"[![%s](%s '%s')](%s)\",[{var}.label, " "REPLACE(REPLACE(COALESCE(irw.thumbnail[0],''),'thumbnailT.png','thumbnail.png'),'http://','https://'), " f"{var}.label, templ.short_form + ',' + {var}.short_form]), " @@ -4003,12 +4007,13 @@ def _targeting_rows(base_match, var, short_form, return_dataframe, limit): if limit != -1: main_query += f" LIMIT {limit}" df = pd.DataFrame.from_records(get_dict_cursor()(vc.nc.commit_list([main_query]))) - df = encode_markdown_links(df, ['label', 'thumbnail']) + df = encode_markdown_links(df, ['label', 'template', 'thumbnail']) if return_dataframe: return df return { "headers": _get_standard_query_headers(), - "rows": [{k: row.get(k) for k in ["id", "label", "tags", "thumbnail"]} + "rows": [{k: row.get(k) + for k in ["id", "label", "tags", "template", "technique", "thumbnail"]} for row in safe_to_dict(df, sort_by_id=False)], "count": total_count, }