sparql-examples

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

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

020

Which are the genes in Primates orthologous to a gene that is expressed in the fruit fly's eye?

Use at

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX genex: <http://purl.org/genex#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX orth: <http://purl.org/net/orth#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX sio: <http://semanticscience.org/resource/>

SELECT DISTINCT ?flyEnsemblGene ?orthologTaxon ?orthologEnsemblGene ?orthologOmaLink WHERE {
	{
        SELECT DISTINCT ?gene ?flyEnsemblGene {
        ?gene a orth:Gene ;
            genex:isExpressedIn/rdfs:label 'eye' ;
            orth:organism/obo:RO_0002162 ?taxon ;
            dcterms:identifier ?flyEnsemblGene .
        ?taxon up:commonName 'fruit fly' .
        } LIMIT 100
    }
    SERVICE <https://sparql.omabrowser.org/sparql> {
        ?protein2 a orth:Protein .
        ?protein1 a orth:Protein .
        ?clusterPrimates a orth:OrthologsCluster .
        ?cluster a orth:OrthologsCluster ;
            orth:hasHomologousMember ?node1 ;
            orth:hasHomologousMember ?node2 .
        ?node1 orth:hasHomologousMember* ?protein1 .
        ?node2 orth:hasHomologousMember* ?clusterPrimates .
        ?clusterPrimates orth:hasHomologousMember* ?protein2 .
        ?protein1 sio:SIO_010079 ?gene . # is encoded by
        ?protein2 rdfs:seeAlso ?orthologOmaLink ;
            orth:organism/obo:RO_0002162 ?orthologTaxonUri ;
            sio:SIO_010079 ?orthologGene . # is encoded by
        ?clusterPrimates orth:hasTaxonomicRange ?taxRange .
        ?taxRange orth:taxRange 'Primates' .
        FILTER ( ?node1 != ?node2 )
    }
    ?orthologTaxonUri up:commonName ?orthologTaxon .
    ?orthologGene dcterms:identifier ?orthologEnsemblGene .
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v9("?cluster")
  v8("?clusterPrimates")
  v3("?flyEnsemblGene"):::projected 
  v1("?gene")
  v4("?node1")
  v5("?node2")
  v15("?orthologEnsemblGene"):::projected 
  v12("?orthologGene")
  v10("?orthologOmaLink"):::projected 
  v14("?orthologTaxon"):::projected 
  v11("?orthologTaxonUri")
  v7("?protein1")
  v6("?protein2")
  v13("?taxRange")
  v2("?taxon")
  a1((" "))
  a2((" "))
  a3((" "))
  c10(["fruit fly"]):::literal 
  c13(["orth:OrthologsCluster"]):::iri 
  c2(["orth:Gene"]):::iri 
  c5(["eye"]):::literal 
  c12(["orth:Protein"]):::iri 
  c19(["Primates"]):::literal 
  v1 --"a"-->  c2
  v1 --"genex:isExpressedIn"-->  a1
  a1 --"rdfs:label"-->  c5
  v1 --"orth:organism"-->  a2
  a2 --"obo:RO_0002162"-->  v2
  v1 --"dcterms:identifier"-->  v3
  v2 --"up:commonName"-->  c10
  subgraph s1["https://sparql.omabrowser.org/sparql"]
    style s1 stroke-width:4px;
    f0[["?node1 != ?node2"]]
    f0 --> v4
    f0 --> v5
    v6 --"a"-->  c12
    v7 --"a"-->  c12
    v8 --"a"-->  c13
    v9 --"a"-->  c13
    v9 --"orth:hasHomologousMember"-->  v4
    v9 --"orth:hasHomologousMember"-->  v5
    v4 --"orth:hasHomologousMember"-->  v7
    v5 --"orth:hasHomologousMember"-->  v8
    v8 --"orth:hasHomologousMember"-->  v6
    v7 --"sio:SIO_010079"-->  v1
    v6 --"rdfs:seeAlso"-->  v10
    v6 --"orth:organism"-->  a3
    a3 --"obo:RO_0002162"-->  v11
    v6 --"sio:SIO_010079"-->  v12
    v8 --"orth:hasTaxonomicRange"-->  v13
    v13 --"orth:taxRange"-->  c19
  end
  v11 --"up:commonName"-->  v14
  v12 --"dcterms:identifier"-->  v15