aboutsummaryrefslogtreecommitdiff
path: root/rdf.py
diff options
context:
space:
mode:
authorArun Isaac2021-08-27 05:49:11 -0500
committerArun Isaac2021-08-27 05:49:11 -0500
commitb6cb5c4d2c64781122223d4ee100a0d6f3dd03b9 (patch)
tree0b53ac191d07c4599d2b58c0d2a96561bcb23cf1 /rdf.py
downloadgn-transform-databases-b6cb5c4d2c64781122223d4ee100a0d6f3dd03b9.tar.gz
Initial commit
Diffstat (limited to 'rdf.py')
-rw-r--r--rdf.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/rdf.py b/rdf.py
new file mode 100644
index 0000000..c2bd5e4
--- /dev/null
+++ b/rdf.py
@@ -0,0 +1,25 @@
+import os.path
+from pathlib import Path
+from rdflib import Graph
+
+graph = Graph()
+graph.parse(location=os.path.join(Path.home(), 'data/dump/dump.ttl'),
+ format='text/turtle')
+
+query = """
+PREFIX gn: <https://genenetwork.org/>
+
+SELECT ?name ?binomial
+WHERE {
+ ?species rdf:type gn:species .
+ ?strain rdf:type gn:strain .
+ ?strain gn:name "JN9" .
+ ?strain gn:strainOfSpecies ?species .
+
+ ?species gn:name ?name .
+ ?species gn:binomialName ?binomial .
+}
+"""
+
+for result in graph.query(query):
+ print(result)