write_neo4j
- write_neo4j(mappings: Iterable[Mapping], directory: str | Path, *, docker_name: str | None = None, equivalence_classes: dict[NormalizedNamableReference, bool] | None = None, add_labels: bool = False, startup_script_name: str = 'startup.sh', run_script_name: str = 'run_on_docker.sh', dockerfile_name: str = 'Dockerfile', pip_install: str = 'semra[web] @ git+https://github.com/biopragmatics/semra.git', use_tqdm: bool = True, compress: None | Literal['during', 'after'] = None) None[source]
Write all files needed to construct a Neo4j graph database from a set of mappings.
- Parameters:
mappings – A list of semantic mappings
directory – The directory to write nodes files, edge files, startup shell script (
startup.sh), run script (run_on_docker.sh), and a Dockerfiledocker_name – The name of the Docker image. Defaults to “semra”
equivalence_classes –
A dictionary from references to booleans, where having
Trueas a value denotes that it is the “primary” reference calculated from processed and prioritiized mappings.This argument is typically used internally - you should not have to pass it yourself.
equivalence_classes = _get_equivalence_classes(processed_mappings, prioritized_mappings)
add_labels – Should labels be looked up for concepts in the database and added? Defaults to false. If set to true, note that this relies on PyOBO to download and parse potentially many large resources.
startup_script_name – The name of the startup script that the Dockerfile calls
run_script_name – The name of the run script that you as the user should call to wrap building and running the Docker image
dockerfile_name – The name of the Dockerfile produced
pip_install – The package that’s pip installed in the docker file
You can use this function to build your own database like in
from semra.io import from_pyobo, write_neo4j mappings = [*from_pyobo("doid"), *from_pyobo("mesh")] path = "~/Desktop/disease_output/" # assume this exist already write_neo4j(mappings, path)
Then, you can run from your shell:
cd ~/Desktop/disease_output/ sh run_on_docker.sh
Finally, you can navigate to the Neo4j frontend at http://localhost:7474, to the SeMRA web frontend at http://localhost:8773, or to the SeMRA JSON API at http://localhost:8773/api.