🔍 Code Extractor

function get_lims_samples_with_references_establishment_dbo_establishment

Maturity: 40

Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific LIMS_Samples node through a REFERENCES_ESTABLISHMENT relationship.

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
1481 - 1488
Complexity:
simple

Purpose

This function is designed to traverse a graph database to find establishment records referenced by laboratory information management system (LIMS) samples. It's useful for tracking which establishments are associated with specific laboratory samples, enabling data lineage and relationship analysis in laboratory data management systems.

Source Code

def get_lims_samples_with_references_establishment_dbo_establishment(source_id, limit=100):
    """Get dbo_Establishment nodes connected to a LIMS_Samples via REFERENCES_ESTABLISHMENT"""
    query = """
    MATCH (source:LIMS_Samples {id: $source_id})-[r:REFERENCES_ESTABLISHMENT]->(target:dbo_Establishment)
    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 of the LIMS_Samples node to query from. This should be a string or value that matches the 'id' property of a LIMS_Samples node in the Neo4j database.

limit: Maximum number of dbo_Establishment nodes to return. Defaults to 100. This parameter controls query performance and result set size. Must be a positive integer.

Return Value

Returns the result of the Neo4j query execution via the run_query function. The exact return type depends on the run_query implementation, but typically returns a list of records containing dbo_Establishment nodes with their properties, or an empty list if no matching establishments are found. Each record represents a target dbo_Establishment node connected to the source LIMS_Samples node.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

# Assuming run_query function 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['target'] for record in result]

# Use the function
sample_id = 'SAMPLE_12345'
establishments = get_lims_samples_with_references_establishment_dbo_establishment(sample_id, limit=50)

# Process results
for establishment in establishments:
    print(f"Establishment: {establishment}")

# Get all establishments (up to 100)
all_establishments = get_lims_samples_with_references_establishment_dbo_establishment('SAMPLE_67890')

Best Practices

  • Ensure the source_id parameter matches existing LIMS_Samples node IDs in the database 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 cases where the source_id doesn't exist
  • Use appropriate Neo4j indexes on the LIMS_Samples.id property for optimal query performance
  • Close Neo4j driver connections properly when done with queries to avoid resource leaks
  • Consider implementing pagination for large result sets instead of relying solely on the limit parameter

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_lims_requests_with_references_establishment_dbo_establishment 93.0% similar

    Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific LIMS_Requests node via a REFERENCES_ESTABLISHMENT relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function create_references_establishment_relationship_v1 85.5% similar

    Creates a REFERENCES_ESTABLISHMENT relationship in a Neo4j graph database between a LIMS_Samples node and a dbo_Establishment node, with optional properties on the relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function create_references_establishment_relationship 80.6% similar

    Creates a REFERENCES_ESTABLISHMENT relationship in a Neo4j graph database between a LIMS_Requests node and a dbo_Establishment node, with optional properties on the relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_samples_with_references_houses_dbo_houses 79.2% similar

    Retrieves dbo_Houses nodes from a Neo4j graph database that are connected to a specific LIMS_Samples node via REFERENCES_HOUSES relationships.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_dbo_establishmentcycles_with_references_establishment_dbo_establishment 78.2% similar

    Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific dbo_EstablishmentCycles node through a REFERENCES_ESTABLISHMENT relationship.

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