function get_lims_parameters_with_references_parameters_lims_parameters
Retrieves LIMS_Parameters nodes from a Neo4j graph database that are connected to a source LIMS_Parameters node via REFERENCES_PARAMETERS relationships.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
1193 - 1200
simple
Purpose
This function queries a Neo4j graph database to find all LIMS_Parameters nodes that are referenced by a specific source LIMS_Parameters node. It's useful for traversing parameter reference hierarchies in a Laboratory Information Management System (LIMS), allowing users to discover which parameters are linked to or depend on a given parameter. The limit parameter controls the maximum number of results returned to prevent overwhelming queries on large graphs.
Source Code
def get_lims_parameters_with_references_parameters_lims_parameters(source_id, limit=100):
"""Get LIMS_Parameters nodes connected to a LIMS_Parameters via REFERENCES_PARAMETERS"""
query = """
MATCH (source:LIMS_Parameters {id: $source_id})-[r:REFERENCES_PARAMETERS]->(target:LIMS_Parameters)
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 source LIMS_Parameters node from which to find referenced parameters. Expected to be a string or integer that matches an existing node's id in the database.
limit: Maximum number of target LIMS_Parameters nodes to return. Defaults to 100. Must be a positive integer. Used to prevent performance issues when querying large graphs with many relationships.
Return Value
Returns the result of run_query() function, which typically returns a list of Neo4j records containing the target LIMS_Parameters nodes that match the query criteria. Each record represents a LIMS_Parameters node connected via REFERENCES_PARAMETERS relationship. The exact return type depends on the run_query() implementation, but is likely a list of dictionaries or Neo4j Record objects containing node properties. Returns an empty list 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 established
# Example run_query implementation:
# def run_query(query, params):
# with driver.session() as session:
# result = session.run(query, params)
# return [record['target'] for record in result]
# Query for parameters referenced by parameter with id 'PARAM_001'
results = get_lims_parameters_with_references_parameters_lims_parameters('PARAM_001', limit=50)
# Process results
for node in results:
print(f"Referenced parameter: {node['id']}")
# Query with default limit
all_refs = get_lims_parameters_with_references_parameters_lims_parameters('PARAM_002')
Best Practices
- Ensure the source_id exists in the database before calling to avoid empty results
- Adjust the limit parameter based on expected result size and performance requirements
- The run_query() function must be properly implemented with error handling and connection management
- Consider adding error handling for database connection failures
- Validate source_id input to prevent injection attacks if user-supplied
- Use appropriate indexes on LIMS_Parameters.id property for optimal query performance
- Consider pagination for large result sets instead of relying solely on limit parameter
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_lims_testparameters_with_references_parameters_lims_parameters 92.5% similar
-
function get_lims_testparameters_with_references_tests_lims_tests 86.7% similar
-
function get_all_lims_parameters 86.5% similar
-
function get_lims_sampletestresults_with_references_testparameters_lims_testparameters 85.6% similar
-
function get_all_lims_testparameters 83.5% similar