Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.example.simplejenaexample;
- import com.hp.hpl.jena.query.QuerySolution;
- import com.hp.hpl.jena.query.ResultSet;
- import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
- public class Main {
- /**
- * @param args
- */
- public static void main(String[] args) {
- QueryEngineHTTP qe = new QueryEngineHTTP(
- "http://geneid.bio2rdf.org/sparql",
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
- "SELECT ?geneLabel WHERE { "
- + "?gene <http://bio2rdf.org/geneid_vocabulary:has_taxid> <http://bio2rdf.org/taxon:7955> . "
- + "?gene <http://bio2rdf.org/geneid_vocabulary:has_chromosome> \"1\" . "
- + "?gene rdfs:label ?geneLabel . }");
- ResultSet results = qe.execSelect();
- while (results.hasNext()) {
- QuerySolution solution = results.next();
- if (solution.contains("?geneLabel")) {
- System.out.println(solution.getLiteral("?geneLabel"));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement