Interacting with Neo4j

BioCypher development was initially centred around a Neo4j graph database output due to the migration of OmniPath to a Neo4j backend. Importantly, we understand BioCypher as an abstration of the build process of a biomedical knowledge graph, and thus are open towards any output format for the knowledge representation. We are currently working on other output formats, such as RDF, SQL, and ArangoDB, and will update the documentation accordingly. In the following section, we give an overview of interacting with Neo4j from the perspective of BioCypher, but we refer the reader to the Neo4j documentation for more details.


We use the APOC library for Neo4j, which is not included automatically, but needs to be installed as a plugin to the DMBS. For more information, please refer to the APOC documentation.

Communication via the Neo4j Python Driver

BioCypher provides a Python driver for interacting with Neo4j, which is accessed through the BioCypher class when setting offline to False. More details can be found in the API docs.

If there exists no BioCypher graph in the currently active database, or if the user explicitly specifies so using the wipe attribute of the driver, a new BioCypher database is created using the schema configuration specified in the schema-config.yaml.

Exporting for the neo4j-admin import feature

Particularly if the data are very extensive (or performance is of the utmost priority), BioCypher can be used to facilitate a speedy and safe import of the data using the neo4j-admin import console command. Admin Import is a particularly fast method of writing data to a newly created graph database (the database needs to be completely empty) that gains most of its performance advantage from turning off safety features regarding input data consistency. Therefore, a sound and consistent representation of the nodes and edges in the graph is of high importance in this process, which is why the BioCypher export functionality has been specifically designed to perform type and content checking for all data to be written to the graph.

Data input from the source database is exactly as in the case of interacting with a running database, with the data representation being converted to a series of CSV files in a designated output folder (standard being biocypher-out/ and the current datetime). BioCypher creates separate header and data files for all node and edge types to be represented in the graph. Additionally, it creates a file called neo4j-admin-import-call.txt containing the console command for creating a new database, which only has to be executed from the directory of the currently running Neo4j database.

The name of the database to be created is given by the db_name setting, and can be arbitrary. In case the db_name is not the default Neo4j database name, neo4j, the database needs to be created in Neo4j before or after using the neo4j-admin import statement. This can be done by executing, in the running database (<db_name> being the name assigned in the method):

  1. :use system

  2. create database <db_name>

  3. :use <db_name>

Tutorial - Neo4j

After writing knowledge graph files with BioCypher in offline mode for the Neo4j DBMS (database management system), the graph can now be imported into Neo4j using the neo4j-admin command line tool. This is not necessary if the graph is created in online mode. For convenience, BioCypher provides the command line call required to import the data into Neo4j:


This creates an executable shell script in the output directory that can be executed from the location of the database folder (or copied into the Neo4j terminal) to import the graph into Neo4j. Since BioCypher creates separate header and data files for each entity type, the import call conveniently aggregates this information into one command, detailing the location of all files on disk, so no data need to be copied around.


The generated import call is currently only compatible with Neo4j version 4. Version 5 support coming soon!

Neo4j can manage multiple projects, each with multiple DBMS (database management system) instances, each of which can house multiple databases. The screenshot below shows a project managed by Neo4j Desktop (project name “BioCypher”) containing a DBMS instance (called “Test DBMS”) with multiple named databases in it: the non-removable “system” DB, the default “neo4j” DB, and several user-created databases.

Neo4j Desktop

Crucially, the import call generated by BioCypher needs to be executed by the neo4j-admin binary in the DBMS folder (in the bin/ directory of the root of the DBMS folder). The DBMS folder is the folder that contains the data/ directory, which in turn contains the databases/ folder, which is where the graph data is stored in individual folders corresponding to the DB names in the DBMS. On Neo4j Desktop, you can open a terminal at the DBMS root location by clicking on the three dots next to the DBMS name and selecting “Terminal” (see screenshot below).

Neo4j Desktop

Since the import call should be executed in the root of the DMBS folder, BioCypher generates the import call starting with bin/neo4j-admin, which can be copied into the terminal opened at the DBMS root location. For other operating systems and Neo4j installations (e.g. in Docker containers), please refer to the Neo4j documentation to find the correct location of your DMBS. We are working on extensions of the BioCypher process to improve interoperability with Neo4j as well as other storage systems.


Neo4j provide a Neo4j Desktop application that can be used to create a local instance of Neo4j. The desktop application provides information about the DBMS folder and can open a terminal at the DBMS root location. The import call generated by BioCypher can then be copied into the terminal of the Neo4j Desktop application for each corresponding DBMS.

Neo4j is also available as a command line interface (CLI) tool. To use the CLI with the BioCypher admin import call, directory structures and permissions need to be set up correctly. The Neo4j CLI tool can be downloaded from the Neo4j download center. Please follow the Neo4j documentation for correct setup and usage on your system.

Be mindful that different versions of Neo4j may differ in features and thus are also documented differently.