function get_lims_testparameters_with_references_tests_lims_tests
Queries a Neo4j graph database to retrieve LIMS_Tests nodes that are connected to a specific LIMS_Testparameters node through a REFERENCES_TESTS relationship.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
1609 - 1616
simple
Purpose
This function is designed to traverse a graph database structure representing a Laboratory Information Management System (LIMS). It finds all test definitions (LIMS_Tests) that are referenced by a specific test parameter configuration (LIMS_Testparameters). This is useful for understanding which tests utilize particular test parameters, enabling analysis of test configurations and their relationships in a laboratory data management context.
Source Code
def get_lims_testparameters_with_references_tests_lims_tests(source_id, limit=100):
"""Get LIMS_Tests nodes connected to a LIMS_Testparameters via REFERENCES_TESTS"""
query = """
MATCH (source:LIMS_Testparameters {id: $source_id})-[r:REFERENCES_TESTS]->(target:LIMS_Tests)
RETURN target
LIMIT $limit
"""
return run_query(query, {"source_id": source_id, "limit": limit})
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
source_id |
- | - | positional_or_keyword |
limit |
- | 100 | positional_or_keyword |
Parameter Details
source_id: The unique identifier (id property) of the LIMS_Testparameters node from which to start the traversal. This should be a string or value that matches the 'id' property of a LIMS_Testparameters node in the Neo4j database.
limit: Maximum number of LIMS_Tests nodes to return. Defaults to 100. This parameter controls query performance and result set size. Should be a positive integer.
Return Value
Returns the result of the run_query function, which typically contains a list or collection of LIMS_Tests nodes that match the query criteria. The exact return type depends on the implementation of run_query, but it likely returns a list of dictionaries or Neo4j Record objects containing the properties of the target LIMS_Tests nodes. Returns an empty collection if no matching relationships are found.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
# Example run_query implementation:
# def run_query(query, params):
# driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'password'))
# with driver.session() as session:
# result = session.run(query, params)
# return [record['target'] for record in result]
# Get LIMS_Tests referenced by a specific test parameter
test_param_id = 'TP-12345'
results = get_lims_testparameters_with_references_tests_lims_tests(test_param_id, limit=50)
# Process results
for test_node in results:
print(f"Test ID: {test_node['id']}, Name: {test_node.get('name', 'N/A')}")
Best Practices
- Ensure the source_id parameter matches an existing LIMS_Testparameters node in the database to avoid empty results
- Adjust the limit parameter based on expected result set size and performance requirements
- Handle cases where run_query might return empty results or raise exceptions
- Consider implementing connection pooling and proper session management in the run_query function
- Use parameterized queries (as shown) to prevent Cypher injection attacks
- Close Neo4j driver connections properly after use to avoid resource leaks
- Consider adding error handling for database connection failures
- For large result sets, consider implementing pagination instead of relying solely on the limit parameter
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_lims_testparameters_with_references_parameters_lims_parameters 95.1% similar
-
function get_lims_sampletestresults_with_references_testparameters_lims_testparameters 92.0% similar
-
function get_lims_sampletypetests_with_references_tests_lims_tests 89.1% similar
-
function get_lims_parameters_with_references_parameters_lims_parameters 86.7% similar
-
function get_all_lims_testparameters 83.3% similar