function get_all_lims_sampletypeproperties
Queries a Neo4j graph database to retrieve LIMS_SampleTypeProperties nodes with a configurable limit on the number of results returned.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
256 - 263
simple
Purpose
This function is designed to fetch sample type property records from a Laboratory Information Management System (LIMS) stored in a Neo4j graph database. It's useful for retrieving metadata about different sample types and their associated properties. The function allows controlling the number of results returned to manage memory and performance when dealing with large datasets.
Source Code
def get_all_lims_sampletypeproperties(limit=100):
"""Return LIMS_SampleTypeProperties nodes (limited to 25)"""
query = """
MATCH (n:LIMS_SampleTypeProperties)
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_SampleTypeProperties nodes to return from the database. Default is 100. Note: The docstring incorrectly states the limit is 25, but the actual default parameter value is 100. This parameter helps prevent overwhelming the system with too many results and allows for pagination-style data retrieval.
Return Value
Returns the result of the run_query function, which typically returns a list of Neo4j node records matching the LIMS_SampleTypeProperties 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. If no nodes are found, it would return an empty list or collection.
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 records
results = get_all_lims_sampletypeproperties()
for record in results:
print(record['n'])
# Example 2: Get only 10 records
results = get_all_lims_sampletypeproperties(limit=10)
for record in results:
node = record['n']
print(f"Node properties: {dict(node)}")
# Example 3: Get all records (use with caution)
results = get_all_lims_sampletypeproperties(limit=10000)
Best Practices
- The docstring contains incorrect information (states limit is 25 but default is 100) - this should be corrected for clarity
- Always use the limit parameter appropriately to avoid memory issues with large datasets
- Ensure the run_query function properly handles database connections and error cases
- Consider implementing pagination for large datasets rather than increasing the limit to very high values
- Validate that the Neo4j database connection is established before calling this function
- Consider adding error handling for cases where the database is unavailable or the query fails
- The function depends on run_query being defined elsewhere - ensure this dependency is available in your codebase
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_all_lims_sampletypes 92.0% similar
-
function get_all_lims_sampletypetests 87.7% similar
-
function get_lims_sampletypeproperties_by_id 87.5% similar
-
function get_all_lims_samples 86.5% similar
-
function get_all_lims_sampletestresults 83.4% similar