vfbquery 0.5.4__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.
Files changed (46) hide show
  1. {vfbquery-0.5.4/src/vfbquery.egg-info → vfbquery-0.5.5}/PKG-INFO +1 -1
  2. {vfbquery-0.5.4 → vfbquery-0.5.5}/setup.py +1 -1
  3. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/__init__.py +1 -1
  4. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/vfb_queries.py +53 -8
  5. {vfbquery-0.5.4 → vfbquery-0.5.5/src/vfbquery.egg-info}/PKG-INFO +1 -1
  6. {vfbquery-0.5.4 → vfbquery-0.5.5}/LICENSE +0 -0
  7. {vfbquery-0.5.4 → vfbquery-0.5.5}/README.md +0 -0
  8. {vfbquery-0.5.4 → vfbquery-0.5.5}/pyproject.toml +0 -0
  9. {vfbquery-0.5.4 → vfbquery-0.5.5}/setup.cfg +0 -0
  10. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/__init__.py +0 -0
  11. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/readme_parser.py +0 -0
  12. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/term_info_queries_test.py +0 -0
  13. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_dataset_template_queries.py +0 -0
  14. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_default_caching.py +0 -0
  15. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_examples_code.py +0 -0
  16. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_examples_diff.py +0 -0
  17. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_expression_overlaps.py +0 -0
  18. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_expression_pattern_fragments.py +0 -0
  19. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_images_neurons.py +0 -0
  20. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_images_that_develop_from.py +0 -0
  21. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_lineage_clones_in.py +0 -0
  22. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_nblast_queries.py +0 -0
  23. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_neuron_classes_fasciculating.py +0 -0
  24. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_neuron_inputs.py +0 -0
  25. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_neuron_neuron_connectivity.py +0 -0
  26. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_neuron_region_connectivity.py +0 -0
  27. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_neurons_part_here.py +0 -0
  28. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_new_owlery_queries.py +0 -0
  29. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_publication_transgene_queries.py +0 -0
  30. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_query_performance.py +0 -0
  31. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_similar_morphology.py +0 -0
  32. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_tracts_nerves_innervating.py +0 -0
  33. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/test/test_transcriptomics.py +0 -0
  34. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/cache_enhancements.py +0 -0
  35. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/cached_functions.py +0 -0
  36. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/neo4j_client.py +0 -0
  37. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/owlery_client.py +0 -0
  38. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/solr_cache_integration.py +0 -0
  39. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/solr_fetcher.py +0 -0
  40. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/solr_result_cache.py +0 -0
  41. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/term_info_queries.py +0 -0
  42. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery/test_utils.py +0 -0
  43. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery.egg-info/SOURCES.txt +0 -0
  44. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery.egg-info/dependency_links.txt +0 -0
  45. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery.egg-info/requires.txt +0 -0
  46. {vfbquery-0.5.4 → vfbquery-0.5.5}/src/vfbquery.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vfbquery
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Wrapper for querying VirtualFlyBrain knowledge graph.
5
5
  Home-page: https://github.com/VirtualFlyBrain/VFBquery
6
6
  Author: VirtualFlyBrain
@@ -3,7 +3,7 @@ from os import path
3
3
 
4
4
  here = path.abspath(path.dirname(__file__))
5
5
 
6
- __version__ = "0.5.4"
6
+ __version__ = "0.5.5"
7
7
 
8
8
  # Get the long description from the README file
9
9
  with open(path.join(here, 'README.md')) as f:
@@ -95,4 +95,4 @@ except ImportError:
95
95
  __solr_caching_available__ = False
96
96
 
97
97
  # Version information
98
- __version__ = "0.5.4"
98
+ __version__ = "0.5.5"
@@ -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
- cypher = f"""
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
- # Filter by direction if specified
2681
- if direction != 'both':
2690
+ # Get total count if limit was applied
2691
+ if limit != -1:
2682
2692
  if direction == 'upstream':
2683
- rows = [row for row in rows if row.get('inputs', 0) > 0]
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
- rows = [row for row in rows if row.get('outputs', 0) > 0]
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': len(rows)
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 (query['preview'] > 0 or query['count'] < 0) and query['count'] != 0:
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
- result_count = len(result)
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vfbquery
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Wrapper for querying VirtualFlyBrain knowledge graph.
5
5
  Home-page: https://github.com/VirtualFlyBrain/VFBquery
6
6
  Author: VirtualFlyBrain
File without changes
File without changes
File without changes
File without changes
File without changes