@@ -1346,104 +1346,62 @@ def term_info_parse_object(results, short_form):
13461346 "default_args" : {"fbco_id" : sf },
13471347 })
13481348
1349- # For individuals that are painted domains of anatomical regions, add parent class queries
1350- if termInfo ["IsIndividual" ] and termInfo ["Technique" ] and any ('computer' in t .lower () for t in termInfo ["Technique" ]):
1351- anatomical_classes = []
1352-
1353- # Check parents
1354- if vfbTerm .parents :
1355- for parent in vfbTerm .parents :
1356- if parent .types and "Class" in parent .types and "Anatomy" in parent .types :
1357- anatomical_classes .append (parent )
1358-
1359- # Check relationships for anatomical classes
1360- if vfbTerm .relationships :
1361- for rel in vfbTerm .relationships :
1362- if hasattr (rel , 'object' ) and rel .object and hasattr (rel .object , 'types' ) and rel .object .types :
1363- if "Class" in rel .object .types and "Anatomy" in rel .object .types :
1364- anatomical_classes .append (rel .object )
1365-
1366- # Remove duplicates based on short_form
1367- seen = set ()
1368- unique_anatomical_classes = []
1369- for cls in anatomical_classes :
1370- if cls .short_form not in seen :
1371- seen .add (cls .short_form )
1372- unique_anatomical_classes .append (cls )
1373-
1374- for parent in unique_anatomical_classes :
1375- parent_short_form = parent .short_form
1376- parent_label = parent .label if parent .label else parent_short_form
1377-
1378- # Add queries based on parent types
1379- if "Anatomy" in parent .types or "Synaptic_neuropil" in parent .types or "Synaptic_neuropil_domain" in parent .types :
1380- # NeuronsPartHere query
1381- q = NeuronsPartHere_to_schema (parent_label , {"short_form" : parent_short_form })
1382- queries .append (q )
1383-
1384- # NeuronsSynaptic query
1385- q = NeuronsSynaptic_to_schema (parent_label , {"short_form" : parent_short_form })
1386- queries .append (q )
1387-
1388- # NeuronsPresynapticHere query
1389- q = NeuronsPresynapticHere_to_schema (parent_label , {"short_form" : parent_short_form })
1390- queries .append (q )
1391-
1392- # NeuronsPostsynapticHere query
1393- q = NeuronsPostsynapticHere_to_schema (parent_label , {"short_form" : parent_short_form })
1394- queries .append (q )
1395-
1396- # TractsNervesInnervatingHere query
1397- q = TractsNervesInnervatingHere_to_schema (parent_label , {"short_form" : parent_short_form })
1398- queries .append (q )
1399-
1400- # LineageClonesIn query
1401- q = LineageClonesIn_to_schema (parent_label , {"short_form" : parent_short_form })
1402- queries .append (q )
1403-
1404- # ImagesNeurons query
1405- q = ImagesNeurons_to_schema (parent_label , {"short_form" : parent_short_form })
1406- queries .append (q )
1407-
1408- if "Expression_pattern" in parent .types or "Expression_pattern_fragment" in parent .types :
1409- # AnatomyExpressedIn query — anatomy classes where this
1410- # expression pattern is expressed.
1411- q = AnatomyExpressedIn_to_schema (parent_label , {"short_form" : parent_short_form })
1412- queries .append (q )
1413-
1414- if "Anatomy" in parent .types and "hasScRNAseq" in parent .types :
1415- # anatScRNAseqQuery query
1416- q = anatScRNAseqQuery_to_schema (parent_label , {"short_form" : parent_short_form })
1417- queries .append (q )
1418-
1419- if "Neuron_projection_bundle" in parent .types :
1420- # NeuronClassesFasciculatingHere query
1421- q = NeuronClassesFasciculatingHere_to_schema (parent_label , {"short_form" : parent_short_form })
1422- queries .append (q )
1423-
1424- if "Neuroblast" in parent .types :
1425- # ImagesThatDevelopFrom query
1426- q = ImagesThatDevelopFrom_to_schema (parent_label , {"short_form" : parent_short_form })
1427- queries .append (q )
1428-
1429- if "Expression_pattern" in parent .types :
1430- # epFrag query
1431- q = epFrag_to_schema (parent_label , {"short_form" : parent_short_form })
1432- queries .append (q )
1433-
1434- if "Nervous_system" in parent .types and ("Anatomy" in parent .types or "Neuron" in parent .types ):
1435- # TransgeneExpressionHere query
1436- q = TransgeneExpressionHere_to_schema (parent_label , {"short_form" : parent_short_form })
1437- queries .append (q )
1438-
1439- # PartsOf query - for any Class
1440- q = PartsOf_to_schema (parent_label , {"short_form" : parent_short_form })
1441- queries .append (q )
1442-
1443- # SubclassesOf query - for any Class
1444- q = SubclassesOf_to_schema (parent_label , {"short_form" : parent_short_form })
1445- queries .append (q )
1446-
1349+ # Bring the parent class's query menu down onto selected Individual
1350+ # instances, reproducing the legacy term-info builder
1351+ # (VFBProcessTermInfoCachedJson, gate ~line 1757): an Individual of one
1352+ # of these anatomical / expression-pattern types inherits every
1353+ # class-anchored query its parent class matches, run on the class (not
1354+ # the individual). Replaces an earlier Technique == "computer graphic"
1355+ # gate that only caught painted domains and silently dropped confocal
1356+ # instances (expression patterns, splits, tracts, muscle).
1357+ #
1358+ # The predicate table mirrors the class-menu conditions above; keep the
1359+ # two in sync (a future refactor should share a single source).
1360+ inherit_instance_types = (
1361+ "Painted_domain" , "Synaptic_neuropil" , "Synaptic_neuropil_domain" ,
1362+ "Synaptic_neuropil_subdomain" , "Neuron_projection_bundle" , "Split" ,
1363+ "Expression_pattern" , "Muscle" ,
1364+ )
1365+ instance_super_types = termInfo ["SuperTypes" ] or []
1366+ if termInfo ["IsIndividual" ] and any (t in instance_super_types for t in inherit_instance_types ):
1367+ # Legacy anchored on the first parent Class (classVariable = parents[0]).
1368+ inherit_parent = next (
1369+ (p for p in (vfbTerm .parents or []) if p .types and "Class" in p .types ),
1370+ None ,
1371+ )
1372+ if inherit_parent is not None :
1373+ p_types = set (inherit_parent .types or [])
1374+ p_ref = {"short_form" : inherit_parent .short_form }
1375+ p_label = inherit_parent .label if inherit_parent .label else inherit_parent .short_form
1376+ # (schema builder, predicate over the parent class's type set).
1377+ # Predicates copy the Class-gated conditions used for the term's
1378+ # own menu above so an instance shows exactly what its class shows.
1379+ inheritable_class_queries = (
1380+ (ListAllAvailableImages_to_schema , lambda p : {"Class" , "Anatomy" } <= p ),
1381+ (NeuronsPartHere_to_schema , lambda p : "Class" in p and "Neuron" not in p and ("Synaptic_neuropil" in p or "Anatomy" in p )),
1382+ (NeuronsSynaptic_to_schema , lambda p : "Class" in p and ("Synaptic_neuropil" in p or "Visual_system" in p or "Synaptic_neuropil_domain" in p )),
1383+ (NeuronsPresynapticHere_to_schema , lambda p : "Class" in p and ("Synaptic_neuropil" in p or "Visual_system" in p or "Synaptic_neuropil_domain" in p )),
1384+ (NeuronsPostsynapticHere_to_schema , lambda p : "Class" in p and ("Synaptic_neuropil" in p or "Visual_system" in p or "Synaptic_neuropil_domain" in p )),
1385+ (ImagesNeurons_to_schema , lambda p : "Class" in p and ("Synaptic_neuropil" in p or "Synaptic_neuropil_domain" in p )),
1386+ (TractsNervesInnervatingHere_to_schema , lambda p : "Class" in p and ("Synaptic_neuropil" in p or "Synaptic_neuropil_domain" in p )),
1387+ (LineageClonesIn_to_schema , lambda p : "Class" in p and ("Synaptic_neuropil" in p or "Synaptic_neuropil_domain" in p )),
1388+ (NeuronClassesFasciculatingHere_to_schema , lambda p : "Class" in p and "Neuron_projection_bundle" in p ),
1389+ (ComponentsOf_to_schema , lambda p : {"Class" , "Clone" } <= p ),
1390+ (ImagesThatDevelopFrom_to_schema , lambda p : {"Class" , "Neuroblast" } <= p ),
1391+ (epFrag_to_schema , lambda p : {"Class" , "Expression_pattern" } <= p ),
1392+ (AnatomyExpressedIn_to_schema , lambda p : "Class" in p and ("Expression_pattern" in p or "Expression_pattern_fragment" in p )),
1393+ (anatScRNAseqQuery_to_schema , lambda p : {"Class" , "Anatomy" , "hasScRNAseq" } <= p ),
1394+ (TransgeneExpressionHere_to_schema , lambda p : "Class" in p and "Nervous_system" in p and ("Anatomy" in p or "Neuron" in p )),
1395+ (TargetNeurons_to_schema , lambda p : {"Class" , "Split" } <= p ),
1396+ (DownstreamClassConnectivity_to_schema , lambda p : {"Class" , "Neuron" } <= p ),
1397+ (UpstreamClassConnectivity_to_schema , lambda p : {"Class" , "Neuron" } <= p ),
1398+ (PartsOf_to_schema , lambda p : "Class" in p and "Neuron" not in p ),
1399+ (SubclassesOf_to_schema , lambda p : "Class" in p ),
1400+ )
1401+ for schema_fn , predicate in inheritable_class_queries :
1402+ if predicate (p_types ):
1403+ queries .append (schema_fn (p_label , p_ref ))
1404+
14471405 # Add Publications to the termInfo object
14481406 if vfbTerm .pubs and len (vfbTerm .pubs ) > 0 :
14491407 publications = []
0 commit comments