from turingdb import TuringDB
# Create TuringDB client
## if TuringDB is running locally
client = TuringDB(
host=<local_URL>, # URL on which local TuringDB is running, e.g. "http://localhost:6666"
)
### if TuringDB is running on a cloud instance
#client = TuringDB(
# instance_id=<your_instance_ID>, # found on the Database Instances management page
# auth_token=<your_auth_token> # your authentification token
#)
# Create and set working graph
client.create_graph("biograph")
client.set_graph("biograph")
# Create and set new change
change = client.new_change()
print(f"Change: {change}")
client.checkout(change=change)
# Multiple nodes and edges can be created at the same time
# using the following syntax
client.query("""CREATE (apoe_gene:Gene {name: 'APOE', chromosome: '19', location: '19q13.32'}),
(apoe_protein:Protein {name: 'Apolipoprotein E', function: 'Lipid_transport', tissue: 'Brain_and_liver'}),
(alzheimers:Disease {name: 'Alzheimers_Disease', type: 'Neurodegenerative'}),
(cholesterol:Molecule {name: 'Cholesterol', type: 'Lipid'}),
(apoe_gene)-[:ENCODES]->(apoe_protein),
(apoe_protein)-[:BINDS]->(cholesterol),
(apoe_protein)-[:ASSOCIATED_WITH]->(alzheimers)
""")
# Commit the change
client.query("COMMIT")
client.query("CHANGE SUBMIT")
# Checkout into main
client.checkout()
# Query graph
df = client.query("MATCH (n:Gene {name: 'APOE'}) RETURN n.name, n.chromosome")
print(df)