vfbquery 0.5.3__tar.gz → 0.5.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vfbquery-0.5.3/src/vfbquery.egg-info → vfbquery-0.5.5}/PKG-INFO +1 -1
- {vfbquery-0.5.3 → vfbquery-0.5.5}/setup.py +1 -1
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/__init__.py +1 -1
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/solr_result_cache.py +3 -1
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/vfb_queries.py +53 -8
- {vfbquery-0.5.3 → vfbquery-0.5.5/src/vfbquery.egg-info}/PKG-INFO +1 -1
- {vfbquery-0.5.3 → vfbquery-0.5.5}/LICENSE +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/README.md +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/pyproject.toml +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/setup.cfg +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/__init__.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/readme_parser.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/term_info_queries_test.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_dataset_template_queries.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_default_caching.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_examples_code.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_examples_diff.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_expression_overlaps.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_expression_pattern_fragments.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_images_neurons.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_images_that_develop_from.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_lineage_clones_in.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_nblast_queries.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_neuron_classes_fasciculating.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_neuron_inputs.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_neuron_neuron_connectivity.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_neuron_region_connectivity.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_neurons_part_here.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_new_owlery_queries.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_publication_transgene_queries.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_query_performance.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_similar_morphology.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_tracts_nerves_innervating.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/test/test_transcriptomics.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/cache_enhancements.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/cached_functions.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/neo4j_client.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/owlery_client.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/solr_cache_integration.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/solr_fetcher.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/term_info_queries.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery/test_utils.py +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery.egg-info/SOURCES.txt +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery.egg-info/dependency_links.txt +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery.egg-info/requires.txt +0 -0
- {vfbquery-0.5.3 → vfbquery-0.5.5}/src/vfbquery.egg-info/top_level.txt +0 -0
|
@@ -660,7 +660,9 @@ def with_solr_cache(query_type: str):
|
|
|
660
660
|
'similar_morphology_part_of', 'similar_morphology_part_of_exp',
|
|
661
661
|
'similar_morphology_nb', 'similar_morphology_nb_exp',
|
|
662
662
|
'similar_morphology_userdata', 'neurons_part_here', 'neurons_synaptic',
|
|
663
|
-
'neurons_presynaptic', 'neurons_postsynaptic'
|
|
663
|
+
'neurons_presynaptic', 'neurons_postsynaptic', 'neuron_neuron_connectivity_query',
|
|
664
|
+
'neuron_region_connectivity_query', 'instances', 'templates', 'images_neurons',
|
|
665
|
+
'images_that_develop_from', 'expression_pattern_fragments']
|
|
664
666
|
if query_type in dataframe_query_types:
|
|
665
667
|
return_dataframe = kwargs.get('return_dataframe', True) # Default is True
|
|
666
668
|
cache_term_id = f"{cache_term_id}_dataframe_{return_dataframe}"
|
|
@@ -2655,7 +2655,7 @@ def get_neuron_neuron_connectivity(short_form: str, return_dataframe=True, limit
|
|
|
2655
2655
|
"""
|
|
2656
2656
|
# Build Cypher query to get connected neurons using synapsed_to relationships
|
|
2657
2657
|
# XMI spec uses min_weight > 1, but we default to 0 to return all valid connections
|
|
2658
|
-
|
|
2658
|
+
base_cypher = f"""
|
|
2659
2659
|
MATCH (primary:Individual {{short_form: '{short_form}'}})
|
|
2660
2660
|
MATCH (oi:Individual)-[r:synapsed_to]-(primary)
|
|
2661
2661
|
WHERE exists(r.weight) AND r.weight[0] > {min_weight}
|
|
@@ -2663,6 +2663,15 @@ def get_neuron_neuron_connectivity(short_form: str, return_dataframe=True, limit
|
|
|
2663
2663
|
OPTIONAL MATCH (oi)<-[down:synapsed_to]-(primary)
|
|
2664
2664
|
WITH down, oi, primary
|
|
2665
2665
|
OPTIONAL MATCH (primary)<-[up:synapsed_to]-(oi)
|
|
2666
|
+
"""
|
|
2667
|
+
|
|
2668
|
+
if direction == 'upstream':
|
|
2669
|
+
base_cypher += " WHERE up IS NOT NULL AND up.weight[0] > 0"
|
|
2670
|
+
elif direction == 'downstream':
|
|
2671
|
+
base_cypher += " WHERE down IS NOT NULL AND down.weight[0] > 0"
|
|
2672
|
+
# for 'both', no additional WHERE
|
|
2673
|
+
|
|
2674
|
+
cypher = base_cypher + """
|
|
2666
2675
|
RETURN
|
|
2667
2676
|
oi.short_form AS id,
|
|
2668
2677
|
oi.label AS label,
|
|
@@ -2670,6 +2679,7 @@ def get_neuron_neuron_connectivity(short_form: str, return_dataframe=True, limit
|
|
|
2670
2679
|
coalesce(up.weight[0], 0) AS inputs,
|
|
2671
2680
|
oi.uniqueFacets AS tags
|
|
2672
2681
|
"""
|
|
2682
|
+
|
|
2673
2683
|
if limit != -1:
|
|
2674
2684
|
cypher += f" LIMIT {limit}"
|
|
2675
2685
|
|
|
@@ -2677,12 +2687,20 @@ def get_neuron_neuron_connectivity(short_form: str, return_dataframe=True, limit
|
|
|
2677
2687
|
results = vc.nc.commit_list([cypher])
|
|
2678
2688
|
rows = get_dict_cursor()(results)
|
|
2679
2689
|
|
|
2680
|
-
#
|
|
2681
|
-
if
|
|
2690
|
+
# Get total count if limit was applied
|
|
2691
|
+
if limit != -1:
|
|
2682
2692
|
if direction == 'upstream':
|
|
2683
|
-
|
|
2693
|
+
count_query = base_cypher + " WHERE up IS NOT NULL AND up.weight[0] > 0 RETURN count(DISTINCT oi)"
|
|
2684
2694
|
elif direction == 'downstream':
|
|
2685
|
-
|
|
2695
|
+
count_query = base_cypher + " WHERE down IS NOT NULL AND down.weight[0] > 0 RETURN count(DISTINCT oi)"
|
|
2696
|
+
else: # both
|
|
2697
|
+
count_query = base_cypher + " RETURN count(DISTINCT oi)"
|
|
2698
|
+
count_results = vc.nc.commit_list([count_query])
|
|
2699
|
+
total_count = count_results[0][0] if count_results and count_results[0] else 0
|
|
2700
|
+
else:
|
|
2701
|
+
total_count = len(rows)
|
|
2702
|
+
|
|
2703
|
+
# No need to filter by direction, it's done in the query
|
|
2686
2704
|
|
|
2687
2705
|
# Format output
|
|
2688
2706
|
if return_dataframe:
|
|
@@ -2699,7 +2717,7 @@ def get_neuron_neuron_connectivity(short_form: str, return_dataframe=True, limit
|
|
|
2699
2717
|
return {
|
|
2700
2718
|
'headers': headers,
|
|
2701
2719
|
'rows': rows,
|
|
2702
|
-
'count':
|
|
2720
|
+
'count': total_count
|
|
2703
2721
|
}
|
|
2704
2722
|
|
|
2705
2723
|
|
|
@@ -3871,7 +3889,7 @@ def fill_query_results(term_info):
|
|
|
3871
3889
|
def process_query(query):
|
|
3872
3890
|
# print(f"Query Keys:{query.keys()}")
|
|
3873
3891
|
|
|
3874
|
-
if "preview" in query.keys() and
|
|
3892
|
+
if "preview" in query.keys() and query['preview'] > 0:
|
|
3875
3893
|
function = globals().get(query['function'])
|
|
3876
3894
|
summary_mode = query.get('output_format', 'table') == 'ribbon'
|
|
3877
3895
|
|
|
@@ -3916,6 +3934,11 @@ def fill_query_results(term_info):
|
|
|
3916
3934
|
filtered_result = []
|
|
3917
3935
|
filtered_headers = {}
|
|
3918
3936
|
|
|
3937
|
+
if result is None:
|
|
3938
|
+
query['preview_results'] = {'headers': query.get('preview_columns', ['id', 'label', 'tags', 'thumbnail']), 'rows': []}
|
|
3939
|
+
query['count'] = 0
|
|
3940
|
+
return
|
|
3941
|
+
|
|
3919
3942
|
if isinstance(result, dict) and 'rows' in result:
|
|
3920
3943
|
for item in result['rows']:
|
|
3921
3944
|
if 'preview_columns' in query.keys() and len(query['preview_columns']) > 0:
|
|
@@ -3958,8 +3981,30 @@ def fill_query_results(term_info):
|
|
|
3958
3981
|
# Handle count extraction based on result type
|
|
3959
3982
|
if isinstance(result, dict) and 'count' in result:
|
|
3960
3983
|
result_count = result['count']
|
|
3984
|
+
# If limit was applied, the count in dict may be wrong, get correct count
|
|
3985
|
+
if query['preview'] > 0 and result_count == len(result['rows']):
|
|
3986
|
+
try:
|
|
3987
|
+
if function_args and takes_short_form:
|
|
3988
|
+
short_form_value = list(function_args.values())[0]
|
|
3989
|
+
full_dict = function(short_form_value, return_dataframe=False, limit=-1)
|
|
3990
|
+
else:
|
|
3991
|
+
full_dict = function(return_dataframe=False, limit=-1)
|
|
3992
|
+
result_count = full_dict['count']
|
|
3993
|
+
except Exception as e:
|
|
3994
|
+
print(f"Error getting full count for {query['function']}: {e}")
|
|
3995
|
+
result_count = result['count'] # Keep as is
|
|
3961
3996
|
elif isinstance(result, pd.DataFrame):
|
|
3962
|
-
|
|
3997
|
+
# For DataFrame results, we need the full count even when preview is limited
|
|
3998
|
+
try:
|
|
3999
|
+
if function_args and takes_short_form:
|
|
4000
|
+
short_form_value = list(function_args.values())[0]
|
|
4001
|
+
full_result = function(short_form_value, return_dataframe=True, limit=-1)
|
|
4002
|
+
else:
|
|
4003
|
+
full_result = function(return_dataframe=True, limit=-1)
|
|
4004
|
+
result_count = len(full_result)
|
|
4005
|
+
except Exception as e:
|
|
4006
|
+
print(f"Error getting full count for {query['function']}: {e}")
|
|
4007
|
+
result_count = len(result) # Fallback to limited count
|
|
3963
4008
|
else:
|
|
3964
4009
|
result_count = 0
|
|
3965
4010
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|