Skip to content

Commit 7eae496

Browse files
committed
Add NeuronsCapableOf query: neurons capable of a neurotransmitter-secretion GO term, gated on GO_0007269 parent
1 parent df02f3a commit 7eae496

3 files changed

Lines changed: 65 additions & 3 deletions

File tree

src/vfbquery/ha_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ async def security_middleware(request, handler):
309309

310310
# Neurons in region
311311
"NeuronsPartHere": "get_neurons_with_part_in",
312+
"NeuronsCapableOf": "get_neurons_capable_of",
312313
"NeuronsSynaptic": "get_neurons_with_synapses_in",
313314
"NeuronsPresynapticHere": "get_neurons_with_presynaptic_terminals_in",
314315
"NeuronsPostsynapticHere": "get_neurons_with_postsynaptic_terminals_in",

src/vfbquery/solr_result_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ def wrapper(*args, **kwargs):
942942
expensive_query_types = ['similar_neurons', 'similar_morphology', 'similar_morphology_part_of',
943943
'similar_morphology_part_of_exp', 'similar_morphology_nb',
944944
'similar_morphology_nb_exp', 'similar_morphology_userdata',
945-
'neurons_part_here', 'neurons_synaptic',
945+
'neurons_part_here', 'neurons_synaptic', 'neurons_capable_of',
946946
'neurons_presynaptic', 'neurons_postsynaptic',
947947
'expression_overlaps_here', 'anatomy_scrnaseq', 'aligned_datasets', 'terms_for_pub',
948948
'individual_neuron_inputs', 'cluster_expression', 'expression_cluster', 'scrnaseq_dataset_data',
@@ -985,8 +985,8 @@ def wrapper(*args, **kwargs):
985985

986986
# Include return_dataframe parameter in cache key for queries that support it
987987
# This ensures DataFrame and dict results are cached separately
988-
dataframe_query_types = ['neurons_part_here', 'neurons_synaptic', 'neurons_presynaptic',
989-
'neurons_postsynaptic', 'similar_neurons', 'similar_morphology',
988+
dataframe_query_types = ['neurons_part_here', 'neurons_synaptic', 'neurons_capable_of', 'neurons_presynaptic',
989+
'neurons_postsynaptic', 'similar_neurons', 'similar_morphology',
990990
'similar_morphology_part_of', 'similar_morphology_part_of_exp',
991991
'similar_morphology_nb', 'similar_morphology_nb_exp',
992992
'similar_morphology_userdata', 'neurons_part_here', 'neurons_synaptic',

src/vfbquery/vfb_queries.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,17 @@ def term_info_parse_object(results, short_form):
11001100
if contains_all_tags(termInfo["SuperTypes"], ["Class"]):
11011101
q = SubclassesOf_to_schema(termInfo["Name"], {"short_form": vfbTerm.term.core.short_form})
11021102
queries.append(q)
1103+
1104+
# NeuronsCapableOf query - inverse of a neuron's 'capable of' relationship,
1105+
# e.g. neurotransmitter-secretion GO terms (neurons capable of ACh/GABA/
1106+
# serotonin secretion). These GO process terms carry no distinguishing
1107+
# SuperType facet, so gate on the term being a subclass of GO_0007269
1108+
# 'neurotransmitter secretion' -- the shared parent of every such process.
1109+
if vfbTerm.parents and any(
1110+
getattr(p, 'short_form', None) == "GO_0007269" for p in vfbTerm.parents
1111+
):
1112+
q = NeuronsCapableOf_to_schema(termInfo["Name"], {"short_form": vfbTerm.term.core.short_form})
1113+
queries.append(q)
11031114

11041115
# NeuronClassesFasciculatingHere query - for tracts/nerves
11051116
# Matches XMI criteria: Class + Tract_or_nerve (VFB uses Neuron_projection_bundle type)
@@ -2024,6 +2035,33 @@ def LineageClonesIn_to_schema(name, take_default):
20242035
return Query(query=query, label=label, function=function, takes=takes, preview=preview, preview_columns=preview_columns)
20252036

20262037

2038+
def NeuronsCapableOf_to_schema(name, take_default):
2039+
"""
2040+
Schema for NeuronsCapableOf query.
2041+
Finds individual neurons capable of the specified process (e.g. a
2042+
neurotransmitter-secretion GO term) -- the inverse of a neuron's
2043+
'capable of' (RO_0002215) relationship.
2044+
2045+
Applicability (gated in term_info_parse_object): the term is a subclass of
2046+
GO_0007269 'neurotransmitter secretion'. These GO terms carry no
2047+
distinguishing SuperType facet, so the shared parent is the signal.
2048+
2049+
Query chain: Owlery instances query -> process -> SOLR
2050+
OWL query: 'Neuron' that 'capable of' some '{short_form}' (returns instances)
2051+
"""
2052+
query = "NeuronsCapableOf"
2053+
label = f"Neurons capable of {name}"
2054+
function = "get_neurons_capable_of"
2055+
takes = {
2056+
"short_form": {"$and": ["Class"]},
2057+
"default": take_default,
2058+
}
2059+
preview = 5
2060+
preview_columns = ["id", "label", "tags", "thumbnail"]
2061+
2062+
return Query(query=query, label=label, function=function, takes=takes, preview=preview, preview_columns=preview_columns)
2063+
2064+
20272065
def ImagesNeurons_to_schema(name, take_default):
20282066
"""
20292067
Schema for ImagesNeurons query.
@@ -4604,6 +4642,29 @@ def get_images_that_develop_from(short_form: str, return_dataframe=True, limit:
46044642
solr_field='anat_image_query', query_by_label=False, query_instances=True)
46054643

46064644

4645+
@with_solr_cache('neurons_capable_of')
4646+
def get_neurons_capable_of(short_form: str, return_dataframe=True, limit: int = -1):
4647+
"""
4648+
Retrieves individual neurons capable of the specified process (e.g. a
4649+
neurotransmitter-secretion GO term) -- the inverse of a neuron's
4650+
'capable of' (RO_0002215) relationship.
4651+
4652+
Query chain: Owlery instances -> process -> SOLR
4653+
OWL query: <FBbt_00005106> and <RO_0002215> some <$ID> (instances)
4654+
Where: FBbt_00005106 = neuron, RO_0002215 = capable of
4655+
4656+
Note: returns INSTANCES (individual neurons), like ImagesNeurons.
4657+
4658+
:param short_form: short form of the process/GO term (Class)
4659+
:param return_dataframe: Returns pandas dataframe if true, otherwise formatted dict
4660+
:param limit: maximum number of results (default -1, all)
4661+
:return: Individual neurons capable of the specified process
4662+
"""
4663+
owl_query = f"<http://purl.obolibrary.org/obo/FBbt_00005106> and <http://purl.obolibrary.org/obo/RO_0002215> some <{_short_form_to_iri(short_form)}>"
4664+
return _owlery_query_to_results(owl_query, short_form, return_dataframe, limit,
4665+
solr_field='anat_image_query', query_by_label=False, query_instances=True)
4666+
4667+
46074668
def _short_form_to_iri(short_form: str) -> str:
46084669
"""
46094670
Convert a short form ID to its full IRI.

0 commit comments

Comments
 (0)