question: Select all taxa from the UniProt taxonomy.

sparql:
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.

sparql:
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.

sparql:
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'.

sparql:
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.

sparql:
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)'.

sparql:
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'.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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?

sparql:
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?

sparql:
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.

sparql:
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.

sparql:
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?

sparql:
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.

sparql:
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.

sparql:
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?

sparql:
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?

sparql:
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'.

sparql:
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'.

sparql:
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.

sparql:
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: List the creation date, last modified date, and last sequence update version for UniProtKB proteins.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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: Find Drosophila proteins that are derived from at least two different transcripts, based on cross-references to Ensembl family resources.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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: Find UniProtKB entries with merged loci in Bordetella avium.

sparql:
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 UniProtKB entries with more than one Topological domain annotation.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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 human protein that contains the epitope VSTQ, where the threonine (T) is phosphorylated.

sparql:
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: Retrieve UniProtKB entries with sequences that are not composed of fragments.

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


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

sparql:
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: Find UniProtKB entries with a transmembrane region that have an alanine in the 15 amino acid region preceding the transmembrane segment.

sparql:
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: How many proteins have binding sites for metals or metal sulfur clusters with experimental evidence for the binding?

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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?

sparql:
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: Select the sets of Ensembl genes, human UniProtKB proteins, and catalyzed Rhea reactions.

sparql:
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.

sparql:
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: How can I extract the UniProtKB primary accession from UniProt protein IRIs using SPARQL?

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.

sparql:
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?

sparql:
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?

sparql:
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).

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


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

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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: Select a mapping of UniProtKB enzymes to PDB entries using the UniProtKB cross-references to the PDB database.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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 Rhea reactions associated with an EC (enzyme classification) in UniProtKB.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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.

sparql:
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: What are the predicates and objects directly associated with the UniParc accession UPI000012A0AD?

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


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

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