🔍 Code Extractor

function get_all_lims_parameters

Maturity: 41

Queries a Neo4j graph database to retrieve all nodes labeled as LIMS_Parameters, with a configurable limit on the number of results returned.

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
61 - 68
Complexity:
simple

Purpose

This function is designed to fetch LIMS (Laboratory Information Management System) parameter nodes from a Neo4j graph database. It's useful for retrieving configuration or metadata about laboratory parameters stored in the graph database. The function uses Cypher query language to match and return nodes, making it suitable for applications that need to access or display LIMS parameter information.

Source Code

def get_all_lims_parameters(limit=100):
    """Return LIMS_Parameters nodes (limited to 25)"""
    query = """
    MATCH (n:LIMS_Parameters)
    RETURN n
    LIMIT $limit
    """
    return run_query(query, {"limit": limit})

Parameters

Name Type Default Kind
limit - 100 positional_or_keyword

Parameter Details

limit: An integer that specifies the maximum number of LIMS_Parameters nodes to return from the database. Default value is 100. Note: The docstring incorrectly states the limit is 25, but the actual default is 100. This parameter helps prevent overwhelming queries on large databases and controls result set size.

Return Value

Returns the result of the run_query function execution, which typically contains a list or collection of Neo4j node objects with the LIMS_Parameters label. 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 node properties. The number of results is capped by the limit parameter.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

# Assuming run_query is defined and Neo4j connection is configured
# Example run_query implementation:
from neo4j import GraphDatabase

driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'password'))

def run_query(query, params):
    with driver.session() as session:
        result = session.run(query, params)
        return [record['n'] for record in result]

# Using get_all_lims_parameters
results = get_all_lims_parameters(limit=50)
for node in results:
    print(node)

# Get default 100 results
all_params = get_all_lims_parameters()

# Get only 10 results
few_params = get_all_lims_parameters(limit=10)

Best Practices

  • The docstring contains incorrect information (states limit is 25 but default is 100) - this should be corrected for clarity
  • Ensure the run_query function properly handles database connection errors and exceptions
  • Consider adding error handling for cases where the database connection fails or the query returns no results
  • The limit parameter should be validated to ensure it's a positive integer to prevent invalid queries
  • Consider adding type hints for better code documentation (e.g., def get_all_lims_parameters(limit: int = 100) -> list)
  • Ensure proper database connection cleanup is handled in the run_query implementation
  • For production use, consider adding pagination support for very large result sets
  • Document the expected structure of LIMS_Parameters nodes for users of this function

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_all_lims_testparameters 94.1% similar

    Retrieves LIMS_Testparameters nodes from a Neo4j graph database with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_samples 87.9% similar

    Queries a Neo4j graph database to retrieve LIMS_Samples nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_requests 87.7% similar

    Queries a Neo4j graph database to retrieve LIMS_Requests nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_parameters_with_references_parameters_lims_parameters 86.5% similar

    Retrieves LIMS_Parameters nodes from a Neo4j graph database that are connected to a source LIMS_Parameters node via REFERENCES_PARAMETERS relationships.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_tests 86.2% similar

    Queries a Neo4j graph database to retrieve LIMS_Tests nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
← Back to Browse