sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

neXtProt/NXQ_00058

Proteins which are located on the genome next to a protein which is involved in spermatogenesis

Use at

PREFIX : <http://nextprot.org/rdf/>
PREFIX nextprot_cv: <http://nextprot.org/rdf/terminology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT (?neighbour as ?entry) (str(?gen) as ?spergen) WHERE {
 {
 SELECT DISTINCT ?chr ?gen ?sperstart (MAX(?ldist) as ?lmin) (MIN(?rdist) as ?rmin) WHERE {
 ?entryx :isoform / :function ?func .
	 ?func :term / :childOf nextprot_cv:GO_0007283 . # Involvment in spermatogenesis
	 filter not exists {?func :negativeEvidence ?negev}
 ?entryx :gene ?gene.
 ?gene :begin ?sperstart; :end ?e; :chromosome ?chr; :recommendedName / rdfs:label ?gen.
 ?ngen :chromosome ?chr.
 ?ngen :begin ?n_begin; :end ?n_end .
 filter ( ?n_end > (?sperstart - 1000000) && ?n_begin <= (?sperstart + 1000000) && ?ngen != ?gene)
 bind(?sperstart - ?n_begin as ?dist)
 bind(if(?dist<0,?dist,-1000000) as ?ldist)
 bind(if(?dist>0,?dist,1000000) as ?rdist)
 } group by ?chr ?gen ?sperstart
 }
 bind(?sperstart - ?lmin as ?lchrpos)
 ?lgene :begin ?lchrpos; :chromosome ?chr.
 bind(?sperstart - ?rmin as ?rchrpos)
 ?rgene :begin ?rchrpos; :chromosome ?chr.
 { ?neighbour :gene ?lgene. } # left gene
	 union
 { ?neighbour :gene ?rgene. } # right gene
} order by ?gen
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v11("?chr")
  v12("?dist")
  v10("?e")
  v22("?entry")
  v9("?entryx")
  v7("?func")
  v1("?gen"):::projected 
  v6("?gene")
  v17("?lchrpos")
  v13("?ldist")
  v18("?lgene")
  v15("?lmin")
  v4("?n_begin")
  v2("?n_end")
  v8("?negev")
  v21("?neighbour"):::projected 
  v5("?ngen")
  v19("?rchrpos")
  v14("?rdist")
  v20("?rgene")
  v16("?rmin")
  v23("?spergen")
  v3("?sperstart")
  a1((" "))
  a2((" "))
  a3((" "))
  c7([":terminology/GO_0007283"]):::iri 
  f0[["?n_end > ?sperstart - '1000000^^xsd:integer'?n_begin <= ?sperstart + '1000000^^xsd:integer'?ngen != ?gene"]]
  f0 --> v2
  f0 --> v3
  f0 --> v4
  f0 --> v5
  f0 --> v6
  f1[["not  "]]
  subgraph f1e0["Exists Clause"]
    e0v1 --":negativeEvidence"-->  e0v2
    e0v1("?func"):::projected 
    e0v2("?negev"):::projected 
  end
  f1--EXISTS--> f1e0
  f1 --> v7
  f1 --> c2
  f1 --> v8
  v7 --":negativeEvidence"-->  v8
  v9 --":isoform"-->  a1
  a1 --":function"-->  v7
  v7 --":term"-->  a2
  a2 --":childOf"-->  c7
  v9 --":gene"-->  v6
  v6 --":begin"-->  v3
  v6 --":end"-->  v10
  v6 --":chromosome"-->  v11
  v6 --":recommendedName"-->  a3
  a3 --"rdfs:label"-->  v1
  v5 --":chromosome"-->  v11
  v5 --":begin"-->  v4
  v5 --":end"-->  v2
  bind2[/"?sperstart - ?n_begin"/]
  v3 --o bind2
  v4 --o bind2
  bind2 --as--o v12
  bind3[/"if(?dist < '0^^xsd:integer',?dist,'-1000000^^xsd:integer')"/]
  v12 --o bind3
  bind3 --as--o v13
  bind4[/"if(?dist > '0^^xsd:integer',?dist,'1000000^^xsd:integer')"/]
  v12 --o bind4
  bind4 --as--o v14
  bind7[/"max(?ldist)"/]
  v13 --o bind7
  bind7 --as--o v15
  bind8[/"min(?rdist)"/]
  v14 --o bind8
  bind8 --as--o v16
  bind9[/"?sperstart - ?lmin"/]
  v3 --o bind9
  v15 --o bind9
  bind9 --as--o v17
  v18 --":begin"-->  v17
  v18 --":chromosome"-->  v11
  bind10[/"?sperstart - ?rmin"/]
  v3 --o bind10
  v16 --o bind10
  bind10 --as--o v19
  v20 --":begin"-->  v19
  v20 --":chromosome"-->  v11
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v21 --":gene"-->  v20
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v21 --":gene"-->  v18
  end
  union0r <== or ==> union0l
  end
  bind11[/"?neighbour"/]
  v21 --o bind11
  bind11 --as--o v22
  bind12[/"str(?gen)"/]
  v1 --o bind12
  bind12 --as--o v23