TCT.TCT_pathfinder

TCT.TCT_pathfinder.build_query_graph(start_node_id: str, end_node_id: str, start_node_categories=None, end_node_categories=None, constraints_path=None)[source]

start_node_categories and end_node_categories are lists of categories.

TCT.TCT_pathfinder.format_pathfinder_query(node1_id: str, node1_category: str, node2_id: str, node2_category: str) dict[source]

Formats a query to the Pathfinder API.

Returns:
A dict formatted as a JSON query to the Pathfinder API.
TCT.TCT_pathfinder.format_query_json_for_pathfinder_with_constraints(subject_ids: str, object_ids: str, subject_categories=None, object_categories=None, predicates=None, constraints=None) dict[source]

Format user’s input into a query json for pathfinder pipeline with constraints on the intermediate node categories.

Parameters:
subject_idsstr

a curie id for the subject node

object_idsstr

a curie id for the object node

subject_categorieslist

a list of categories for the subject node

object_categorieslist

a list of categories for the object node

predicateslist

a list of predicates for the edge between subject and object nodes

constraintslist

a list of intermediate categories for the pathfinder pipeline, currently only one intermediate category is allowed in the constraints list.

Returns:
query_json_tempdict

a query json for pathfinder pipeline

Examples

>>> query_json_temp = format_query_json_for_pathfinder_with_constraints(
    subject_ids='NCBIGene:6774',
    object_ids='NCBIGene:4170',
    subject_categories=['biolink:Gene'],
    object_categories=['biolink:Gene'],
    predicates=['biolink:related_to'],
    constraints=['biolink:Protein'])
TCT.TCT_pathfinder.generate_score_results(results: dict, method='infores')[source]

Generates a score dict, and a list of “analyses”. method can be ‘infores’ or ‘edges’

TCT.TCT_pathfinder.parse_results_for_pathfinder(start_node_id: str, end_node_id: str, result1: dict, result2: dict, start_node_categories=None, end_node_categories=None, get_node_info=True, scoring_method='infores')[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’.

TCT.TCT_pathfinder.query_TCT_pathfinder(start: str, end: str, intermediate_categories: list[str], *, start_categories: list[str] | None = None, end_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, scoring_method: str = 'infores', name_resolver_kwargs: dict[str, Any] | None = None, node_normalizer_kwargs: dict[str, Any] | None = None) FinderResult[source]

Find paths between two biomedical concepts using Translator KPs.

Parameters:
startstr

Start node as either a CURIE (for example, "MONDO:0004979") or a human-readable string (for example, "asthma").

endstr

End node as either a CURIE or human-readable string.

intermediate_categorieslist[str]

Allowed categories for intermediate path nodes. Values may be short names like "Gene" or full Biolink names like "biolink:Gene".

start_categorieslist[str], optional

Category override for the start node. If omitted, categories are inferred from Node Normalizer.

end_categorieslist[str], optional

Category override for the end node. If omitted, categories are inferred from Node Normalizer.

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 pathfinder implementation.

scoring_methodstr

Scoring method passed to the legacy parser. Current values are "infores" and "edges".

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, the parsed knowledge graph, results, auxiliary graphs, and the raw TRAPI-style output dictionary.

Examples

>>> from TCT import query_TCT_pathfinder
>>> result = query_TCT_pathfinder("asthma", "albuterol", ["Gene"])
>>> result.resolved_nodes["start"].curie
'MONDO:0004979'
TCT.TCT_pathfinder.query_aragorn_pathfinder(node1_id: str, node1_category: str, node2_id: str, node2_category: str) str[source]

This queries the ARAGORN Pathfinder API.

Returns:
A string (which should be a JSON) representing the result of an ARAGORN pathfinder query.
TCT.TCT_pathfinder.query_aragorn_pathfinder_with_constraints(node1_id: str, node1_category: str, node2_id: str, node2_category: str, constraints: list) str[source]

This queries the ARAGORN Pathfinder API with a list of constraints.

Returns:
A string (which should be a JSON) representing the result of an ARAGORN pathfinder query.
TCT.TCT_pathfinder.query_arax_pathfinder(node1_id: str, node1_category: str, node2_id: str, node2_category: str) str[source]

This queries the ARAX Pathfinder API.

Returns:
A string (which should be a JSON) representing the result of an ARAX pathfinder query.
TCT.TCT_pathfinder.query_arax_pathfinder_with_constraints(node1_id: str, node1_category: str, node2_id: str, node2_category: str, constraints: list) str[source]

This queries the ARAX Pathfinder API with a list of constraints.

Returns:
A string (which should be a JSON) representing the result of an ARAX pathfinder query.