-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding dump-graph to cli (#18)
- Loading branch information
Showing
5 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Helpers for inspection models""" | ||
|
||
import pickle | ||
|
||
import networkx as nx | ||
|
||
from cada_prio.predict import load_hgnc_info | ||
|
||
|
||
def dump_graph(path_graph: str, path_hgnc_info: str): | ||
_, hgnc_info_by_id = load_hgnc_info(path_hgnc_info) | ||
with open(path_graph, "rb") as inputf: | ||
graph: nx.Graph = pickle.load(inputf) | ||
for edge in sorted(graph.edges): | ||
lhs, rhs = edge | ||
if lhs.startswith("HGNC:"): | ||
lhs = "Entrez:%s" % hgnc_info_by_id[lhs].ncbi_gene_id | ||
if rhs.startswith("HGNC:"): | ||
rhs = "Entrez:%s" % hgnc_info_by_id[rhs].ncbi_gene_id | ||
print(f"{lhs}\t{rhs}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters