Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a3a1660
fix test error
yjzhang Apr 29, 2026
9252844
Merge branch 'NCATSTranslator:main' into main
yjzhang Apr 30, 2026
afffeee
adding scoring to pathfinder output
yjzhang Apr 30, 2026
43df311
add nodes to TCT_pathfinder
yjzhang May 1, 2026
384c56a
start on neighborhood finder
yjzhang May 1, 2026
d712fe3
neighborhood finder - new output type
yjzhang May 1, 2026
3b097a9
removed extraneous function
yjzhang May 1, 2026
2ffe87d
consolidated some duplicate functions
yjzhang May 1, 2026
e6ff218
Merge branch 'NCATSTranslator:main' into main
yjzhang May 1, 2026
2b8d4dd
renamed file
yjzhang May 7, 2026
85e0fa3
Merge branch 'NCATSTranslator:main' into main
yjzhang May 14, 2026
83261b0
add attribute constraints to translator_query.build_query_json
yjzhang May 18, 2026
856fdb1
merged
yjzhang May 18, 2026
031bd2f
Merge branch 'NCATSTranslator:main' into main
yjzhang May 19, 2026
f135e79
testing queries with constraints
yjzhang May 21, 2026
f1de54a
notebook for queries with constraints
yjzhang May 22, 2026
c188e40
neighborhood finder with constraints
yjzhang May 23, 2026
cff0467
update docs to include neighborhood/pathfinder
yjzhang May 28, 2026
0c00041
notebook
yjzhang May 28, 2026
4a87c87
queries with constraints, updating docs
yjzhang May 29, 2026
715ab9f
Merge branch 'NCATSTranslator:main' into main
yjzhang Jun 1, 2026
1c4727f
fixed some potential bugs with neighborhood finder
yjzhang Jun 2, 2026
30ab2f4
Merge branch 'main' of https://github.com/yjzhang/Translator_componen…
yjzhang Jun 2, 2026
471c8a0
working on updating the metakg query...
yjzhang Jun 2, 2026
ce5e739
working on updating the metakg query...
yjzhang Jun 2, 2026
33114e6
add new metakg api url
yjzhang Jun 2, 2026
f8ea041
metakg stuff
yjzhang Jun 2, 2026
3cb26e8
using new metaKG URL
yjzhang Jun 3, 2026
3be3ad1
remove json files from codespell checks
yjzhang Jun 3, 2026
eac06e5
merged
yjzhang Jun 4, 2026
7f2ca92
merged
yjzhang Jun 4, 2026
1cc8355
Merge branch 'NCATSTranslator:main' into main
yjzhang Jun 8, 2026
62f2ba3
Merge branch 'NCATSTranslator:main' into main
yjzhang Jun 11, 2026
eed4b91
neighborhood finder with multiple input nodes
yjzhang Jun 19, 2026
cd3aa5c
Merge branch 'NCATSTranslator:main' into main
yjzhang Jun 25, 2026
f94ac70
Merge branch 'NCATSTranslator:main' into main
yjzhang Jul 7, 2026
65cb46b
Merge branch 'NCATSTranslator:main' into main
yjzhang Jul 7, 2026
7dffc25
Merge branch 'NCATSTranslator:main' into main
yjzhang Jul 7, 2026
18ab874
remove certain requirements
yjzhang Jul 7, 2026
b07e6fb
restore requirements
yjzhang Jul 7, 2026
f65f805
fix typo, fix docs
yjzhang Jul 7, 2026
4526777
fix typos
yjzhang Jul 7, 2026
f1a6632
move ipycytoscape imports to inside function
yjzhang Jul 7, 2026
9570fc0
fix docstring formatting
yjzhang Jul 7, 2026
ead1cd1
Merge branch 'NCATSTranslator:main' into main
yjzhang Jul 7, 2026
5307006
updated docstrings
yjzhang Jul 7, 2026
414dccf
update docstrings
yjzhang Jul 7, 2026
a5d9086
docstring examples
yjzhang Jul 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 29 additions & 32 deletions TCT/TCT_neighborhood_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,41 +195,39 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred

Parameters
----------
input_node (str)
input_node : str
The input node - should be a CURIE id.
node2_categories (list)
node2_categories : list
A list of intermediate categories to be used in the neighborhood finding process.
APInames (dict)
APInames : dict
A dictionary containing the names of the APIs to be used.
metaKG (DataFrame)
metaKG : DataFrame
The metadata knowledge graph containing information about the APIs and their predicates.
API_predicates (dict)
API_predicates : dict
A dictionary containing the predicates for each API.
input_node_category (list)
input_node_category : list
Optional. A list of categories for the input node. If empty, it will be derived from the input node's types.
attribute_constraints (list)
attribute_constraints : list
Optional. List of outputs of translator_query.build_attribute_constraint

Returns
--------------
input_node_id (str)
-------
input_node_id : str
The curie id of the input node.
result (dict)
result : dict
The result of the query for the input node.
result_parsed (DataFrame)
result_parsed : DataFrame
The parsed results for the input node.
result_ranked_by_primary_infores (DataFrame)
result_ranked_by_primary_infores : DataFrame
The ranked results based on primary infores.

--------------
Example:
Examples
--------
>>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer
node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'],
APInames = APInames,
metaKG = metaKG,
API_predicates = API_predicates)
--------------

"""
from . import node_normalizer
from . import translator_query
Expand Down Expand Up @@ -291,23 +289,23 @@ def neighborhood_finder_multiple_inputs(input_nodes:list[str], node2_categories:

Parameters
----------
input_nodes (list[str])
input_nodes : list[str]
The input nodes - should be a list of CURIE ids.
node2_categories (list)
node2_categories : list
A list of intermediate categories to be used in the neighborhood finding process.
APInames (dict)
APInames : dict
A dictionary containing the names of the APIs to be used.
metaKG (DataFrame)
metaKG : DataFrame
The metadata knowledge graph containing information about the APIs and their predicates.
API_predicates (dict)
API_predicates : dict
A dictionary containing the predicates for each API.
input_node_category (list)
input_node_category : list
Optional. A list of categories for the input node. If empty, it will be derived from the input node's types.
attribute_constraints (list)
attribute_constraints : list
Optional. List of outputs of translator_query.build_attribute_constraint

Returns
--------------
-------
input_node_id (str)
The curie id of the input node.
result (dict)
Expand All @@ -317,15 +315,14 @@ def neighborhood_finder_multiple_inputs(input_nodes:list[str], node2_categories:
result_ranked_by_primary_infores (DataFrame)
The ranked results based on primary infores.

--------------
Example:
>>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer
node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'],
APInames = APInames,
metaKG = metaKG,
API_predicates = API_predicates)
--------------

Examples
--------
>>> result, result_parsed = neighborhood_finder_multiple_inputs(['NCBIGene:6774', 'NCBIGene:4170', 'NCBIGene:4792'],
node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'],
APInames = APInames,
metaKG = metaKG,
API_predicates = API_predicates)
"""
from . import node_normalizer
from . import translator_query
Expand Down
35 changes: 15 additions & 20 deletions TCT/TCT_network_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,36 +175,31 @@ def get_connected_graph(result_parsed, input_identifiers):

Parameters
----------
result_parsed (dict)
result_parsed : dict
The parsed results for results from TCT_neighborhood_finder.neighborhood_finder_multiple_inputs().
input_identifiers (list)
input_identifiers : list
A list of input node identifiers, which are also input for TCT_neighborhood_finder.neighborhood_finder_multiple_inputs().

Returns
--------------
result_parsed (dict)
-------
result_parsed : dict
The connected graph extracted from the parsed results.

--------------
Example:
>>>
input_identifiers = ['NCBIGene:6774', 'NCBIGene:4170','NCBIGene:4792','NCBIGene:4288','NCBIGene:596','NCBIGene:581','NCBIGene:836','NCBIGene:6777','NCBIGene:4790','NCBIGene:545']

result, result_parsed = TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(input_identifiers,
Examples
--------
>>> input_identifiers = ['NCBIGene:6774', 'NCBIGene:4170','NCBIGene:4792','NCBIGene:4288','NCBIGene:596','NCBIGene:581','NCBIGene:836','NCBIGene:6777','NCBIGene:4790','NCBIGene:545']
>>> result, result_parsed = TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(input_identifiers,
node2_categories = ['biolink:Gene','biolink:Protein'],
APInames = APInames,
metaKG = metaKG,
API_predicates = API_predicates)

result = TCT_network_annotator.get_connected_graph(result_parsed, input_identifiers)
import datetime
import json
timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
with open('./PathFinder_testing_results/'+'TCT_neighborhood_finder_result_'+'_'+timestamp+'.json', 'w') as f:
json.dump(result, f)
# visualize the result using the TCT visualization tool (https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/notebooks/visulize_path_finder_results.html).
--------------

>>> result = TCT_network_annotator.get_connected_graph(result_parsed, input_identifiers)
>>> import datetime
>>> import json
>>> timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
>>> with open('./PathFinder_testing_results/'+'TCT_neighborhood_finder_result_'+'_'+timestamp+'.json', 'w') as f:
>>> json.dump(result, f)
>>> # visualize the result using the TCT visualization tool (https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/notebooks/visulize_path_finder_results.html).
"""

result_parsed_copy = result_parsed.copy()
Expand Down
19 changes: 10 additions & 9 deletions TCT/TCT_pathfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ def format_query_json_for_pathfinder_with_constraints(subject_ids,
a list of predicates for the edge between subject and object nodes
constraints : list
a list of intermediate categories for the pathfinder pipeline, currently only one intermediate category is allowed in the constraints list.

Returns
-------
query_json_temp : dict
a query json for pathfinder pipeline

Example
-------
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']
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'])
"""
if constraints is None or len(constraints) == 0:
constraints_intermediate_category = None
Expand Down
Loading