Skip to content

Commit c220b8c

Browse files
committed
add label for separating direct and indirect is-a relations
1 parent 0c72c69 commit c220b8c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

chebifier/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def build_chebi_graph(chebi_version=241):
9797
# Only take the edges which connect the existing nodes, to avoid internal creation of obsolete nodes
9898
# https://github.com/ChEB-AI/python-chebai/pull/55#issuecomment-2386654142
9999
g.add_edges_from(
100-
[(p, q["id"]) for q in elements for p in q["parents"] if g.has_node(p)]
100+
[(p, q["id"]) for q in elements for p in q["parents"] if g.has_node(p)],
101+
label="direct_child",
101102
)
102103
return nx.transitive_closure_dag(g)
103104

@@ -153,3 +154,12 @@ def process_config(config, model_registry):
153154
else:
154155
new_config[model_name] = entry
155156
return new_config
157+
158+
159+
if __name__ == "__main__":
160+
chebi_graph = build_chebi_graph(chebi_version=244)
161+
os.makedirs(os.path.join("data", "chebi_v244"), exist_ok=True)
162+
pickle.dump(
163+
chebi_graph,
164+
open(os.path.join("data", "chebi_v244", "chebi_graph.pkl"), "wb"),
165+
)

0 commit comments

Comments
 (0)