function get_all_lims_tests
Queries a Neo4j graph database to retrieve LIMS_Tests nodes with a configurable limit on the number of results returned.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
451 - 458
simple
Purpose
This function provides a simple interface to fetch Laboratory Information Management System (LIMS) test records from a Neo4j graph database. It's designed for retrieving test data for analysis, reporting, or integration with other systems. The function uses Cypher query language to match nodes labeled as LIMS_Tests and returns them through a query execution function.
Source Code
def get_all_lims_tests(limit=100):
"""Return LIMS_Tests nodes (limited to 25)"""
query = """
MATCH (n:LIMS_Tests)
RETURN n
LIMIT $limit
"""
return run_query(query, {"limit": limit})
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
limit |
- | 100 | positional_or_keyword |
Parameter Details
limit: Integer value that controls the maximum number of LIMS_Tests nodes to return from the database. Default is 100, though the docstring incorrectly states 25. Must be a positive integer. Higher values may impact performance depending on database size and network conditions.
Return Value
Returns the result of run_query() function execution. The exact return type depends on the run_query implementation, but typically would be a list of Neo4j node objects or dictionaries representing LIMS_Tests nodes, limited to the specified number. Could also return None or an empty collection if no matching nodes exist or if the query fails.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
# Example 1: Get default 100 LIMS tests
tests = get_all_lims_tests()
for test in tests:
print(test)
# Example 2: Get only 10 LIMS tests
tests_limited = get_all_lims_tests(limit=10)
# Example 3: Get all available tests (use with caution)
tests_all = get_all_lims_tests(limit=10000)
Best Practices
- Note the discrepancy: docstring says 'limited to 25' but default parameter is 100 - update documentation for consistency
- Always specify an appropriate limit value based on your use case to avoid performance issues with large datasets
- Ensure the run_query() function is properly implemented with error handling and connection management
- Consider adding error handling around the query execution for production use
- The function depends on run_query() being available - ensure this dependency is satisfied before calling
- For large result sets, consider implementing pagination instead of increasing the limit
- Validate that the Neo4j database connection is established before calling this function
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_all_lims_sampletestresults 91.7% similar
-
function get_all_lims_sampletypetests 91.1% similar
-
function get_all_lims_testparameters 90.4% similar
-
function get_all_lims_samples 89.3% similar
-
function get_all_lims_tests4pathogens 89.0% similar