SPARQL example query
180_subcellular_location_ancestors: Find every broader subcellular location reachable from a given one (here, Endosome membrane, locations:100). The location hierarchy mixes rdfs:subClassOf (is-a) and up:partOf (part-of) edges, so both have to be chained together - rdfs:subClassOf*/up:partOf+/rdfs:subClassOf* - to reach the full set of ancestors; using only one of the two misses e.g. Endosome (is-a) or Membrane (part-of, then is-a)
PREFIX up: <http://purl.uniprot.org/core/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT ?ancestor ?ancestorName WHERE { GRAPH <http://sparql.uniprot.org/locations> { <http://purl.uniprot.org/locations/100> rdfs:subClassOf*/up:partOf+/rdfs:subClassOf* ?ancestor . ?ancestor skos:prefLabel ?ancestorName . } }Use181_subcellular_locations_that_are_membranes: Find every subcellular location that is itself a kind of membrane, by reasoning back to locations:162 ("Membrane") over the same mixed rdfs:subClassOf/up:partOf hierarchy as #180. Nothing states directly that e.g. Endosome membrane "is a membrane" - it has to be derived by following the location hierarchy up to the Membrane term
PREFIX up: <http://purl.uniprot.org/core/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT ?location ?locationName WHERE { GRAPH <http://sparql.uniprot.org/locations> { ?location rdfs:subClassOf*/up:partOf+/rdfs:subClassOf* <http://purl.uniprot.org/locations/162> ; skos:prefLabel ?locationName . } }Use182_reviewed_proteins_by_ec_class: Count reviewed proteins classified anywhere under EC class 2.7 (transferases that transfer phosphorus-containing groups, e.g. kinases), matched either directly via up:enzyme or through a catalytic-activity annotation's Rhea-linked enzyme classification. EC subclasses are materialized in UniProt's data, so this is done with a plain rdfs:subClassOf join against the whole 2.7.-.- subtree rather than an rdfs:subClassOf+ transitive path or a STRSTARTS string-prefix filter on the EC IRI
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT (COUNT(DISTINCT ?protein) AS ?count) WHERE { ?protein up:reviewed true ; up:enzyme|up:annotation/up:catalyticActivity/up:enzymeClass ?ecNumber . ?ecNumber rdfs:subClassOf <http://purl.uniprot.org/enzyme/2.7.-.-> }Use183_protein_count_by_clade_single_hop: Compare the number of reviewed proteins in two named taxonomic clades (Primates, Rodentia), using a single-hop ?organism rdfs:subClassOf ?clade rather than the transitive rdfs:subClassOf+ or rdfs:subClassOf* form. UniProt's taxonomy is pre-flattened: every taxon carries a direct rdfs:subClassOf edge to every one of its ancestors, not only its immediate parent (verified live: taxon 9606, Homo sapiens, has 30 direct rdfs:subClassOf triples, one per ancestor up to cellular organisms), so a single hop already reaches every member of a clade at any depth and is far cheaper than the transitive path
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?clade ?cladeName (COUNT(DISTINCT ?protein) AS ?proteinCount) WHERE { VALUES ?clade { <http://purl.uniprot.org/taxonomy/9443> <http://purl.uniprot.org/taxonomy/9989> } ?clade up:scientificName ?cladeName . ?protein up:reviewed true ; up:organism ?organism . ?organism rdfs:subClassOf ?clade . } GROUP BY ?clade ?cladeNameUse184_multiple_annotation_types_via_faldo: Retrieve several different kinds of positional annotation (modified residues, domains, binding sites) together in one query, each one's sequence range resolved through FALDO in the same WHERE clause, instead of writing one query per annotation type. The candidate types are listed with VALUES rather than bound to a variable and checked with FILTER(?annotType IN (...)): live against sparql.uniprot.org, the FILTER(IN) form was slow and unstable (anywhere from 14s to over a minute, sometimes timing out outright), while VALUES consistently answered in a few seconds
PREFIX up: <http://purl.uniprot.org/core/> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> PREFIX faldo: <http://biohackathon.org/resource/faldo#> SELECT ?protein ?annotType ?begin ?end WHERE { VALUES ?annotType { up:Modified_Residue_Annotation up:Domain_Annotation up:Binding_Site_Annotation } ?protein a up:Protein ; up:organism taxon:9606 ; up:reviewed true ; up:annotation ?annotation . ?annotation a ?annotType ; up:range ?range . ?range faldo:begin/faldo:position ?begin ; faldo:end/faldo:position ?end . } LIMIT 20Use185_proteins_by_keyword_complete_enumeration: Count reviewed proteins classified with the controlled-vocabulary keyword Kinase (keywords:418) via up:classifiedWith. This is the complete route to "every kinase": a free-text search over protein names or comments for the word "kinase" would miss proteins named with the synonym "Phosphotransferase" (keywords:418's own skos:altLabel) instead, while curator-assigned keyword classification catches both consistently
PREFIX up: <http://purl.uniprot.org/core/> PREFIX keywords: <http://purl.uniprot.org/keywords/> SELECT (COUNT(DISTINCT ?protein) AS ?count) WHERE { ?protein up:reviewed true ; up:classifiedWith keywords:418 . }Use186_ensembl_gene_biotype_and_location: Given a UniProt protein (human TP53, P04637), federate out to Ensembl's own RDF at RDF Portal to retrieve its gene's biotype and genomic location (begin/end via FALDO). UniProt only holds the Ensembl gene identifier locally (up:transcribedFrom); the gene's own attributes - biotype, genomic coordinates - only exist in Ensembl's RDF, not UniProt's. Note: up:transcribedFrom's object is a *versioned* Ensembl gene IRI (e.g. .../ENSG00000141510.20), but RDF Portal's Ensembl graph identifies the gene by its *unversioned* IRI, so a direct IRI join between the two silently returns nothing; matching via rdfs:seeAlso from the protein (as done here), filtered to the ensembl:EnsemblGene type to exclude transcripts, avoids that mismatch
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX ensembl: <http://rdf.ebi.ac.uk/terms/ensembl/> PREFIX faldo: <http://biohackathon.org/resource/faldo#> SELECT ?gene ?biotype ?begin ?end WHERE { BIND(<http://purl.uniprot.org/uniprot/P04637> AS ?protein) SERVICE <https://rdfportal.org/ebi/sparql> { ?gene a ensembl:EnsemblGene ; rdfs:seeAlso ?protein ; ensembl:has_biotype ?biotype ; faldo:location ?location . ?location faldo:begin/faldo:position ?begin ; faldo:end/faldo:position ?end . } }Use187_reactome_pathways_via_ensembl_gene: Given a UniProt protein (human TP53, P04637), list the Reactome pathways it participates in, reached via its Ensembl gene's own rdfs:seeAlso links at RDF Portal. This is a federated alternative to any pathway cross-references UniProt exposes directly: the Ensembl gene resource carries rdfs:seeAlso triples both back to the UniProt protein and out to each Reactome pathway identifier, so matching on the shared gene resource joins the two
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX ensembl: <http://rdf.ebi.ac.uk/terms/ensembl/> SELECT ?gene ?reactomePathway WHERE { BIND(<http://purl.uniprot.org/uniprot/P04637> AS ?protein) SERVICE <https://rdfportal.org/ebi/sparql> { ?gene a ensembl:EnsemblGene ; rdfs:seeAlso ?protein ; rdfs:seeAlso ?reactomePathway . FILTER(STRSTARTS(STR(?reactomePathway), "http://identifiers.org/reactome/")) } } LIMIT 20Use188_batch_gene_symbol_to_uniprot_and_ensembl: Given a batch of human gene symbols (TP53, BRCA1, EGFR), resolve each to its Ensembl gene ID and reviewed UniProt accession in one federated query - the closest direct analogue to biomaRt's getBM() across two live SPARQL endpoints instead of one local database. Gene symbols and the Ensembl gene resource itself only exist in Ensembl's own RDF, so the symbol-to-gene match happens inside the SERVICE clause; restricting to human (RO_0002162, in-taxon) avoids matching the same symbol used for orthologous genes in other species, and the up:reviewed true filter (evaluated locally, since ?protein is already bound to a UniProt IRI) keeps one canonical accession per gene rather than every isoform
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX ensembl: <http://rdf.ebi.ac.uk/terms/ensembl/> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX obo: <http://purl.obolibrary.org/obo/> SELECT DISTINCT ?symbol ?ensemblGeneId ?protein WHERE { SERVICE <https://rdfportal.org/ebi/sparql> { VALUES ?symbol { "TP53" "BRCA1" "EGFR" } ?gene a ensembl:EnsemblGene ; rdfs:label ?symbol ; dcterms:identifier ?ensemblGeneId ; obo:RO_0002162 <http://identifiers.org/taxonomy/9606> ; rdfs:seeAlso ?protein . FILTER(STRSTARTS(STR(?protein), "http://purl.uniprot.org/uniprot/")) } ?protein up:reviewed true . } ORDER BY ?symbolUse189_pseudokinases: Find reviewed human pseudokinases: proteins with an annotated protein kinase domain but no annotated kinase (phosphotransferase) catalytic activity at all - a real, well-known biological category (catalytically-dead kinase domains repurposed for scaffolding/allosteric regulation, e.g. Tribbles homologs). The kinase domain itself is a up:Domain_Extent_Annotation whose rdfs:comment names it ("Protein kinase", sometimes qualified "; inactive" or "; truncated")
PREFIX up: <http://purl.uniprot.org/core/> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?protein ?domainComment WHERE { ?protein up:reviewed true ; up:organism taxon:9606 ; up:annotation ?domain . ?domain a up:Domain_Extent_Annotation ; rdfs:comment ?domainComment . FILTER(CONTAINS(?domainComment, "Protein kinase")) FILTER(NOT EXISTS { ?protein up:enzyme|up:annotation/up:catalyticActivity/up:enzymeClass ?ec . ?ec rdfs:subClassOf <http://purl.uniprot.org/enzyme/2.7.-.-> }) }Use190_ion_channels_associated_with_disease: Find reviewed proteins classified with the Ion channel keyword that are also linked to a disease, and name the disease - combining a structural/functional classification with clinical relevance
PREFIX up: <http://purl.uniprot.org/core/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX keywords: <http://purl.uniprot.org/keywords/> SELECT ?protein ?diseaseName WHERE { ?protein up:reviewed true ; up:classifiedWith keywords:407 ; up:annotation ?disease . ?disease a up:Disease_Annotation ; up:disease ?d . ?d skos:prefLabel ?diseaseName . }Use191_calcium_dependent_enzymes_with_binding_site: Find reviewed enzymes that both require Ca(2+) as a cofactor and have an annotated calcium-binding site - two distinct annotation types (a stated cofactor requirement vs. an explicit structural binding-site position) corroborating each other for the same ion. Both sides are matched by the actual ChEBI identity of calcium(2+) (CHEBI:29108), not by name text: up:cofactor points directly at the ChEBI IRI, while a binding site's up:ligand is an instance further typed via rdfs:subClassOf to the ChEBI class
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_> SELECT DISTINCT ?protein WHERE { BIND(CHEBI:29108 AS ?calcium) ?protein up:reviewed true ; up:enzyme ?ec ; up:annotation ?cofactor ; up:annotation ?binding . ?cofactor a up:Cofactor_Annotation ; up:cofactor ?calcium . ?binding a up:Binding_Site_Annotation ; up:ligand ?ligand . ?ligand rdfs:subClassOf ?calcium . }Use192_multifunctional_enzymes: Find reviewed multifunctional (multi-catalytic) enzymes: proteins annotated with more than one distinct EC number via up:enzyme or up:catalyticActivity - real biology (e.g. bifunctional enzymes in a biosynthetic pathway, or moonlighting enzymes), not just an EC-number-format curiosity.
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?protein (COUNT(DISTINCT ?ec) AS ?ecCount) WHERE { ?protein up:reviewed true ; up:enzyme|up:annotation/up:catalyticActivity/up:enzymeClass ?ec . } GROUP BY ?protein HAVING (COUNT(DISTINCT ?ec) > 1)Use193_book_citation_bibliographic_record: Find the full bibliographic record of a book chapter cited as evidence for a protein annotation: title, authors, editors, publisher, place and pages — distinct from the PubMed-ID-focused journal citation example (#19)
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?protein ?citation ?title (GROUP_CONCAT(DISTINCT ?author; separator=", ") AS ?authors) (GROUP_CONCAT(DISTINCT ?editor; separator=", ") AS ?editors) (SAMPLE(?publisher) AS ?onePublisher) (SAMPLE(?place) AS ?onePlace) (SAMPLE(?pages) AS ?onePages) WHERE { ?protein a up:Protein ; up:annotation ?annotation . ?linkToEvidence rdf:object ?annotation ; up:attribution ?attribution . ?attribution up:source ?citation . ?citation a up:Book_Citation ; up:title ?title ; up:author ?author ; up:pages ?pages . OPTIONAL { ?citation up:editor ?editor } OPTIONAL { ?citation up:publisher ?publisher } OPTIONAL { ?citation up:place ?place } } GROUP BY ?protein ?citation ?titleUse194_citation_erratum_chain: Find publications that have a published erratum/correction, linking the original citation to its corrigendum
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?citation ?title ?erratum ?erratumTitle WHERE { ?citation up:erratum ?erratum ; up:title ?title . ?erratum up:title ?erratumTitle . }Use195_submission_citation_database: Find proteins backed by a direct-submission citation, and which database (e.g. EMBL/GenBank/DDBJ, PDB) that submission was made to
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT DISTINCT ?protein ?citation ?title ?database ?date WHERE { ?protein a up:Protein ; up:annotation ?annotation . ?linkToEvidence rdf:object ?annotation ; up:attribution ?attribution . ?attribution up:source ?citation . ?citation a up:Submission_Citation ; up:title ?title ; up:submittedTo ?database ; up:date ?date . }Use196_proteome_related_by_similarity_score: Find the most closely related proteomes and the similarity score behind that relation. The score is not attached directly to the up:relatedProteome triple but to its RDF reification (rdf:Statement with matching rdf:subject/rdf:predicate/rdf:object)
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?proteome ?related ?score WHERE { ?proteome up:relatedProteome ?related . ?statement a rdf:Statement ; rdf:subject ?proteome ; rdf:predicate up:relatedProteome ; rdf:object ?related ; up:relatedProteomeSimilarityScore ?score . } ORDER BY DESC(?score)Use197_proteome_panproteome_taxon: Given a strain-level proteome, find the taxon of the pan-proteome (species/strain group) it belongs to. up:panproteomeTaxon points directly at the Taxon
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?proteome ?organismName ?panproteomeTaxon ?panproteomeTaxonName WHERE { ?proteome up:organism ?organism ; up:panproteomeTaxon ?panproteomeTaxon . ?organism up:scientificName ?organismName . ?panproteomeTaxon up:scientificName ?panproteomeTaxonName . }Use198_sequence_integrity_metadata: For reviewed human proteins, get the mass and MD5 checksum recorded on the canonical sequence together with the sequence length recorded on the corresponding UniParc entry — the kind of 'does this sequence match what I have locally' check downstream tooling actually runs
PREFIX up: <http://purl.uniprot.org/core/> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> SELECT ?protein ?mass ?md5Checksum ?length WHERE { ?protein a up:Protein ; up:organism taxon:9606 ; up:reviewed true ; up:sequence ?sequence . ?sequence up:mass ?mass ; up:md5Checksum ?md5Checksum . ?uniparc up:sequenceFor ?protein ; up:length ?length . }Use199_cds_sequence_discrepancy_note: Find a protein's cross-referenced CDS/nucleotide entry that disagrees with the reviewed Swiss-Prot sequence, together with the curator's note on why (e.g. different initiation, sequence problems, frameshift) — real curation-quality content, distinct from modeling detail
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?protein ?nucleotideEntry ?note WHERE { ?protein a up:Protein ; up:reviewed true ; rdfs:seeAlso ?nucleotideEntry . ?nucleotideEntry a up:Nucleotide_Resource ; up:sequenceDiscrepancy ?discrepancy . ?discrepancy rdfs:comment ?note . }Use200_protein_conflicting_external_sequence: Find a protein's conflicting sequence: an alternative translation from a nucleotide entry that another group submitted, which disagrees with UniProt's own reviewed sequence for the same protein
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?protein ?externalSequence ?translatedFrom WHERE { ?protein a up:Protein ; up:conflictingSequence ?externalSequence . ?externalSequence a up:External_Sequence ; up:translatedFrom ?translatedFrom . }Use201_isoform_modified_sequence_basis: Find a protein's modified (spliced) isoform sequence, the canonical sequence it is based on, and the alternative-splicing event annotation describing the difference between them
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT ?protein ?modifiedSequence ?canonicalSequence ?modification ?description WHERE { ?protein a up:Protein ; up:sequence ?modifiedSequence . ?modifiedSequence a up:Modified_Sequence ; up:basedOn ?canonicalSequence ; up:modification ?modification . ?modification rdfs:comment ?description . }Use202_uniparc_sequence_cluster_membership: Find which UniRef clusters a specific sequence (identified by its UniParc entry) is a member of, using up:memberOf on the sequence itself. Distinct from the existing UniRef common-taxon example (#162), which starts from the cluster and asks for its up:member sequences — this starts from the sequence and asks which clusters it belongs to
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?uniparc ?cluster WHERE { ?uniparc up:sequenceFor <http://purl.uniprot.org/uniprot/P04637> ; up:memberOf ?cluster . }Use203_cross_reference_url_reconstruction: For proteins cross-referenced to the AbasyAtlas database, reconstruct a working link to the external record by substituting the cross-reference's own identifier into that database's up:urlTemplate — exactly the kind of thing external tooling needs and currently has to hardcode per-database
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?protein ?xref ?identifier ?urlTemplate ?constructedUrl WHERE { BIND(<http://purl.uniprot.org/database/AbasyAtlas> AS ?database) ?database up:linkIsExplicit true ; up:urlTemplate ?urlTemplate . ?protein a up:Protein ; rdfs:seeAlso ?xref . ?xref up:database ?database . BIND(REPLACE(STR(?xref), "^.*/", "") AS ?identifier) BIND(IRI(REPLACE(?urlTemplate, "%u", ?identifier)) AS ?constructedUrl) }Use204_taxon_name_variants: Find taxa with recorded name variants beyond their primary scientific name: a taxonomic synonym (an earlier or alternative Latin name for the same taxon) and other recorded name forms such as author citations or authority strings
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?taxon ?name (GROUP_CONCAT(DISTINCT ?syn; separator="; ") AS ?synonyms) (GROUP_CONCAT(DISTINCT ?other; separator="; ") AS ?otherNames) WHERE { ?taxon up:scientificName ?name . OPTIONAL { ?taxon up:synonym ?syn } OPTIONAL { ?taxon up:otherName ?other } FILTER(BOUND(?syn) || BOUND(?other)) } GROUP BY ?taxon ?nameUse205_taxon_abbreviated_lineage_flag: For human (taxon 9606), list every ancestor taxon in its lineage and whether that taxon is shown in UniProt's abbreviated lineage view (up:partOfLineage), as opposed to the full, non-abbreviated set of ancestors. Pairs with #183: since UniProt's taxonomy is pre-flattened, a single-hop rdfs:subClassOf already reaches every ancestor at any depth
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> SELECT ?ancestor ?ancestorName ?partOfLineage WHERE { taxon:9606 rdfs:subClassOf ?ancestor . ?ancestor up:scientificName ?ancestorName . OPTIONAL { ?ancestor up:partOfLineage ?partOfLineage } } ORDER BY DESC(?partOfLineage)Use