TCT.TCT_neighborhood_finder¶
- TCT.TCT_neighborhood_finder.neighborhood_finder(node: str | list[str], neighbor_categories: list[str], *, node_categories: list[str] | None = None, api_names: dict[str, str] | None = None, meta_kg: DataFrame | None = None, api_predicates: dict[str, list[str]] | None = None, resources: TranslatorResources | None = None, predicates_subset: list[str] | None = None, attribute_constraints: list[dict[str, Any]] | None = None, name_resolver_kwargs: dict[str, Any] | None = None, node_normalizer_kwargs: dict[str, Any] | None = None) FinderResult[source]¶
Find one-hop neighbors for one or more biomedical concepts.
- Parameters:
- nodestr or list[str]
Source node or nodes. Each value may be a CURIE or human-readable string. Human-readable strings are resolved with Name Resolver and then normalized with Node Normalizer.
- neighbor_categorieslist[str]
Desired neighbor categories. Values may be short names like
"Drug"or full Biolink names like"biolink:Drug".- node_categorieslist[str], optional
Category override for source nodes. If omitted, categories are inferred from the first normalized source node.
- resourcesTranslatorResources, optional
Preloaded Translator resources. If omitted, the module-level singleton is loaded on first use and reused.
- api_names, meta_kg, api_predicatesoptional
Advanced partial overrides for the Translator resources used by the neighborhood implementation.
- predicates_subsetlist[str], optional
Optional predicate filter applied after MetaKG predicate selection.
- attribute_constraintslist[dict], optional
TRAPI attribute constraints passed through to query construction.
- name_resolver_kwargsdict, optional
Extra keyword arguments for
name_resolver.lookup.- node_normalizer_kwargsdict, optional
Extra keyword arguments for
node_normalizer.get_normalized_nodes.
- Returns:
- FinderResult
Convenience wrapper containing resolved input nodes, parsed neighborhood knowledge graph, results, auxiliary graphs, and raw TRAPI-style output.
Examples
>>> from TCT import neighborhood_finder >>> result = neighborhood_finder("asthma", ["SmallMolecule", "Drug"]) >>> result.knowledge_graph["nodes"] {...}
- TCT.TCT_neighborhood_finder.parse_results_for_neighborhood_finder(start_node_id: str, results: dict, start_node_categories: list | None = None, end_node_categories: list | None = None, get_node_info: bool = True, scoring_method: str = 'infores') dict[source]¶
Converts the results of two TRAPI queries into the same general json format as the other pathfinder APIs.
- Returns:
- A dict of the format {‘query_graph’: …, ‘knowledge_graph’: …, ‘results’:, ‘auxiliary_graphs’:…}
- TCT.TCT_neighborhood_finder.parse_results_for_neighborhood_finder_multiple_inputs(start_node_ids: list[str], results: dict, start_node_categories: list | None = None, end_node_categories: list | None = None, get_node_info: bool = True, scoring_method: str = 'infores') dict[source]¶
Converts the results of two TRAPI queries into the same general json format as the other pathfinder APIs. scoring_method is how the node scores are generated, and could be ‘infores’ or ‘edges’.