I am in a learning phase of SPARQL so excuse if the question sounds basic. I am exploring SPARQLWrapper to connect to a SPARQL endpoint to fetch some data. Below is the query.
sparql = SPARQLWrapper("http://patho.phenomebrowser.net/sparql/") #endpoint link
sparql.setQuery("""
PREFIX SIO: <http://semanticscience.org/resource/SIO_>
PREFIX RO: <http://purl.obolibrary.org/obo/RO_>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT distinct ?PA_ID ?pathogen ?D_ID ?disease ?disease_pathogen_evidence_code ?P_ID ?phenotype ?disease_phenotype_evidence_code
FROM <http://patho.phenomebrowser.net>
WHERE
{
?D_ID SIO:000255 ?o1 .
?o1 RO:0002558 ?EC1_ID .
?o1 RO:0002200 ?P_ID .
?D_ID SIO:000255 ?o .
?o RO:0002558 ?EC2_ID .
?o RO:0002556 ?PA_ID .
?PA_ID rdfs:label ?pathogen.
?P_ID rdfs:label ?phenotype .
?D_ID rdfs:label ?disease .
?EC1_ID rdfs:label ?disease_phenotype_evidence_code .
?EC2_ID rdfs:label ?disease_pathogen_evidence_code .
} limit 50
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
for result in results["results"]["bindings"]:
print(result["pathogen"]["value"])
The query above work fine. Is there a way to load or read a Turtle file and then use SPARQLWrapper to query the graph?