Question: Select all taxa from the UniProt taxonomy.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?taxon
FROM <http://sparql.uniprot.org/taxonomy>
WHERE
{
    ?taxon a up:Taxon .
}


Question: Select all bacterial taxa and their scientific names from the UniProt taxonomy.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?taxon ?name
WHERE
{
    ?taxon a up:Taxon .
    ?taxon up:scientificName ?name .
    # Taxon subclasses are materialized, do not use rdfs:subClassOf+
    ?taxon rdfs:subClassOf taxon:2 .
}


Question: Select all UniProtKB entries, along with their organisms and amino acid sequences (including isoforms), for E. coli K12 and all its strains.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?organism ?isoform ?sequence
WHERE
{
    ?protein a up:Protein .
    ?protein up:organism ?organism .
    # Taxon subclasses are materialized, do not use rdfs:subClassOf+
    ?organism rdfs:subClassOf taxon:83333 .
    ?protein up:sequence ?isoform .
    ?isoform rdf:value ?sequence .
}


Question: Select the UniProtKB entry with the mnemonic 'A4_HUMAN'.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein
WHERE
{
    ?protein a up:Protein .
    ?protein up:mnemonic 'A4_HUMAN'
}


Question: Select a mapping of UniProtKB proteins to PDB entries using the UniProtKB cross-references to the PDB database.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?db
WHERE {
    ?protein a up:Protein .
    ?protein rdfs:seeAlso ?db .
    ?db up:database <http://purl.uniprot.org/database/PDB> .
}


Question: Select all cross-references to external databases of the category '3D structure databases' for UniProtKB entries classified with the keyword 'Acetoin biosynthesis (KW-0005)'.

PREFIX keywords: <http://purl.uniprot.org/keywords/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT ?link
WHERE
{
    ?protein a up:Protein .
    ?protein up:classifiedWith keywords:KW-0005 .
    ?protein rdfs:seeAlso ?link .
    ?link up:database ?db .
    ?db up:category "3D structure databases" .
}


Question: Select reviewed UniProtKB entries (Swiss-Prot) and their recommended protein names where the preferred gene name contains the text 'DNA'.

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?name
WHERE
{
        ?protein a up:Protein .
        ?protein up:reviewed true .
        ?protein up:recommendedName ?recommended .
        ?recommended up:fullName ?name .
        ?protein up:encodedBy ?gene .
        ?gene skos:prefLabel ?text .
        FILTER CONTAINS(?text, 'DNA')
}


Question: Select the preferred gene name and disease annotation of all human UniProtKB entries that are known to be involved in a disease.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?name ?text
WHERE
{
        ?protein a up:Protein .
        ?protein up:organism taxon:9606 .
        ?protein up:encodedBy ?gene .
        ?gene skos:prefLabel ?name .
        ?protein up:annotation ?annotation .
        ?annotation a up:Disease_Annotation .
        ?annotation rdfs:comment ?text
}


Question: Select all human UniProtKB entries with a sequence variant that leads to a loss of function.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?text
WHERE
{
        ?protein a up:Protein .
        ?protein up:organism taxon:9606 .
        ?protein up:annotation ?annotation .
        ?annotation a up:Natural_Variant_Annotation .
        ?annotation rdfs:comment ?text .
        FILTER (CONTAINS(?text, 'loss of function'))
}


Question: Select all human UniProtKB entries with a sequence variant that causes a tyrosine to phenylalanine substitution.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?annotation ?begin ?text
WHERE
{
        ?protein a up:Protein ;
            up:organism taxon:9606 ;
            up:annotation ?annotation .
        ?annotation a up:Natural_Variant_Annotation ;
            rdfs:comment ?text ;
            up:substitution ?substitution ;
            up:range/faldo:begin
                [ faldo:position ?begin ;
                  faldo:reference ?sequence ] .
        ?sequence rdf:value ?value .
        BIND (substr(?value, ?begin, 1) as ?original) .
        FILTER(?original = 'Y' && ?substitution = 'F') .
}


Question: Select all UniProtKB entries with annotated transmembrane regions and the regions' begin and end coordinates on the canonical sequence.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?begin ?end
WHERE
{
	?protein a up:Protein .
	?protein up:annotation ?annotation .
	?annotation a up:Transmembrane_Annotation .
	?annotation up:range ?range .
	?range faldo:begin/faldo:position ?begin .
	?range faldo:end/faldo:position ?end
}


Question: Select all UniProtKB entries that were created on November 30, 2010.

PREFIX up: <http://purl.uniprot.org/core/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?protein
WHERE
{
	?protein a up:Protein .
	?protein up:created '2010-11-30'^^xsd:date
}


Question: Was any UniProtKB entry integrated on January 9, 2013?

PREFIX up: <http://purl.uniprot.org/core/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
ASK
WHERE
{
	?protein a up:Protein .
	?protein up:created '2013-01-09'^^xsd:date
}


Question: What is the average number of cross-references to the PDB database for UniProtKB entries that have at least one cross-reference to the PDB database?

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT (AVG(?linksToPdbPerEntry) AS ?avgLinksToPdbPerEntry)
WHERE
{
	SELECT ?protein (COUNT(DISTINCT ?db) AS ?linksToPdbPerEntry)
	WHERE
	{
		?protein a up:Protein .
		?protein rdfs:seeAlso ?db .
		?db up:database <http://purl.uniprot.org/database/PDB> .
	}
	GROUP BY ?protein ORDER BY DESC(?linksToPdbPerEntry)
}


Question: Select the number of UniProtKB entries for each of the top-level Enzyme Commission (EC) categories.

PREFIX ec: <http://purl.uniprot.org/enzyme/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?ecClass (COUNT(?protein) as ?size)
WHERE
{
    VALUES (?ecClass) {(ec:1.-.-.-) (ec:2.-.-.-) (ec:3.-.-.-) (ec:4.-.-.-) (ec:5.-.-.-) (ec:6.-.-.-) (ec:7.-.-.-)} .
    ?protein ( up:enzyme | up:domain/up:enzyme | up:component/up:enzyme ) ?enzyme .
    # Enzyme subclasses are materialized, do not use rdfs:subClassOf+
    ?enzyme rdfs:subClassOf ?ecClass .
}
GROUP BY ?ecClass ORDER BY ?ecClass


Question: Find all natural variant annotations that are associated via an evidence tag to an article with a PubMed identifier.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?accession
    ?annotation_acc
    ?pubmed
WHERE
{
        ?protein a up:Protein ;
            up:annotation ?annotation .
        ?annotation a up:Natural_Variant_Annotation .
        ?linkToEvidence rdf:object ?annotation ;
                        up:attribution ?attribution .
        ?attribution up:source ?source .
        ?source a up:Journal_Citation .
  BIND(SUBSTR(STR(?protein),33) AS ?accession)
  BIND(IF(CONTAINS(STR(?annotation), "#SIP"), SUBSTR(STR(?annotation),33), SUBSTR(STR(?annotation),36))AS?annotation_acc)
  BIND(SUBSTR(STR(?source),35) AS ?pubmed)
}


Question: How often is each PubMed article used as an evidence source in human protein annotations, ordered from most used to least?

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?source
    (COUNT(?attribution) AS ?attribitions)
WHERE
{
        ?protein a up:Protein ;
            up:organism taxon:9606 ;
            up:annotation ?annotation .
        ?linkToEvidence rdf:object ?annotation ;
                        up:attribution ?attribution .
        ?attribution up:source ?source .
        ?source a up:Journal_Citation .
} GROUP BY ?source ORDER BY DESC(COUNT(?attribution))


Question: Find where disease-related proteins are known to be located in the cell.

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?protein
    ?disease
    ?location_inside_cell
    ?cellcmpt
WHERE
{
    ?protein up:annotation ?diseaseAnnotation , ?subcellAnnotation .
    ?diseaseAnnotation up:disease/skos:prefLabel ?disease .
    ?subcellAnnotation up:locatedIn/up:cellularComponent ?cellcmpt .
    ?cellcmpt skos:prefLabel ?location_inside_cell .
}


Question: For two UniProt accession numbers, find the GO term labels and group them into GO biological process, molecular function, and cellular component categories.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX GO:<http://purl.obolibrary.org/obo/GO_>
SELECT
    (CONCAT(SUBSTR(STR(?protein), 33)) AS ?uniprot)
    (GROUP_CONCAT(?celtype; separator=";") AS ?celtypes)
    (GROUP_CONCAT(?biotype; separator=";") AS ?biotypes)
    (GROUP_CONCAT(?moltype; separator=";") AS ?moltypes)
WHERE
{
    VALUES (?ac) {("Q6GZX4") ("Q96375")}
    BIND (IRI(CONCAT("http://purl.uniprot.org/uniprot/",?ac)) AS ?protein)
    ?protein a up:Protein .
    ?protein up:classifiedWith ?goTerm .
    #Determine if the type is biological_process
    OPTIONAL {
        ?goTerm rdfs:subClassOf GO:0008150 .
        ?goTerm rdfs:label ?biotype .
    }
    #Determine if the type is cellular_component
    OPTIONAL {
        ?goTerm rdfs:subClassOf GO:0005575 .
        ?goTerm rdfs:label ?celtype .
    }
    #Determine if the type is molecular_function
    OPTIONAL {
        ?goTerm rdfs:subClassOf GO:0003674 .
        ?goTerm rdfs:label ?moltype .
    }
    #Filter out the uniprot keywords
    FILTER(bound(?biotype) || bound(?celtype) || bound(?moltype))
} GROUP BY ?protein


Question: How many reviewed human protein entries (UniProtKB/Swiss-Prot) are associated with kinase activity?

PREFIX GO: <http://purl.obolibrary.org/obo/GO_>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    (COUNT(DISTINCT(?protein)) AS ?pc)
WHERE
{
    ?protein rdf:type up:Protein ;
        up:reviewed true  ;
        up:organism taxon:9606 ;
        up:classifiedWith|(up:classifiedWith/rdfs:subClassOf) GO:0016301 .
}


Question: What is the release number of the UniProt data currently being queried?

SELECT ?version
FROM <https://sparql.uniprot.org/.well-known/void>
WHERE
{
    [] <http://purl.org/pav/version> ?version
}


Question: Find the UniProtKB entry with the protein name 'HLA class I histocompatibility antigen, B-73 alpha chain'.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?anyKindOfName
WHERE {
  ?protein a up:Protein .
  ?protein (up:recommendedName|up:alternativeName) ?structuredName .
  ?structuredName ?anyKindOfName "HLA class I histocompatibility antigen, B-73 alpha chain" .
  ?anyKindOfName rdfs:subPropertyOf up:structuredNameType .
}


Question: Find UniProtKB proteins that are cleaved and contain a domain or component named 'HLA class I histocompatibility antigen, B-73 alpha chain'.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?anyKindOfName
WHERE {
  ?protein a up:Protein .
  ?protein (up:recommendedName|up:alternativeName)|((up:domain|up:component)/(up:recommendedName|up:alternativeName)) ?structuredName .
  ?structuredName ?anyKindOfName "HLA class I histocompatibility antigen, B-73 alpha chain" .
  ?anyKindOfName rdfs:subPropertyOf up:structuredNameType .
}


Question: Retrieve all protein and peptide names associated with the UniProtKB entry P05067.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?anyKindOfName
  ?names
  ?partType
WHERE
{
  BIND(<http://purl.uniprot.org/uniprot/P05067> AS ?protein)
  ?protein a up:Protein .
  {
    ?protein (up:recommendedName|up:alternativeName) ?structuredName .
  }
    UNION
  {
    VALUES(?partType){(up:domain) (up:component)}
    ?protein ?partType ?part .
    ?part (up:recommendedName|up:alternativeName) ?structuredName .
  }
  ?structuredName ?anyKindOfName  ?names .
  ?anyKindOfName rdfs:subPropertyOf up:structuredNameType .
}


Question: Translate the global unique identifier for a UniProtKB record into other identifiers using the Bioregistry translating endpoint.

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?protein
    ?otherIdentifier
WHERE {
    BIND(uniprotkb:P00750 AS ?protein)
    ?protein a up:Protein .
    SERVICE <https://bioregistry.io/sparql> {
        ?protein owl:sameAs ?otherIdentifier .
    }
}


Question: List the creation date, last modified date, and last sequence update version for UniProtKB proteins.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?created
  ?modified
  ?version
WHERE {
  ?protein a up:Protein ;
           up:created ?created ;
           up:modified ?modified ;
           up:version ?version .
}


Question: List UniProtKB proteins with their associated named genes.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?gene
WHERE {
  ?protein a up:Protein ;
           up:encodedBy ?gene .
}


Question: List UniProtKB proteins with their associated gene and the gene's preferred name.

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?gene ?recommendedGeneName
WHERE {
  ?protein a up:Protein ;
           up:encodedBy ?gene .
  ?gene skos:prefLabel ?recommendedGeneName .
}


Question: List UniProtKB proteins with their associated gene and the gene's ORF label.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?gene
  ?orfName
WHERE {
  ?protein a up:Protein ;
           up:encodedBy ?gene .
  ?gene up:orfName ?orfName .
}


Question: Find GeneIDs that are cross-referenced to more than one human or mouse UniProtKB entry.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX taxon:<http://purl.uniprot.org/taxon/>
SELECT
  ?geneid
  ?organism
  (GROUP_CONCAT(?protein; separator=', ') AS ?entries)
WHERE
{
  VALUES ?organism {taxon:9606 taxon:10090}
  ?geneid up:database <http://purl.uniprot.org/database/GeneID> .
  ?protein rdfs:seeAlso ?geneid ;
           up:organism ?organism
} GROUP BY ?geneid ?organism HAVING (COUNT(?protein) > 1) ORDER BY ?organism ?geneid


Question: Translate a selection of UniProtKB accession numbers into other identifier options using the identifiers.org translating endpoint.

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?protein
    ?otherIdentifier
WHERE {
    VALUES (?protein) {(uniprotkb:P00750) (uniprotkb:P05067)}
    ?protein a up:Protein .
    SERVICE <https://sparql.api.identifiers.org/sparql> {
        ?protein owl:sameAs ?otherIdentifier .
    }
}


Question: Find Drosophila proteins that are derived from at least two different transcripts, based on cross-references to Ensembl family resources.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein
WHERE {
  ?protein a up:Protein ;
           up:organism taxon:7227 ;
           up:reviewed true ;
           rdfs:seeAlso ?transcript .
  ?transcript a up:Transcript_Resource .
} GROUP BY ?protein
HAVING (COUNT(?transcript) >= 2)


Question: Find Drosophila enzymes that are derived from at least two different transcripts, based on cross-references to Ensembl transcript resources.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein
WHERE {
  ?protein up:organism taxon:7227 ;
           a up:Protein ;
           up:reviewed true ;
           rdfs:seeAlso ?transcript .
  {
    ?protein up:annotation/a up:Catalytic_Activity_Annotation ;
  } UNION {
    ?protein up:enzyme ?enzyme .
  }
  ?transcript a up:Transcript_Resource .
} GROUP BY ?protein HAVING(COUNT(?transcript) >= 2)


Question: Find enzymes with a Tyrosine (Y) as an active site residue.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
WHERE {
  ?protein up:annotation ?activeSiteAnnotation .
  ?activeSiteAnnotation a up:Active_Site_Annotation ;
    up:range ?range .
  ?range faldo:begin ?begin .
  ?begin faldo:position ?beginPosition ;
    faldo:reference ?sequence .
  ?sequence rdf:value ?sequenceVal .
  FILTER(SUBSTR(?sequenceVal, ?beginPosition, 1) = 'Y')
}


Question: List UniProtKB proteins with their associated genes and the alternative gene names that are used but not recommended by UniProtKB.

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?gene ?altGeneName
WHERE {
  ?protein a up:Protein ;
           up:encodedBy ?gene .
  ?gene skos:altLabel ?altGeneName .
}


Question: Get the list of reviewed UniProtKB protein entries for the chromosome of proteome UP000000625.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
WHERE
{
  ?protein a up:Protein ;
           up:reviewed true ;
           up:proteome <http://purl.uniprot.org/proteomes/UP000000625#Chromosome> .
}


Question: Use the ALLIE service to find the English name of the protein corresponding to the Japanese term "アミロイド前駆体タンパク質" in UniProt.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?englishLabelStr
WHERE {
    SERVICE <https://data.allie.dbcls.jp/sparql> {
        ?x rdfs:label "アミロイド前駆体タンパク質"@ja ;
            rdfs:label ?englishLabel .
        FILTER(lang(?englishLabel) = "en")
    }
    BIND (STR(?englishLabel) AS ?englishLabelStr)
    ?protein a up:Protein .
    {
        ?protein (up:recommendedName|up:alternativeName) ?structuredName .
    }
    UNION
    {
        VALUES(?partType){(up:domain) (up:component)}
            ?protein ?partType ?part .
        ?part (up:recommendedName|up:alternativeName) ?structuredName .
    }
    ?structuredName ?anyKindOfName  ?englishLabelStr .
    ?anyKindOfName rdfs:subPropertyOf up:structuredNameType .
}


Question: Find UniProtKB entries with merged loci in Bordetella avium.

PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  (GROUP_CONCAT(?locusName; separator=',') AS ?locusNames)
WHERE
{
  ?protein a up:Protein ;
    up:organism taxon:360910 ;
    up:encodedBy ?gene .
  ?gene up:locusName ?locusName .
}
GROUP BY ?protein
HAVING (COUNT(?locusName) > 1)


Question: Find UniParc records whose sequences correspond to the highest number of database entries.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?sequence ?entries
WHERE
{
    {
        SELECT ?sequence (COUNT(?entry) AS ?entries)
        WHERE
        {
            GRAPH <http://sparql.uniprot.org/uniparc> {
                ?sequence up:sequenceFor ?entry .
            }
        }
        GROUP BY ?sequence
    }
}
ORDER BY DESC(?entries)


Question: Find UniProtKB entries with more than one Topological domain annotation.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?protein
    (GROUP_CONCAT(?comment; separator=", ") AS ?comments)
WHERE
{
    ?protein a up:Protein ;
            up:annotation ?annotation .
    ?annotation rdf:type up:Topological_Domain_Annotation ;
            rdfs:comment ?comment .
}
GROUP BY ?protein
HAVING (COUNT(?annotation) > 1)


Question: Find the longest comment text associated with a UniProtKB natural variant annotation.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?annotation ?comment
WHERE {
    ?annotation a up:Natural_Variant_Annotation ;
        rdfs:comment ?comment .
}
ORDER BY DESC(STRLEN(?comment))
LIMIT 1


Question: Find the co-occurrence count of topological domain comment texts in UniProtKB entries.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?comment1
    ?comment2
    (COUNT(?comment1) AS ?count1)
WHERE
{
    ?protein a up:Protein ;
               up:annotation ?annotation1 ,
                             ?annotation2 .
    ?annotation1 rdf:type up:Topological_Domain_Annotation ;
        rdfs:comment ?rawComment1 .
    ?annotation2 rdf:type up:Topological_Domain_Annotation ;
        rdfs:comment ?rawComment2 .
    BIND(IF(contains(?rawComment1, ';'),
            STRBEFORE(?rawComment1,';'),
            ?rawComment1) AS ?comment1)
    BIND(IF(contains(?rawComment2, ';'),
            STRBEFORE(?rawComment2,';'),
            ?rawComment2) AS ?comment2)
    FILTER(?annotation1 != ?annotation2)
}
GROUP BY ?comment1 ?comment2
ORDER BY DESC(COUNT(?comment1))


Question: Find the similar proteins for UniProtKB entry P05607 sorted by UniRef cluster identity.

PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?similar ?identity
FROM <http://sparql.uniprot.org/uniref>
FROM <http://sparql.uniprot.org/uniprot>
WHERE
{
    BIND (uniprotkb:P05607 AS ?protein)
    ?cluster up:member ?member ;
             up:member/up:sequenceFor ?protein;
             up:identity ?identity .
    ?member up:sequenceFor ?similar .
    FILTER(!sameTerm(?similar, ?protein))
}
ORDER BY DESC(?identity)


Question: Find the orthologous proteins for UniProtKB entry P05067 using the OrthoDB database.

PREFIX orthodb: <http://purl.orthodb.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?orthoGroup
  ?scientificName
  ?functionComment
  ?prefferedGeneName
  ((STRLEN(?value) - ?medianLength) as ?deviationFromMedianLength)
WHERE
{
  uniprotkb:P05067 a up:Protein ;
        up:organism/up:scientificName ?scientificName ;
        rdfs:seeAlso ?orthoGroup ;
        up:encodedBy/skos:prefLabel ?prefferedGeneName ;
          up:sequence/rdf:value ?value .
  OPTIONAL {
    ?protein up:annotation ?functionAnnotation .
    ?functionAnnotation a up:Function_Annotation ;
      rdfs:comment ?functionComment .
  }
  SERVICE <https://sparql.orthodb.org/sparql>{
    ?orthoGroup orthodb:ogMedianProteinLength ?medianLength .
    ?orthoGroup orthodb:hasMember ?xref .
    ?xref orthodb:xref/orthodb:xrefResource uniprotkb:P05067 .
  }
}


Question: Find the human protein that contains the epitope VSTQ, where the threonine (T) is phosphorylated.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?comment
  ?begin
  ?end
WHERE
{
  ?protein a up:Protein ;
    up:organism taxon:9606 ;
    up:sequence ?sequence ;
    up:annotation ?annotation .
  ?annotation a up:Modified_Residue_Annotation ;
    rdfs:comment ?comment ;
    up:range ?range .
  ?range
    faldo:begin [ faldo:position ?begin ; faldo:reference ?sequence ] ;
    faldo:end [ faldo:position ?end ; faldo:reference ?sequence ] .
  ?sequence rdf:value ?aaSequence .
  FILTER (SUBSTR(?aaSequence, ?begin -2 , 4) = "VSTQ")
  FILTER (CONTAINS(?comment, "Phosphothreonine"))
}


Question: For the human entry P05067 (Amyloid-beta precursor protein), find the gene start and end positions in Wikidata.

PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT
	?protein
	?begin
	?end
	?chromosome
	?assembly
WHERE {
    {
        BIND(uniprotkb:P05067 AS ?proteinIRI)
        BIND (SUBSTR(STR(?proteinIRI), STRLEN(STR(uniprotkb:))+1) AS ?protein)
    }
    SERVICE <https://query.wikidata.org/sparql> {
        ?wp wdt:P352 ?protein ;
            wdt:P702 ?wg .
        ?wg p:P644   ?wgss .
        ?wgss ps:P644        ?begin ;
          pq:P1057/wdt:P1813 ?chromosome ;
          pq:P659/rdfs:label ?assembly .
        ?wg p:P645 ?wgse .
        ?wgse ps:P645        ?end ;
          pq:P1057/wdt:P1813 ?chromosome ;
          pq:P659/rdfs:label ?assembly .
        FILTER(lang(?assembly) = "en")
  }
}


Question: Retrieve entries and their catalytic activities in the reviewed (UniProtKB/Swiss-Prot) section that have experimental evidence.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?rhea
WHERE {
  # ECO 269 is experimental evidence
  BIND (<http://purl.obolibrary.org/obo/ECO_0000269> as ?evidence)
  GRAPH <http://sparql.uniprot.org/uniprot> {
    ?protein up:reviewed true ;
      up:annotation ?a ;
      up:attribution ?attribution  .
    ?a a up:Catalytic_Activity_Annotation ;
      up:catalyticActivity ?ca .
    ?ca up:catalyzedReaction ?rhea .

    [] rdf:subject ?a ;
      rdf:predicate up:catalyticActivity ;
      rdf:object ?ca ;
      up:attribution ?attribution .
    ?attribution up:evidence ?evidence .
  }
}


Question: Retrieve human enzymes that metabolize sphingolipids and are annotated in ChEMBL.

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT ?protein ?chemblEntry
WHERE {
  SERVICE <https://sparql.rhea-db.org/sparql> {
    ?rhea rdfs:subClassOf rh:Reaction ;
      rh:side/rh:contains/rh:compound/rh:chebi/rdfs:subClassOf+ CHEBI:26739 .
  }
  ?ca up:catalyzedReaction ?rhea .
  ?protein up:annotation/up:catalyticActivity ?ca ;
    up:organism taxon:9606 ;
    rdfs:seeAlso ?chemblEntry .
  ?chemblEntry up:database <http://purl.uniprot.org/database/ChEMBL> .
}


Question: Retrieve UniProtKB entries with sequences that are not composed of fragments.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT
  ?protein
WHERE {
  ?protein a up:Protein ;
    up:sequence ?sequence .
  MINUS { ?sequence up:fragment [] }
}


Question: Connect patents cited in UniProtKB with those in the patent database at EPO via publication number.

PREFIX patent: <http://data.epo.org/linked-data/def/patent/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?citation ?patent ?application ?applicationNo
WHERE {
  ?citation a up:Patent_Citation ;
    skos:exactMatch ?patent .
  FILTER(CONTAINS(STR(?patent), 'EP'))
  BIND(SUBSTR(STR(?patent), 35) AS ?applicationNo)
  SERVICE <https://data.epo.org/linked-data/query> {
    ?application patent:publicationNumber ?applicationNo .
  }
}


Question: Connect patents cited in UniProtKB with those in the EPO patent database via publication number, where the grant date is more than twenty years ago.

PREFIX patent: <http://data.epo.org/linked-data/def/patent/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?grantDate ?patent ?application ?applicationNo
WHERE
{
    ?citation a up:Patent_Citation ;
      skos:exactMatch ?patent .
    BIND(SUBSTR(STR(?patent), 35) AS ?applicationNo)
    BIND(SUBSTR(STR(?patent), 33, 2) AS ?countryCode)
    SERVICE <https://data.epo.org/linked-data/query>{
      ?publication patent:publicationNumber ?applicationNo ;
        patent:application ?application .
      ?application patent:grantDate ?grantDate .
    }
    BIND((year(now()) - 20) AS ?thisYearMinusTwenty)
    BIND(year(?grantDate) AS ?grantYear)
    FILTER(?grantYear < ?thisYearMinusTwenty)
} ORDER BY ?grantYear


Question: Find the combinations of Rhea and InterPro annotations in reviewed UniProtKB entries.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?interpro
	?rhea
FROM <http://sparql.uniprot.org/uniprot>
WHERE
{
  ?protein up:reviewed true .
  ?protein up:annotation ?annotation .
  ?annotation up:catalyticActivity ?rhea .
  ?protein rdfs:seeAlso ?interpro .
  ?interpro up:database <http://purl.uniprot.org/database/InterPro> .
} ORDER BY ?rhea


Question: Retrieve drugs that target human enzymes involved in sterol metabolism by federated querying WikiData and Rhea.

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX chebihash: <http://purl.obolibrary.org/obo/chebi#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT DISTINCT ?protein ?proteinFullName ?wikiChemical ?wikiChemicalLabel ?medicalConditionTreatedLabel
WHERE {
  # ChEBI: retrieve members of the ChEBI class ChEBI:15889 (sterol)
  # Rhea: retrieve the reactions involving these ChEBI as participants
  SERVICE <https://sparql.rhea-db.org/sparql> {
    ?reaction rdfs:subClassOf rh:Reaction ;
      rh:status rh:Approved ;
      rh:side ?reactionSide .
    ?reactionSide
      rh:contains ?participant .
    ?participant rh:compound ?compound
    {
      ?compound rh:chebi ?chebi .
      ?chebi (rdfs:subClassOf)+ CHEBI:15889
    } UNION {
      ?compound rh:chebi ?chebi .
      ?chebi2 rdfs:subClassOf ?chebiRestriction .
      ?chebiRestriction
		a owl:Restriction ;
		owl:onProperty chebihash:has_major_microspecies_at_pH_7_3 ;
		owl:someValuesFrom ?chebi .
      ?chebi2 (rdfs:subClassOf)+ CHEBI:15889
    }
  }
  # UniProt: retrieve the human (taxid:9606) enzymes catalyzing these Rhea reactions
  ?ca up:catalyzedReaction  ?reaction .
  ?a up:catalyticActivity  ?ca .
  ?proteinIRI  up:annotation ?a ;
    up:organism taxon:9606 ;
    up:recommendedName ?proteinRecName .
  ?proteinRecName up:fullName ?proteinFullName .
  # Find drugs in wikidata that interact with the UniProt Proteins
  BIND (SUBSTR(STR(?proteinIRI), STRLEN(STR(uniprotkb:))+1) AS ?protein)
  SERVICE <https://query.wikidata.org/sparql> {
    ?wp wdt:P352  ?protein .
    ?wikiChemical wdt:P129 ?wp . # Physically interacts with
    ?wikiChemical rdfs:label ?wikiChemicalLabel .
    ?wikiChemical wdt:P2175 ?wmc . # Medical condition treated
    ?wmc rdfs:label ?medicalConditionTreatedLabel .
    FILTER(lang(?medicalConditionTreatedLabel) = 'en')
    FILTER(lang(?wikiChemicalLabel) = 'en')
  }
}


Question: Retrieve images of 'Anas' (ducks) from the European Environmental Agency databases using a federated query.

PREFIX eunisSpecies: <http://eunis.eea.europa.eu/rdf/species-schema.rdf#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?taxon
    ?ncbiTaxid
    ?eunisTaxon
    ?eunisName
    ?image
WHERE
{
    GRAPH <http://sparql.uniprot.org/taxonomy>
    {
        ?taxon a up:Taxon .
        # Taxon subclasses are materialized, do not use rdfs:subClassOf+
        ?taxon rdfs:subClassOf taxon:8835 .
        BIND(strafter(str(?taxon), 'onomy/') AS ?ncbiTaxid)
    }
    SERVICE <https://semantic.eea.europa.eu/sparql>
    {
        ?eunisTaxon a eunisSpecies:SpeciesSynonym ;
           eunisSpecies:binomialName ?eunisName ;
           eunisSpecies:sameSpeciesNCBI ?ncbiTaxid ;
           <http://xmlns.com/foaf/0.1/depiction> ?image .
    }
}


Question: Find UniProtKB entries with a transmembrane region that have an alanine in the 15 amino acid region preceding the transmembrane segment.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?from ?interestingRegion
WHERE
{
  ?protein up:annotation ?annotation .
  ?annotation a up:Transmembrane_Annotation .
  # Get the coordinates of the Transmembrane
  ?annotation up:range ?range .
  ?range faldo:begin ?beginI .
  ?beginI faldo:position ?begin .
  ?beginI faldo:reference ?sequence .
  # The aas will have the specific IUPAC aminoacids
  ?sequence rdf:value ?aas .
  # We calculate the start by subtracting 10
  BIND(?begin - 10 AS ?tenBeforeBegin)
  # Can't start before the sequence starts or we might miss some results
  BIND(IF(?tenBeforeBegin < 1, 0, ?tenBeforeBegin) AS ?from)
  # Substring the IUPAC aminoacids
  BIND(SUBSTR(?aas, ?from, 15) AS ?interestingRegion)
  # The interestingRegion needs to contain an Alanine
  FILTER(CONTAINS(?interestingRegion, 'A'))
}


Question: Retrieve glycosylation sites and glycans on human enzymes (federated with Glyconnect)

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX glycan: <http://purl.jp/bio/12/glyco/glycan#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT ?protein ?glycosite ?glycostructure ?glycoimage WHERE {
  ?protein up:annotation ?annotation .
  ?protein up:organism taxon:9606 .
  ?annotation a up:Catalytic_Activity_Annotation .
  ?protein up:sequence ?isoform .
  SERVICE <https://glyconnect.expasy.org/sparql> {
    ?glycosite faldo:reference ?isoform .
    ?glycosite faldo:position ?position .
    ?specificglycosite faldo:location ?glycosite .
    ?glycoprotein glycan:glycosylated_at ?specificglycosite .
    ?glycostructure glycan:glycosylates_at ?specificglycosite .
    ?glycostructure foaf:depiction ?glycoimage .
  }
}


Question: Retrieve the UniProtKB proteins, their catalyzed Rhea reactions, their encoding Ensembl genes, and the anatomic entities where these genes are expressed (UBERON anatomic entities from the Bgee expression data resource).

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX genex: <http://purl.org/genex#>
PREFIX lscr: <http://purl.org/lscr#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT ?protein ?ensemblGene ?reaction ?anatomicEntityLabel ?anatomicEntity
WHERE {
  # federated query to Rhea endpoint
  {
    SELECT DISTINCT ?reaction WHERE {
      SERVICE <https://sparql.rhea-db.org/sparql> {
        ?reaction rdfs:subClassOf rh:Reaction ;
          rh:equation ?reactionEquation ;
          rh:side ?reactionSide .
        ?reactionSide rh:contains ?participant .
        ?participant rh:compound ?compound .
        # compound constraint (CHEBI:16113 == cholesterol)
        ?compound rh:chebi CHEBI:16113 .
      }
    }
  }
  # taxonomy constraint (taxon:9606 == Homo sapiens)
  ?protein up:organism taxon:9606 ;
    up:annotation ?a ;
    rdfs:seeAlso / up:transcribedFrom ?ensemblGene .
  ?a a up:Catalytic_Activity_Annotation ;
    up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?reaction .
  # federated query to Bgee (expression data)
  BIND(IRI(REPLACE(STR(?ensemblGene), "\\.[0-9]+$", "")) AS ?ensemblGeneNoVersion)
  SERVICE <https://www.bgee.org/sparql> {
    ?gene lscr:xrefEnsemblGene ?ensemblGeneNoVersion ;
      genex:isExpressedIn ?anatomicEntity .
    ?anatomicEntity rdfs:label ?anatomicEntityLabel .
  }
}


Question: Where in the human body are the genes encoding enzymes that metabolize N-acyl sphingosines expressed? (Federated query using Rhea and Bgee)

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX genex: <http://purl.org/genex#>
PREFIX lscr: <http://purl.org/lscr#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  DISTINCT
    ?chebi
    ?reaction
    ?protein ?ensemblGene
    ?anatomicEntityLabel
    ?anatomicEntity
WHERE {
  SERVICE <https://sparql.rhea-db.org/sparql> {
    ?reaction rdfs:subClassOf rh:Reaction .
    ?reaction rh:equation ?reactionEquation .
    ?reaction rh:side ?reactionSide .
    ?reactionSide rh:contains ?participant .
    ?participant rh:compound ?compound .
    ?compound rh:chebi ?chebi .
    ?chebi rdfs:subClassOf* CHEBI:52639
  }
  ?protein up:organism taxon:9606 .
  ?protein up:annotation ?a .
  ?a a up:Catalytic_Activity_Annotation .
  ?a up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?reaction .
  ?protein rdfs:seeAlso / up:transcribedFrom ?ensemblGene .
  SERVICE  <https://www.bgee.org/sparql> {
    ?gene genex:isExpressedIn ?anatomicEntity .
    ?gene lscr:xrefEnsemblGene ?ensemblGene .
    ?anatomicEntity rdfs:label ?anatomicEntityLabel .
  }
}


Question: Find all proteins linked to arachidonate (CHEBI:32395).

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    DISTINCT
        ?uniprot
        ?uniprotID
        ?recname
        ?gene
        ?chebi
        ?uniprotName
WHERE {
  SERVICE <https://sparql.rhea-db.org/sparql> {
     VALUES (?chebi) { (CHEBI:32395) }
     ?rhea rh:side/rh:contains/rh:compound ?compound .
     ?compound rh:chebi ?chebi .
     ?chebi up:name ?uniprotName .
  }
  ?uniprot up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea .
  ?uniprot up:mnemonic ?uniprotID .
  ?uniprot up:recommendedName/up:fullName ?recname .
  OPTIONAL {?uniprot up:encodedBy/skos:prefLabel ?gene .}
}


Question: Retrieve drugs that target human enzymes involved in sterol metabolism.

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX cco: <http://rdf.ebi.ac.uk/terms/chembl#>
PREFIX chebihash: <http://purl.obolibrary.org/obo/chebi#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
        DISTINCT
            ?protein
            ?proteinFullName
            ?activityType
            ?standardActivityValue
            ?standardActivityUnit
            ?chemblMolecule
            ?chemlbMoleculePrefLabel
WHERE
  {
  SERVICE <https://sparql.rhea-db.org/sparql> {
    ?reaction rdfs:subClassOf  rh:Reaction ;
          rh:status        rh:Approved ;
          rh:side          ?reactionSide .
    ?reactionSide
          rh:contains      ?participant .
    ?participant rh:compound  ?compound
    {
      ?compound  rh:chebi  ?chebi .
      ?chebi (rdfs:subClassOf)+ CHEBI:15889
    } UNION {
      ?compound  rh:chebi           ?chebi .
      ?chebi2   rdfs:subClassOf     ?chebiRestriction .
      ?chebiRestriction
        a           owl:Restriction ;
        owl:onProperty      chebihash:has_major_microspecies_at_pH_7_3 ;
        owl:someValuesFrom  ?chebi .
      ?chebi2 (rdfs:subClassOf)+ CHEBI:15889
    }
  }
  ?ca       up:catalyzedReaction  ?reaction .
  ?a        up:catalyticActivity  ?ca .
  ?protein  up:annotation         ?a ;
            up:organism           taxon:9606 ;
            up:recommendedName    ?proteinRecName .
  ?proteinRecName
            up:fullName           ?proteinFullName .
  SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/idsm> {
    ?activity a cco:Activity ;
      cco:hasMolecule ?chemblMolecule ;
      cco:hasAssay ?assay ;
      cco:standardType ?activityType ;
      cco:standardValue ?standardActivityValue ;
      cco:standardUnits ?standardActivityUnit .
    ?chemblMolecule cco:highestDevelopmentPhase ?highestDevelopmentPhase ;
      rdfs:label ?chemblMoleculeLabel ;
      skos:prefLabel ?chemlbMoleculePrefLabel .
    FILTER (?highestDevelopmentPhase > 3)
    ?assay cco:hasTarget ?target .
    ?target cco:hasTargetComponent/cco:targetCmptXref ?protein .
    ?protein a cco:UniprotRef .
  }
}


Question: Find mouse homologs in OMABrowser of human enzymes that catalyze reactions involving sterols (CHEBI:15889), federating with Rhea and OMABrowser.

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX lscr: <http://purl.org/lscr#>
PREFIX orth: <http://purl.org/net/orth#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  DISTINCT
    ?chebi
    ?reaction
    ?humanProtein
    ?mouseProtein
    ?cluster
WHERE {
  SERVICE <https://sparql.rhea-db.org/sparql> {
    ?reaction rdfs:subClassOf rh:Reaction .
    ?reaction rh:side/rh:contains/rh:compound ?compound .
    ?compound rh:chebi ?chebi .
    ?chebi rdfs:subClassOf* CHEBI:15889
  }
  ?humanProtein up:organism taxon:9606 .
  ?humanProtein up:annotation ?a .
  ?a a up:Catalytic_Activity_Annotation .
  ?a up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?reaction .
  SERVICE  <https://sparql.omabrowser.org/sparql> {
    ?cluster a orth:ParalogsCluster .
    ?cluster orth:hasHomologousMember ?node1 , ?node2 .
    ?node1 orth:hasHomologousMember* ?orthoProtein1 .
    ?node2 orth:hasHomologousMember* ?orthoProtein2 .
    ?orthoProtein1 lscr:xrefUniprot ?mouseProtein .
    ?orthoProtein2 lscr:xrefUniprot ?humanProtein .
    ?orthoProtein1 orth:organism/<http://purl.obolibrary.org/obo/RO_0002162> taxon:10090 .
  }
}


Question: Proteins with binding sites for ligands similar to heme

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT
  ?protein
  ?mnemonic
  ?proteinName
  ?ligandSimilarityScore
  ?ligand
WHERE {
  SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/chebi> {
    ?ssc sachem:compound ?ligand;
      sachem:score ?ligandSimilarityScore ;
      sachem:similaritySearch ?sss .
        # Smiles of Heme
    ?sss    sachem:query "CC1=C(CCC([O-])=O)C2=[N+]3C1=Cc1c(C)c(C=C)c4C=C5C(C)=C(C=C)C6=[N+]5[Fe-]3(n14)n1c(=C6)c(C)c(CCC([O-])=O)c1=C2";
      sachem:cutoff "8e-1"^^xsd:double ;
      sachem:aromaticityMode sachem:aromaticityDetect ;
      sachem:similarityRadius 1 ;
      sachem:tautomerMode sachem:ignoreTautomers .
  }
  ?protein up:mnemonic ?mnemonic ;
    up:recommendedName/up:fullName ?proteinName ;
    up:annotation ?annotation .
  ?annotation a up:Binding_Site_Annotation ;
      up:ligand/rdfs:subClassOf ?ligand .
}
ORDER BY DESC(?ligandSimilarityScore)


Question: How many proteins have binding sites for metals or metal sulfur clusters with experimental evidence for the binding?

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?ligand
  ?ligandName
  (COUNT(DISTINCT ?protein) as ?entries)
WHERE {
   ?protein up:annotation ?annotation .

   VALUES ?evs { obo:ECO_0000269 obo:ECO_0007744 } .
   VALUES ?chebids { CHEBI:25213 CHEBI:25214 } .
   ?st rdf:subject ?protein ;
       rdf:predicate up:annotation ;
       rdf:object ?annotation ;
       up:attribution/up:evidence ?evs .
   ?annotation up:ligand/rdfs:subClassOf ?ligand .
   ?ligand rdfs:subClassOf+ ?chebids ;
     rdfs:label ?ligandName .
}
GROUP BY ?ligand ?ligandName
ORDER BY DESC(?entries)


Question: Select enzymes that have ligands known to have an allosteric effect.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?ligandName
  ?ligandNote
  ?chebi
WHERE {
   ?protein up:annotation ?annotation .
   ?annotation a up:Binding_Site_Annotation .
   ?annotation up:ligand ?ligand .
   ?ligand rdfs:comment ?ligandNote ;
     rdfs:subClassOf ?chebi ;
     rdfs:label ?ligandName .
   FILTER(REGEX(?ligandNote, "allosteric", "i"))
}


Question: Map a selection of PDB identifiers and their chains to UniProtKB entries.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?pdbId ?chain ?pdbChain ?uniprot
WHERE
{
  # A space separated list of pairs of PDB identifiers and the chain code.
  VALUES(?pdbId ?pdbChain) { ('6VXC' 'A') ('1BG3' 'B') }
  # Make an IRI out of the pdbId
  BIND(iri(concat('http://rdf.wwpdb.org/pdb/', ?pdbId)) AS ?pdb)
  # Map to UniProt entries
  ?uniprot rdfs:seeAlso ?pdb .
  ?pdb up:database <http://purl.uniprot.org/database/PDB> ;
       up:chainSequenceMapping ?chainSm .
  ?chainSm up:chain ?chainsPlusRange .
  # Extract the list of chains from the text representation.
  BIND(STRBEFORE(?chainsPlusRange, '=') AS ?chain)
  # Filter those that match.
  FILTER(CONTAINS(?chain, ?pdbChain))
}


Question: Map a selection of UniProtKB accession numbers to their corresponding HGNC identifiers and symbols.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?uniprot
  ?hgnc
  ?hgncSymbol
WHERE
{
  VALUES (?acc) {('P05067') ('P00750')}
  BIND(iri(concat(str(uniprotkb:), ?acc)) AS ?uniprot)
  ?uniprot rdfs:seeAlso ?hgnc .
  ?hgnc up:database <http://purl.uniprot.org/database/HGNC> ;
       rdfs:comment ?hgncSymbol .
}


Question: How many isoforms are there for the human proteome UP000005640?

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX proteome:<http://purl.uniprot.org/proteomes/>
SELECT
  (COUNT(DISTINCT ?sequence) AS ?allIsoforms)
WHERE
{
  ?protein up:reviewed true .
  ?protein up:organism taxon:9606 .
  ?protein up:sequence ?sequence .
  ?protein up:proteome/^skos:narrower proteome:UP000005640 .
}


Question: Find human proteins that catalyze reactions where substrates or products have a cholestane skeleton.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  DISTINCT
    ?protein
    ?disease
    ?rhea
    ?chebi
    ?omim
WHERE {
    # Find complete ChEBIs with a Cholestane skeleton, via the Czech Elixir node IDSM Sachem chemical substructure search.
    SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/chebi> {
      ?chebi sachem:substructureSearch [
        sachem:query
"[C@]12(CCC3CCCC[C@]3(C)[C@@]1([H])CC[C@]1(C)[C@@]([H])([C@@](C)([H])CCCC(C)C)CC[C@@]21[H])[H]"
].
   }
   # Use the fact that UniProt catalytic activities are annotated using Rhea
   # Mapping the found ChEBIs to Rhea reactions
   SERVICE <https://sparql.rhea-db.org/sparql>{
     ?rhea rh:side/rh:contains/rh:compound/rdfs:subClassOf ?chebi .
   }
   # Match the found Rhea reactions with human UniProtKB proteins
   ?protein up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea .
   ?protein up:organism taxon:9606 .
   # Find only those human entries that have an annotated related disease, and optionally map these to OMIM
   ?protein up:annotation/up:disease ?disease .
   OPTIONAL {
     ?disease rdfs:seeAlso ?omim .
     ?omim up:database <http://purl.uniprot.org/database/MIM>
   }
}


Question: Select the sets of Ensembl genes, human UniProtKB proteins, and catalyzed Rhea reactions.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
?ensemblGene ?protein ?rhea
WHERE {
  ?protein up:reviewed true ;
           up:organism taxon:9606 .
  ?protein up:annotation ?caa ;
           rdfs:seeAlso ?ensemblTranscript .
  ?ensemblTranscript up:database <http://purl.uniprot.org/database/Ensembl> .
  ?caa up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?rhea .
  ?ensemblTranscript up:transcribedFrom ?ensemblGene .
}


Question: List the proteins encoded by genes located in organelles other than the nucleus, or on plasmids rather than chromosomes. Note that gene location is indicated by the encodedIn property, and plasmids may have multiple names listed as multiple rdfs:label properties.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
    ?protein
    ?plasmidOrOrganelle
    ?label
WHERE {
    ?protein a up:Protein ;
      up:encodedIn ?plasmidOrOrganelle .
    OPTIONAL {
        ?plasmidOrOrganelle rdfs:label ?label .
    }
    FILTER (?plasmidOrOrganelle != up:Nucleus)
}


Question: List all human UniProtKB entries and their computationally mapped potential isoforms.

PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?entry ?sequence ?isCanonical
WHERE {
  GRAPH <http://sparql.uniprot.org/uniprot> {
      ?entry a up:Protein ;
        up:organism taxon:9606 ;
        up:potentialSequence ?sequence .
  }
}


Question: How can I extract the UniProtKB primary accession from UniProt protein IRIs using SPARQL?

PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?primaryAccession
  ?protein
WHERE {
  ?protein a up:Protein .
  BIND(substr(str(?protein), strlen(str(uniprotkb:))+1) AS ?primaryAccession)
}


Question: List UniProtKB proteins along with the genetic replicon on which their genes are encoded, using Proteome data.

PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT ?protein ?replicon ?proteome WHERE {
  ?protein a up:Protein ;
           up:reviewed true ;
           up:organism taxon:9606 ;
           up:proteome ?proteomeData .
  BIND(strbefore(str(?proteomeData), "#") AS ?proteome)
  BIND(strafter(str(?proteomeData), "#") AS ?replicon)
}


Question: What are the recommended full names of proteins for UniProtKB entries?

PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?fullName
WHERE {
  ?protein a up:Protein ;
           up:recommendedName ?recommendedName .
  ?recommendedName up:fullName ?fullName .
}


Question: What are the recommended protein short names for UniProtKB entries?

PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?fullName
WHERE {
  ?protein a up:Protein ;
           up:recommendedName ?recommendedName .
  ?recommendedName up:shortName ?fullName .
}


Question: List all UniProtKB proteins and indicate whether they are reviewed (Swiss-Prot) or unreviewed (TrEMBL).

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?reviewed
WHERE {
  ?protein a up:Protein .
  ?protein up:reviewed ?reviewed .
}


Question: List all human UniProtKB entries and their sequences, indicating whether each sequence is the canonical sequence of the corresponding entry.

PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?entry ?sequence ?isCanonical
WHERE {
  GRAPH <http://sparql.uniprot.org/uniprot> {
      ?entry a up:Protein ;
        up:organism taxon:9606 ;
        up:sequence ?sequence .
      OPTIONAL {
        ?sequence a up:Simple_Sequence .
        BIND(true AS ?likelyIsCanonical)
      }
      OPTIONAL {
        FILTER(?likelyIsCanonical)
        ?sequence a up:External_Sequence .
        BIND(true AS ?isComplicated)
      }
      BIND(IF(?isComplicated, STRENDS(STR(?entry), STRBEFORE(SUBSTR(STR(?sequence), 34),'-')), ?likelyIsCanonical) AS ?isCanonical)
  }
}


Question: List all InterPro member database signature match start and end positions for the UniProtKB protein P05067.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein ?interproMemberDatabaseXref ?matchStart ?matchEnd
WHERE{
  GRAPH <http://sparql.uniprot.org/uniprot> {
    VALUES ?protein {<http://purl.uniprot.org/uniprot/P05067>} .
    ?protein rdfs:seeAlso ?sa .
  }
  GRAPH <http://sparql.uniprot.org/uniparc> {
    ?uniparc up:sequenceFor ?protein ;
      rdfs:seeAlso ?interproMemberDatabaseXref .
    ?interproMemberDatabaseXref up:signatureSequenceMatch ?sam .
    ?sam faldo:begin ?sab ;
      faldo:end ?sae .
    ?sab faldo:position ?matchStart ;
      faldo:reference ?uniparc .
    ?sae  faldo:position ?matchEnd ;
      faldo:reference ?uniparc .
  }
}


Question: Find human transporter proteins in reviewed UniProtKB/Swiss-Prot that are expressed in the liver, using Bgee and UBERON.

PREFIX genex: <http://purl.org/genex#>
PREFIX lscr: <http://purl.org/lscr#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX orth: <http://purl.org/net/orth#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX uberon: <http://purl.obolibrary.org/obo/uo#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?rhea
  ?protein
  ?anat
WHERE
{
  GRAPH <https://sparql.rhea-db.org/rhea> {
    ?rhea rh:isTransport true .
  }
  ?protein up:annotation ?ann .
  ?protein up:organism taxon:9606 .
  ?ann up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?rhea .
  BIND(uberon:0002107 AS ?anat)
  SERVICE <https://www.bgee.org/sparql> {
    ?seq genex:isExpressedIn ?anat .
    ?seq lscr:xrefUniprot ?protein .
    ?seq orth:organism ?organism .
    ?organism obo:RO_0002162 taxon:9606 .
  }
}


Question: Given a UniProt chain identifier, generate the matching sequence in FASTA format.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX faldo: <http://biohackathon.org/resource/faldo#>
SELECT (CONCAT('>', ?chainSeqId, '\n', (SUBSTR(?iupacAA, ?begin, (?end-?begin+1)))) AS ?chainFasta)
WHERE {
  BIND("PRO_0000268053" AS ?chainSeqId)
  BIND(IRI(CONCAT("http://purl.uniprot.org/annotation/", ?chainSeqId)) AS ?annId)
  ?annId up:range ?range .
  ?range faldo:begin [ faldo:reference ?reference ; faldo:position ?begin ] ;
         faldo:end [ faldo:position ?end ] .
  ?reference rdf:value ?iupacAA .
}


Question: Find diseases that are thought to be related to enzymes.

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
?disease ?diseaseLabel
WHERE {
 ?protein up:enzyme|up:annotation/up:catalyticActivity/up:enzymeClass ?enzyme ;
                   up:annotation ?diseaseAnnotation .
 ?diseaseAnnotation a up:Disease_Annotation ;
                    up:disease ?disease .
 ?disease skos:prefLabel ?diseaseLabel .
}


Question: Find human genetic diseases associated with enzymes located in the mitochondrion.

PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT ?disease WHERE {
  ?protein a up:Protein ;
           up:organism taxon:9606 ;
           up:annotation ?disease_annotation , ?subcellularLocation .
  {
    ?protein up:enzyme [] .
  } UNION {
    ?protein up:annotation/a up:Catalytic_Activity_Annotation .
  }
  ?disease_annotation a up:Disease_Annotation ;
                    up:disease ?disease .
  ?subcellularLocation a up:Subcellular_Location_Annotation ;
                       up:locatedIn ?location .
  ?location up:cellularComponent ?component .
  ?component up:partOf* <http://purl.uniprot.org/locations/173> .
}


Question: Find human genetic diseases that are related to a natural variant located on the active site of an enzyme.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  DISTINCT
   ?disease
WHERE {
  ?protein a up:Protein ;
    up:organism taxon:9606 ;
    up:annotation ?disease_annotation, ?active_site_annotation, ?natural_variant_annotation .
  {
    ?protein up:enzyme [] .
  } UNION {
  ?protein up:annotation/a up:Catalytic_Activity_Annotation .
  }
  ?disease_annotation a up:Disease_Annotation ;
  up:disease ?disease .
  ?active_site_annotation a up:Active_Site_Annotation ;
  up:range ?active_site_range .
  ?active_site_range faldo:begin ?active_site_begin .
  ?active_site_begin faldo:position ?active_site_position ;
                     faldo:reference ?sequence .
  ?natural_variant_annotation a up:Natural_Variant_Annotation ;
  up:range ?natural_variant_range ;
  skos:related ?disease .
  ?natural_variant_range faldo:begin ?natural_variant_begin ;
                         faldo:end ?natural_variant_end .
  ?natural_variant_begin faldo:position ?natural_variant_begin_position .
  ?natural_variant_end faldo:position ?natural_variant_end_position ;
                       faldo:reference ?sequence .
  FILTER(?natural_variant_begin_position >= ?active_site_position && ?active_site_position <= ?natural_variant_end_position)
}


Question: How many distinct extinct organisms are represented in UniProtKB?

PREFIX keywords: <http://purl.uniprot.org/keywords/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?taxon
  (SAMPLE(?name) AS ?anName)
  (COUNT(DISTINCT ?protein) AS ?entriesPerExtinctTaxon)
WHERE
{
  GRAPH <http://sparql.uniprot.org/taxonomy> {
    ?taxon a up:Taxon ;
           up:scientificName ?name .
  }
  ?protein up:organism ?taxon ;
           up:classifiedWith keywords:952 .
} GROUP BY ?taxon ORDER BY ?taxon


Question: How many unique Rhea transport reactions are annotated in reviewed UniProtKB entries?

PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
(COUNT(DISTINCT ?rhea) AS ?distinctRheaTransportInUniProt)
WHERE
{
  GRAPH <https://sparql.rhea-db.org/rhea> {
    ?rhea rh:isTransport true .
  }
  ?protein up:annotation ?ann .
  ?ann up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?rhea .
}


Question: Generate a draft human metabolome.

PREFIX chebislash: <http://purl.obolibrary.org/obo/chebi/>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
?uniprot ?mnemonic ?rhea ?chebi ?smiles ?inchiKey
WHERE
{
  ?uniprot up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea ;
        up:organism taxon:9606 ;
        up:mnemonic ?mnemonic .
  SERVICE <https://sparql.rhea-db.org/sparql> {
	?rhea rh:side/rh:contains/rh:compound ?compound .
    ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?chebi .
   }
   ?chebi chebislash:smiles ?smiles ;
          chebislash:inchikey ?inchiKey .
}


Question: Which enzymes catalyze reactions involving molecules similar to dopamine?

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?rhea
  ?chebi
WHERE {
  # Use the smiles of dopamine CHEBI:18243
  SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/chebi>{
    ?chebi sachem:similarCompoundSearch [
      sachem:query "NCCc1ccc(O)c(O)c1" ] .
  }
  GRAPH<https://sparql.rhea-db.org/rhea>{
    ?rhea rh:side/rh:contains/rh:compound ?compound .
    ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?chebi .
  }
  ?protein up:reviewed true ;
    up:annotation ?caa .
  ?caa up:catalyticActivity/up:catalyzedReaction ?rhea .
}


Question: Which enzymes catalyze reactions involving molecules similar to dopamine and have natural variants related to diseases?

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?rhea
  ?chebi
  ?disease
WHERE {
  # Use the SMILES of dopamine CHEBI:18243
  SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/chebi> {
    ?chebi sachem:similarCompoundSearch [
      sachem:query "NCCc1ccc(O)c(O)c1" ] .
  }
  GRAPH <https://sparql.rhea-db.org/rhea> {
    ?rhea rh:side/rh:contains/rh:compound ?compound .
    ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?chebi .
  }
  ?protein up:reviewed true ;
    up:annotation ?caa, ?natural_variant_annotation, ?disease_annotation .
  ?caa up:catalyticActivity/up:catalyzedReaction ?rhea .
  ?natural_variant_annotation a up:Natural_Variant_Annotation ;
    skos:related ?disease .
  ?disease_annotation a up:Disease_Annotation ;
     up:disease ?disease .
}


Question: Select a mapping of UniProtKB enzymes to PDB entries using the UniProtKB cross-references to the PDB database.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
  ?db
WHERE
{
  ?protein a up:Protein .
  ?protein rdfs:seeAlso ?db .
  ?db up:database <http://purl.uniprot.org/database/PDB> .
  {
    ?protein up:enzyme ?enzyme .
  } UNION {
    ?protein up:annotation/rdf:type up:Catalytic_Activity_Annotation .
  }
}


Question: Select Enzyme Classification (EC) classes that have an associated protein.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  DISTINCT ?enzyme
WHERE {
  ?protein a up:Protein .
  {
    ?protein up:enzyme ?enzyme .
  } UNION {
    ?protein up:annotation ?caa .
    ?caa a up:Catalytic_Activity_Annotation .
    ?caa up:catalyticActivity ?ca .
    ?ca up:enzymeClass ?enzyme
  } UNION {
    ?protein up:component/up:enzyme ?enzyme .
  } UNION {
    ?protein up:domain/up:enzyme ?enzyme .
  }
}


Question: Find Hydrolases (enzymes that catalyse the hydrolysis of various bonds) that have at least two transmembrane domains.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein
WHERE {
 ?protein up:enzyme|up:annotation/up:catalyticActivity/up:enzymeClass ?enzymeClass ;
                   up:annotation ?transMembraneAnnotation .
 ?enzymeClass rdfs:subClassOf <http://purl.uniprot.org/enzyme/3.-.-.-> .
 ?transMembraneAnnotation a up:Transmembrane_Annotation .
} GROUP BY ?protein HAVING (COUNT(DISTINCT ?transMembraneAnnotation) >= 2)


Question: Find enzymes that have at least two transmembrane domains and whose 3D structure has been determined by X-Ray crystallography.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein
WHERE {
  ?protein a up:Protein ;
           up:annotation ?transmembrane_annotation ;
           rdfs:seeAlso ?wwPDB .
  {
    ?protein up:enzyme ?enzyme .
  } UNION {
    ?protein up:annotation/a up:Catalytic_Activity_Annotation .
  }
  ?wwPDB up:database <http://purl.uniprot.org/database/PDB> ;
        up:method up:X-Ray_Crystallography .
  ?transmembrane_annotation a up:Transmembrane_Annotation .
} GROUP BY ?protein HAVING(COUNT(DISTINCT ?transmembrane_annotation) >= 2)


Question: Find enzymes where the active site overlaps with regions affected by mutagenesis, and show the comment regarding the mutagenesis effect.

PREFIX faldo: <http://biohackathon.org/resource/faldo#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?protein ?mutagenesisBeginPosition ?activeSiteBeginPosition ?mutagenesisRangeEndPosition ?mutagenesisComment
WHERE {
  ?protein up:annotation ?activeSiteAnnotation ,
      ?mutagenesisAnnotation .
  ?mutagenesisAnnotation a up:Mutagenesis_Annotation ;
     up:range ?mutagenesisRange ;
	 rdfs:comment ?mutagenesisComment .
  ?activeSiteAnnotation a up:Active_Site_Annotation ;
    up:range ?activeSiteRange .
  ?activeSiteRange faldo:begin ?activeSiteBegin .
  ?activeSiteBegin faldo:position ?activeSiteBeginPosition ;
    faldo:reference ?sequence .
  ?mutagenesisRange faldo:begin ?mutagenesisRangeBegin ;
    faldo:end ?mutagenesisRangeEnd .
  ?mutagenesisRangeBegin faldo:position ?mutagenesisBeginPosition ;
    faldo:reference ?sequence .
  ?mutagenesisRangeEnd faldo:position ?mutagenesisRangeEndPosition .
  FILTER(?mutagenesisBeginPosition <= ?activeSiteBeginPosition && ?activeSiteBeginPosition <= ?mutagenesisRangeEndPosition)
}


Question: List all UniProtKB proteins annotated as related to a genetic disease.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?uniprot ?disease ?diseaseComment ?mim
WHERE
{
  GRAPH <http://sparql.uniprot.org/uniprot> {
    ?uniprot a up:Protein ;
       up:annotation ?diseaseAnnotation .
    ?diseaseAnnotation up:disease ?disease .
  }
  GRAPH <http://sparql.uniprot.org/diseases> {
    ?disease a up:Disease ;
             rdfs:comment ?diseaseComment .
    OPTIONAL {
      ?disease rdfs:seeAlso ?mim .
       ?mim up:database <http://purl.uniprot.org/database/MIM> .
    }
  }
}


Question: List all UniProtKB protein IDs (mnemonics) for current UniProtKB entries.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?uniprot ?mnemonic
WHERE
{
  GRAPH <http://sparql.uniprot.org/uniprot> {
        ?uniprot a up:Protein ;
            up:mnemonic ?mnemonic .
    }
}


Question: List all UniProtKB protein IDs (mnemonics) that were used in the past for current UniProtKB entries.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?uniprot ?obsoleteMnemonic
WHERE
{
  GRAPH <http://sparql.uniprot.org/uniprot> {
        ?uniprot a up:Protein ;
            up:oldMnemonic ?obsoleteMnemonic .
    }
}


Question: Find all Rhea reactions involving only small molecules that are used in UniProtKB, where the annotation has a paper and is supported by experimental evidence.

PREFIX ECO: <http://purl.obolibrary.org/obo/ECO_>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?rhea
  ?catalyzedReaction
  ?source
WHERE {
  {
    SELECT
      DISTINCT
        ?rhea
      WHERE {
        GRAPH <https://sparql.rhea-db.org/rhea> {
          ?rhea rdfs:subClassOf rh:Reaction .
          ?rhea rh:side/rh:contains/rh:compound ?compound2 .
          ?uc rdfs:subClassOf rh:Compound .
        }
        ?compound2 rdfs:subClassOf ?uc .
        BIND(IF(?uc = rh:SmallMolecule, 0, 1) AS ?c)
      } GROUP BY ?rhea  HAVING (SUM(?c) = 0)
  }
  ?catalyzedReaction up:catalyzedReaction ?rhea .
  ?reif rdf:object ?catalyzedReaction ;
        up:attribution ?attr .
  ?attr up:evidence ECO:0000269 ;
        up:source ?source .
  ?source a up:Citation .
}


Question: List Rhea reactions associated with an EC (enzyme classification) in UniProtKB.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?rhea
  ?EC
WHERE {
  ?CatalyticActivity  up:catalyzedReaction   ?rhea ;
    up:enzymeClass         ?EC .
}


Question: List Rhea reactions that are not associated with an EC (enzyme classification) in UniProtKB.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?rhea
  ?EC
WHERE {
  ?CatalyticActivity up:catalyzedReaction ?rhea .
  MINUS {
    ?CatalyticActivity up:enzymeClass ?EC .
  }
}


Question: Find all species that belong to the genus Homo in the taxonomic hierarchy.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?species
WHERE {
  BIND(taxon:9605 AS ?genus)
  ?species a up:Taxon ;
           up:rank up:Species ;
           rdfs:subClassOf ?genus .
  ?genus a up:Taxon ;
         up:rank up:Genus .
}


Question: Find taxon records that have part of their life cycle in other organisms, such as parasites, symbionts, or infections.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?virus
  ?host
WHERE {
    ?virus up:host ?host .
}


Question: Retrieve the rank and the scientific name of taxonomic records. Note that not all taxonomic records have a rank associated with them.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?taxon
  ?scientificName
  ?rank
WHERE {
  ?taxon a up:Taxon ;
         up:scientificName ?scientificName .
  OPTIONAL {
    ?taxon up:rank ?rank
  }
}


Question: Find taxon records that have at least one reviewed UniProtKB/Swiss-Prot entry. The taxon list may include species, strains, subspecies, and isolates.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT DISTINCT ?taxid ?scientificName ?domain ?domainName WHERE {
  ?uniprot a up:Protein .
  ?uniprot up:reviewed true .
  ?uniprot up:organism ?taxid .
  ?taxid up:scientificName ?scientificName .
  VALUES ?domain { taxon:2 taxon:2157 taxon:2759 taxon:10239 } .
  ?taxid rdfs:subClassOf ?domain .
}


Question: For the UniParc accession UPI000002DB1C, show which active UniProtKB entries have the same amino acid sequence.

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?uniparc
  ?uniprot
WHERE {
  GRAPH <http://sparql.uniprot.org/uniparc>{
    BIND(<http://purl.uniprot.org/uniparc/UPI000002DB1C> AS ?uniparc)
    ?uniparc up:sequenceFor ?uniprot .
  }
  GRAPH <http://sparql.uniprot.org/uniprot> {
    ?uniprot a up:Protein .
  }
}


Question: What are the predicates and objects directly associated with the UniParc accession UPI000012A0AD?

PREFIX up: <http://purl.uniprot.org/core/>
SELECT
  ?predicate
  ?object
WHERE {
  <http://purl.uniprot.org/uniparc/UPI000012A0AD> ?predicate ?object
}


Question: Find UniProtKB proteins involved in metabolic diseases using the MeSH concept for 'Metabolic Diseases'.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
 ?disease ?protein
WHERE {
  SERVICE <https://id.nlm.nih.gov/mesh/sparql> {
    GRAPH <http://id.nlm.nih.gov/mesh> {
      # MeSH M0013493 represents the concept 'Metabolic Diseases'
      ?mesh <http://id.nlm.nih.gov/mesh/vocab#broaderDescriptor>* <http://id.nlm.nih.gov/mesh/M0013493> .
    }
  }
  GRAPH <http://sparql.uniprot.org/diseases> {
    ?disease a up:Disease ;
      rdfs:seeAlso ?mesh .
    ?mesh up:database <http://purl.uniprot.org/database/MeSH> .
  }
  GRAPH <http://sparql.uniprot.org/uniprot> {
    ?protein up:annotation/up:disease ?disease .
  }
}


Question: What are the alternative full names for UniProtKB protein entries?

PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?protein ?fullName
WHERE {
  ?protein a up:Protein ;
           up:alternativeName ?recommendedName .
  ?recommendedName up:fullName ?fullName .
}