Skip to content

Commit

Permalink
split up neo4j dataload queries
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesamcl committed Nov 7, 2024
1 parent d948bf9 commit a998c7e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
21 changes: 0 additions & 21 deletions dataload/07_create_db/neo4j/create_indexes.cypher

This file was deleted.

11 changes: 11 additions & 0 deletions dataload/07_create_db/neo4j/cypher/create_indexes.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

CREATE INDEX node_id FOR (n:GraphNode) ON n.`grebi:nodeId`
;
CREATE INDEX subgraph FOR (n:GraphNode) ON n.`grebi:subgraph`
;
CREATE INDEX id_id FOR (n:Id) ON n.`id`
;
CREATE INDEX ic FOR (n:GraphNode) ON (n.ic)
;
CALL db.awaitIndexes(10800)
;
4 changes: 4 additions & 0 deletions dataload/07_create_db/neo4j/cypher/ic_scores_1.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MATCH (ancestor:`ols:Class`)<-[:`biolink:broad_match`*1..]-(subclass:`ols:Class`)
WITH ancestor, count(DISTINCT subclass) AS num_desc
SET ancestor.num_desc = num_desc
;
4 changes: 4 additions & 0 deletions dataload/07_create_db/neo4j/cypher/ic_scores_2.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WITH COLLECT { MATCH (cl:`ols:Class`) RETURN max(cl.num_desc) }[0] AS max_num_desc
MATCH (cl2:`ols:Class`)
SET cl2.ic = 1.0 - (cl2.num_desc/max_num_desc)
;
8 changes: 6 additions & 2 deletions dataload/07_create_db/neo4j/neo4j_import.dockersh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ sleep 20

echo Creating neo4j indexes...

cypher-shell -a neo4j://127.0.0.1:7687 --non-interactive -f /create_indexes.cypher
cypher-shell -a neo4j://127.0.0.1:7687 --non-interactive -f /cypher/ic_scores_1.cypher
sleep 20
cypher-shell -a neo4j://127.0.0.1:7687 --non-interactive -f /cypher/ic_scores_2.cypher
sleep 20
cypher-shell -a neo4j://127.0.0.1:7687 --non-interactive -f /cypher/create_indexes.cypher

echo Creating neo4j indexes done

sleep 5
sleep 20
neo4j stop

4 changes: 2 additions & 2 deletions dataload/07_create_db/neo4j/neo4j_import.slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main():
'--bind ' + shlex.quote(neo_data_path) + ':/data',
'--bind ' + shlex.quote(neo_logs_path) + ':/logs',
'--bind ' + os.path.abspath(os.path.join(os.environ['GREBI_HOME'], '07_create_db/neo4j/neo4j_import.dockersh')) + ':/import.sh',
'--bind ' + os.path.abspath(os.path.join(os.environ['GREBI_HOME'], '07_create_db/neo4j/create_indexes.cypher')) + ':/create_indexes.cypher',
'--bind ' + os.path.abspath(os.path.join(os.environ['GREBI_HOME'], '07_create_db/neo4j/cypher')) + ':/cypher',
'--writable-tmpfs',
'--network=none',
'--env NEO4J_AUTH=none',
Expand All @@ -50,7 +50,7 @@ def main():
'-v ' + shlex.quote(neo_data_path) + ':/data',
'-v ' + shlex.quote(neo_logs_path) + ':/logs',
'-v ' + os.path.abspath(os.path.join(os.environ['GREBI_HOME'], '07_create_db/neo4j/neo4j_import.dockersh')) + ':/import.sh',
'-v ' + os.path.abspath(os.path.join(os.environ['GREBI_HOME'], '07_create_db/neo4j/create_indexes.cypher')) + ':/create_indexes.cypher',
'-v ' + os.path.abspath(os.path.join(os.environ['GREBI_HOME'], '07_create_db/neo4j/cypher')) + ':/cypher',
'-e NEO4J_AUTH=none',
'neo4j:5.18.0',
'bash /import.sh'
Expand Down

0 comments on commit a998c7e

Please sign in to comment.