Skip to content

Commit

Permalink
Merge pull request #3 from Jnguye84/neo4j
Browse files Browse the repository at this point in the history
Neo4j
  • Loading branch information
hammad93 committed Mar 2, 2024
2 parents 5cb7d58 + 5acdabd commit c4453cb
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
24 changes: 24 additions & 0 deletions neo4j/README.md
@@ -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
```
33 changes: 33 additions & 0 deletions neo4j/app.py
@@ -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)
3 changes: 3 additions & 0 deletions neo4j/install.sh
@@ -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
6 changes: 6 additions & 0 deletions neo4j/keys.txt
@@ -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
9 changes: 9 additions & 0 deletions neo4j/load.cql
@@ -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);

0 comments on commit c4453cb

Please sign in to comment.