function get_lims_testparameters_with_references_parameters_lims_parameters
Queries a Neo4j graph database to retrieve LIMS_Parameters nodes that are connected to a specific LIMS_Testparameters node through a REFERENCES_PARAMETERS relationship.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
1577 - 1584
simple
Purpose
This function is designed to traverse a graph database structure representing a Laboratory Information Management System (LIMS). It finds all parameter definitions (LIMS_Parameters) that are referenced by a specific test parameter configuration (LIMS_Testparameters). This is useful for understanding which parameters are associated with a particular test configuration, enabling test setup validation, parameter dependency analysis, and test configuration management.
Source Code
def get_lims_testparameters_with_references_parameters_lims_parameters(source_id, limit=100):
"""Get LIMS_Parameters nodes connected to a LIMS_Testparameters via REFERENCES_PARAMETERS"""
query = """
MATCH (source:LIMS_Testparameters {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 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_Parameters nodes to return. Defaults to 100. This parameter controls query performance and prevents returning excessively large result sets. Must be a positive integer.
Return Value
Returns the result of the run_query function, which typically contains a list or collection of LIMS_Parameters nodes (as Neo4j node objects or dictionaries) that are connected to the specified LIMS_Testparameters node via REFERENCES_PARAMETERS relationships. The exact return type depends on the implementation of run_query, but it commonly returns a list of records where each record contains the 'target' node data. Returns an empty collection if no matching relationships are found or if the source_id doesn't exist.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
# Example: Get all parameters referenced by test parameter with id 'TP001'
result = get_lims_testparameters_with_references_parameters_lims_parameters(
source_id='TP001',
limit=50
)
# Process the results
for record in result:
parameter_node = record['target']
print(f"Parameter ID: {parameter_node['id']}")
print(f"Parameter Name: {parameter_node.get('name', 'N/A')}")
# Example with default limit
all_params = get_lims_testparameters_with_references_parameters_lims_parameters(
source_id='TP002'
)
Best Practices
- Ensure the source_id exists in the database before calling this function to avoid empty results
- Adjust the limit parameter based on expected result size to optimize query performance
- Handle empty result sets gracefully in calling code
- Consider adding error handling for database connection issues
- Validate that the run_query function is properly configured with Neo4j connection details
- Use appropriate indexes on the 'id' property of LIMS_Testparameters nodes for better query performance
- Consider pagination for large result sets by calling the function multiple times with different offsets if needed
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_lims_testparameters_with_references_tests_lims_tests 95.1% similar
-
function get_lims_sampletestresults_with_references_testparameters_lims_testparameters 93.2% similar
-
function get_lims_parameters_with_references_parameters_lims_parameters 92.5% similar
-
function get_all_lims_testparameters 85.1% similar
-
function get_all_lims_parameters 82.8% similar