Skip to content

Commit

Permalink
Make adding the graph to docker simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
nanglo123 committed Sep 19, 2024
1 parent d3a641a commit eae0588
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ RUN wget -O /sw/nodes.tsv.gz https://askem-mira.s3.amazonaws.com/dkg/$domain/bui
sed -i 's/#dbms.security.auth_enabled/dbms.security.auth_enabled/' /etc/neo4j/neo4j.conf && \
neo4j-admin import --delimiter='TAB' --skip-duplicate-nodes=true --skip-bad-relationships=true --nodes /sw/nodes.tsv.gz --relationships /sw/edges.tsv.gz

COPY generate_obo_graphs.py /sw/generate_obo_graphs.py
# Python packages
RUN python -m pip install --upgrade pip && \
python -m pip install git+https://github.com/gyorilab/mira.git@main#egg=mira[web,uvicorn,dkg-client,dkg-construct] && \
Expand All @@ -40,9 +39,10 @@ RUN python -m pip install --upgrade pip && \
python -m pip install --no-dependencies "lxml>=4.6.4" && \
python -m pip install --no-dependencies --ignore-requires-python sbmlmath

RUN python -m mira.dkg.generate_obo_graphs

# Copy the example json for reconstructing the ode semantics
RUN wget -O /sw/sir_flux_span.json https://raw.githubusercontent.com/gyorilab/mira/main/tests/sir_flux_span.json

RUN mkdir -p /graphs
COPY startup.sh startup.sh
ENTRYPOINT ["/bin/bash", "/sw/startup.sh"]
7 changes: 0 additions & 7 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ docker run -p 8771:8771 -p 7687:7687 -e MIRA_NEO4J_URL=bolt://0.0.0.0:7687 mira:

This exposes a REST API at `http://localhost:8771`. This also exposes Neo4j's bolt port at port 7687.


Running the `build_run_docker.sh` script builds the docker image,
create directory `docker/mounted_graph_storage` to store the pickled obo
graphs, and start the container. When you first run the script and
start the container, it will take a few minutes to generate and store the
pickled graphs.

## MIRA Metaregistry

The MIRA metaregistry contains the prefixes and their associated metadata for all use cases.
Expand Down
5 changes: 0 additions & 5 deletions docker/build_run_docker.sh

This file was deleted.

8 changes: 4 additions & 4 deletions mira/dkg/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ def extract_ontology_subtree(curie: str, add_subtree: bool = False):
resource_prefix = curie.split(":")[0]
if resource_prefix == "ncbitaxon":
type = "class"
cached_relabeled_obo_graph_path = (Path(__file__).resolve().parents[2]
/ "docker" /
"mounted_graph_storage" /
"ncbitaxon_obo_graph.pkl")
version = get_version(resource_prefix)
cached_relabeled_obo_graph_path = prefix_directory_join(resource_prefix,
name="relabeled_obo_graph.pkl",
version=version)

with open(cached_relabeled_obo_graph_path,'rb') as relabeled_graph_file:
relabeled_graph = pickle.load(relabeled_graph_file)
Expand Down
34 changes: 34 additions & 0 deletions mira/dkg/generate_obo_graphs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pyobo import get_version
from pyobo.getters import _ensure_ontology_path
from pyobo.utils.path import prefix_directory_join
from obonet import read_obo
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 = prefix_directory_join(resource_prefix,
name="relabeled_obo_graph.pkl",
version=version)
if not cached_relabeled_obo_graph_path.exists():
_, 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:
pickle.dump(relabeled_graph, relabeled_graph_file)


if __name__ == "__main__":
download_convert_ncbitaxon_obo_to_graph()

0 comments on commit eae0588

Please sign in to comment.