@@ -2453,19 +2453,32 @@ def get_similar_neurons(neuron, similarity_score='NBLAST_score', return_datafram
24532453 count_df = pd .DataFrame .from_records (get_dict_cursor ()(count_results ))
24542454 total_count = count_df ['total_count' ][0 ] if not count_df .empty else 0
24552455
2456- main_query = f"""MATCH (c1:Class)<-[:INSTANCEOF]-(n1)-[r:has_similar_morphology_to]-(n2)-[:INSTANCEOF]->(c2:Class)
2456+ # Extends the v1.10.1 channel/template/technique pattern. Adds:
2457+ # - type = pipe-joined parent class labels (n2 -[:INSTANCEOF]-> Class)
2458+ # matches v2 prod's `Type` column from SOLR's `types` collection
2459+ # - template = `[symbol](short_form)` markdown of the alignment template
2460+ # - technique = imaging technique label (channel -[:is_specified_output_of]-> Class)
2461+ main_query = f"""MATCH (c1:Class)<-[:INSTANCEOF]-(n1)-[r:has_similar_morphology_to]-(n2)-[:INSTANCEOF]->(c2:Class)
24572462 WHERE n1.short_form = '{ neuron } ' and exists(r.{ similarity_score } )
24582463 WITH c1, n1, r, n2, c2
24592464 OPTIONAL MATCH (n2)-[rx:database_cross_reference]->(site:Site)
24602465 WHERE site.is_data_source
24612466 WITH n2, r, c2, rx, site
2462- OPTIONAL MATCH (n2)<-[:depicts]-(:Individual)-[ri:in_register_with]->(:Template)-[:depicts]->(templ:Template)
2467+ OPTIONAL MATCH (n2)<-[:depicts]-(channel:Individual)-[ri:in_register_with]->(:Template)-[:depicts]->(templ:Template)
2468+ OPTIONAL MATCH (channel)-[:is_specified_output_of]->(technique:Class)
2469+ WITH n2, r, c2, rx, site, channel, ri, templ, technique
2470+ OPTIONAL MATCH (n2)-[:INSTANCEOF]->(typ:Class)
2471+ WITH n2, r, rx, site, channel, ri, templ, technique,
2472+ apoc.text.join(collect(DISTINCT coalesce(typ.label, '')), '; ') AS type
24632473 RETURN DISTINCT n2.short_form as id,
2464- apoc.text.format("[%s](%s)", [n2.label, n2.short_form]) AS name,
2474+ apoc.text.format("[%s](%s)", [n2.label, n2.short_form]) AS name,
24652475 r.{ similarity_score } [0] AS score,
2466- apoc.text.join(n2.uniqueFacets, '|') AS tags,
2476+ apoc.text.join(coalesce(n2.uniqueFacets, []), '|') AS tags,
2477+ type,
24672478 REPLACE(apoc.text.format("[%s](%s)",[COALESCE(site.symbol[0],site.label),site.short_form]), '[null](null)', '') AS source,
24682479 REPLACE(apoc.text.format("[%s](%s)",[rx.accession[0], (site.link_base[0] + rx.accession[0])]), '[null](null)', '') AS source_id,
2480+ REPLACE(apoc.text.format("[%s](%s)",[COALESCE(templ.symbol[0],templ.label),templ.short_form]), '[null](null)', '') AS template,
2481+ coalesce(technique.label, '') AS technique,
24692482 REPLACE(apoc.text.format("[](%s)",[COALESCE(n2.symbol[0],n2.label) + " aligned to " + COALESCE(templ.symbol[0],templ.label), REPLACE(COALESCE(ri.thumbnail[0],""),"thumbnailT.png","thumbnail.png"), COALESCE(n2.symbol[0],n2.label) + " aligned to " + COALESCE(templ.symbol[0],templ.label), templ.short_form + "," + n2.short_form]), "[](null)", "") as thumbnail
24702483 ORDER BY score DESC"""
24712484
0 commit comments