Skip to content

Commit

Permalink
Format file
Browse files Browse the repository at this point in the history
  • Loading branch information
nanglo123 committed Sep 19, 2024
1 parent a6a21c3 commit d3a641a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docker/generate_obo_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@
import networkx
import pickle


def download_convert_ncbitaxon_obo_to_graph():
resource_prefix = "ncbitaxon"
version = get_version(resource_prefix)

# Checks to see if the pickled ncbitaxon obo graph exists in the container
cached_relabeled_obo_graph_path = Path("/graphs/ncbitaxon_obo_graph.pkl")
if not cached_relabeled_obo_graph_path.exists():
_, obo_path = _ensure_ontology_path(resource_prefix, force=False,
version=version)
_, obo_path = _ensure_ontology_path(
resource_prefix, force=False, version=version
)
obo_graph = read_obo(obo_path)

# Normalize node indices
relabeled_graph = networkx.relabel_nodes(obo_graph,
lambda node_index:
node_index.lower())
with open(cached_relabeled_obo_graph_path,
'wb') as relabeled_graph_file:
relabeled_graph = networkx.relabel_nodes(
obo_graph, lambda node_index: node_index.lower()
)
with open(
cached_relabeled_obo_graph_path, "wb"
) as relabeled_graph_file:
pickle.dump(relabeled_graph, relabeled_graph_file)


if __name__ == "__main__":
download_convert_ncbitaxon_obo_to_graph()

0 comments on commit d3a641a

Please sign in to comment.