Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Jnguye84/neo4j
Neo4j
- Loading branch information
Showing
5 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Neo4J ADCY5 | ||
This directory in the repository explains how to setup and create the Neo4J database. | ||
|
||
## Quickstart | ||
|
||
1. Run the command `python main.py` to create the JSON file which performs data collection accross the internet. | ||
2. Run the command `python ParseJson.py` creates the CSV. | ||
3. Open the `load.cql` file to create the query from the `output.csv` to run on the cloud Neo4J. | ||
|
||
## Cloud Storage | ||
The data is located on https://console.neo4j.io/ and you can find the authentication, urls, and secrets in `keys.txt`. | ||
|
||
## Install | ||
- Run `./install.sh` | ||
- Run the command `./neo4j-community-5.17.0/bin/neo4j status` to see the status of the Neo4J database. | ||
|
||
## Visualize | ||
|
||
Run this query to produce a visualization. | ||
|
||
```cypher | ||
MATCH (v:Variant)-[:CONTRIBUTED_BY]->(c:Contributor) | ||
RETURN v, c | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from flask import Flask, request, Response | ||
import requests | ||
from flask_cors import CORS # Import CORS | ||
|
||
app = Flask(__name__) | ||
CORS(app) # Enable CORS on the Flask app | ||
NEO4J_URL = "http://localhost:7474/browser" # Default URL where Neo4j browser is running | ||
|
||
@app.route('/', defaults={'path': ''}, methods=["GET", "POST", "PUT", "DELETE", "PATCH"]) | ||
@app.route('/<path:path>', methods=["GET", "POST", "PUT", "DELETE", "PATCH"]) | ||
def proxy(path): | ||
global NEO4J_URL | ||
if request.method == "GET": | ||
resp = requests.get(f'{NEO4J_URL}/{path}', stream=True) | ||
elif request.method == "POST": | ||
resp = requests.post(f'{NEO4J_URL}/{path}', json=request.json, stream=True) | ||
elif request.method == "PUT": | ||
resp = requests.put(f'{NEO4J_URL}/{path}', json=request.json, stream=True) | ||
elif request.method == "DELETE": | ||
resp = requests.delete(f'{NEO4J_URL}/{path}', stream=True) | ||
elif request.method == "PATCH": | ||
resp = requests.patch(f'{NEO4J_URL}/{path}', json=request.json, stream=True) | ||
else: | ||
return 'Unsupported HTTP method', 405 | ||
|
||
excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection'] | ||
headers = [(name, value) for (name, value) in resp.raw.headers.items() | ||
if name.lower() not in excluded_headers] | ||
response = Response(resp.content, resp.status_code, headers) | ||
return response | ||
|
||
if __name__ == '__main__': | ||
app.run(port=8888, debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
wget https://neo4j.com/artifact.php?name=neo4j-community-5.17.0-unix.tar.gz | ||
tar -xf artifact.php\?name\=neo4j-community-5.17.0-unix.tar.gz | ||
./neo4j-community-5.17.0/bin/neo4j start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Wait 60 seconds before connecting using these details, or login to https://console.neo4j.io to validate the Aura Instance is available | ||
NEO4J_URI=neo4j+s://a8b1f4fd.databases.neo4j.io | ||
NEO4J_USERNAME=neo4j | ||
NEO4J_PASSWORD=43SNNN1z7WxtGO95-8uwA0qSLLRk6AgL52OyrbjFVDg | ||
AURA_INSTANCEID=a8b1f4fd | ||
AURA_INSTANCENAME=Instance01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
LOAD CSV WITH HEADERS FROM 'file:///output.csv' AS row | ||
WITH row WHERE row.Contributors IS NOT NULL | ||
MERGE (v:Variant {name: row.`Allelic variant list`}) | ||
MERGE (r:Reference {citation: row.`Reference list`}) | ||
MERGE (l:Link {url: row.`External links`}) | ||
MERGE (c:Contributor {name: row.Contributors}) | ||
MERGE (v)-[:HAS_REFERENCE]->(r) | ||
MERGE (r)-[:HAS_LINK]->(l) | ||
MERGE (v)-[:CONTRIBUTED_BY]->(c); |