@prefix ex: <https://sparql.uniprot.org/.well-known/sparql-examples/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> . 

ex:118_biosodafrontend_rat_brain_human_cancer a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "What are the Homo sapiens genes associated with cancer and their orthologs expressed in the Rattus norvegicus brain?"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX up:<http://purl.uniprot.org/core/>
PREFIX taxon:<http://purl.uniprot.org/taxonomy/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX orth:<http://purl.org/net/orth#>
PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX obo:<http://purl.obolibrary.org/obo/>
PREFIX lscr:<http://purl.org/lscr#>
PREFIX genex:<http://purl.org/genex#>
PREFIX sio: <http://semanticscience.org/resource/>
SELECT ?gene ?orthologous_protein2 WHERE {
  {
    SELECT ?protein1 WHERE {
      ?protein1 a up:Protein;
        up:organism/up:scientificName 'Homo sapiens' ;
        up:annotation ?annotation .
      ?annotation rdfs:comment ?annotation_text.
      ?annotation a up:Disease_Annotation .
      FILTER CONTAINS (?annotation_text, "cancer")
    }
  }
  SERVICE <https://sparql.omabrowser.org/sparql/> {
    SELECT ?orthologous_protein2 ?protein1 ?gene WHERE {
      ?protein_OMA a orth:Protein .
      ?orthologous_protein2 a orth:Protein .
      ?cluster a orth:OrthologsCluster .
      ?cluster orth:hasHomologousMember ?node1 .
      ?cluster orth:hasHomologousMember ?node2 .
      ?node2 orth:hasHomologousMember* ?protein_OMA .
      ?node1 orth:hasHomologousMember* ?orthologous_protein2 
      .?orthologous_protein2 orth:organism/obo:RO_0002162/up:scientificName 'Rattus norvegicus' .
      ?orthologous_protein2 sio:SIO_010079 ?gene .
      ?protein_OMA lscr:xrefUniprot ?protein1 .
      FILTER(?node1 != ?node2)
    }
  }
  SERVICE <https://www.bgee.org/sparql/> {
    ?gene genex:isExpressedIn ?anatEntity .
    ?anatEntity rdfs:label 'brain' .
    ?gene orth:organism ?org . 
    ?org obo:RO_0002162 taxon:10116 .
  }
}""" ;
    schema:target <https://sparql.uniprot.org/sparql> ;
    spex:federatesWith <https://sparql.omabrowser.org/sparql/>, <https://www.bgee.org/sparql/> .

