SPARQL example query
205_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)Use206_alternative_name_kinds: Find proteins with a name of a specific, distinct naming convention beyond the ordinary recommended/alternative name pair: an allergen name (with the allergen nomenclature this comes from), a CD antigen name (HCDM nomenclature, e.g. for cell-surface markers), or an INN (international nonproprietary name, the standard name for a pharmaceutical substance such as a therapeutic antibody)
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?protein ?kind ?name WHERE { ?protein up:alternativeName ?altName . { ?altName up:allergenName ?name . BIND("allergen" AS ?kind) } UNION { ?altName up:cdAntigenName ?name . BIND("CD antigen" AS ?kind) } UNION { ?altName up:internationalNonproprietaryName ?name . BIND("INN" AS ?kind) } }Use207_catalytic_activity_physiological_reaction: Find the physiological reaction (the direction/reaction an enzyme actually performs in vivo) associated with a catalytic activity annotation, using up:catalyzedPhysiologicalReaction, distinct from the general reaction the enzyme is capable of catalyzing (up:catalyzedReaction)
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?protein ?activity ?physReaction WHERE { ?protein a up:Protein ; up:annotation ?activity . ?activity a up:Catalytic_Activity_Annotation ; up:catalyzedPhysiologicalReaction ?physReaction . }Use208_absorption_maximum_and_certainty: Find a protein's reported absorption maximum wavelength (up:maximum, in nm) together with up:certain, a qualifier flagging whether that reported value is certain or approximate
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?protein ?maxWavelength ?certain WHERE { ?protein a up:Protein ; up:annotation ?annotation . ?annotation a up:Absorption_Annotation ; up:maximum ?maxWavelength . OPTIONAL { ?annotation up:certain ?certain } }Use209_xenologous_interaction: Find protein-protein interactions flagged as xenologous (up:xeno), i.e. between molecules from different species, such as a host protein interacting with a pathogen protein — as opposed to an interaction between proteins of the same organism
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?protein ?interaction ?xeno WHERE { ?protein a up:Protein ; up:interaction ?interaction . ?interaction a up:Non_Self_Interaction ; up:xeno ?xeno . }Use210_mass_spectrometry_measured_value: Find a protein's mass spectrometry annotation with its measured mass (up:measuredValue) and, where recorded, the measurement's error margin (up:measuredError)
PREFIX up: <http://purl.uniprot.org/core/> SELECT ?protein ?annotation ?measuredValue ?measuredError WHERE { ?protein a up:Protein ; up:annotation ?annotation . ?annotation a up:Mass_Spectrometry_Annotation ; up:measuredValue ?measuredValue . OPTIONAL { ?annotation up:measuredError ?measuredError } }Use211_structure_resolution: Find the highest-resolution (lowest Angstrom value) experimentally determined structures cross-referenced from reviewed proteins, using up:resolution recorded on the PDB structure resource
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?protein ?structure ?resolution WHERE { ?protein a up:Protein ; up:reviewed true ; rdfs:seeAlso ?structure . ?structure a up:Structure_Resource ; up:resolution ?resolution . } ORDER BY ?resolutionUse212_enzyme_classification_replaced: Find EC (enzyme classification) numbers that have been replaced by a new EC number following reclassification, together with the new number's name. The old number itself no longer carries a name once replaced
PREFIX up: <http://purl.uniprot.org/core/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> SELECT ?oldEc ?newEc ?newName WHERE { ?oldEc up:replacedBy ?newEc . ?newEc skos:prefLabel ?newName . }Use213_protein_isolated_from_tissue: Find the tissue a protein was originally found to be expressed in from (up:isolatedFrom), distinct from its usual organism/subcellular-location annotations — the object is either a shared Tissue resource or a locally-defined (entry specific) tissue label
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> SELECT ?protein ?tissue ?tissueLabel WHERE { ?protein a up:Protein ; up:isolatedFrom ?tissue . ?tissue a up:Tissue . # A shared tissue resource carries a skos:prefLabel; a protein-local # tissue fragment (minted when no shared resource exists) carries an # rdfs:label instead. OPTIONAL { ?tissue skos:prefLabel ?tissueLabel } OPTIONAL { ?tissue rdfs:label ?tissueLabel } }Use214_proteins_starting_with_methionine: Of reviewed human proteins, how many have a stored sequence starting with methionine (the universal translation start codon), and of those, how many have that initiator methionine later cleaved off post-translationally (up:Initiator_Methionine_Annotation with comment 'Removed') rather than retained in the mature protein
PREFIX up: <http://purl.uniprot.org/core/> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT (COUNT(DISTINCT ?protein) AS ?totalReviewedHumanProteins) (SUM(IF(?startsWithMet, 1, 0)) AS ?startWithMethionine) (SUM(IF(BOUND(?initiatorMetRemoved), 1, 0)) AS ?initiatorMethionineLaterRemoved) WHERE { ?protein a up:Protein ; up:organism taxon:9606 ; up:reviewed true ; up:sequence ?sequence . ?sequence rdf:value ?seqValue . BIND(STRSTARTS(?seqValue, "M") AS ?startsWithMet) OPTIONAL { ?protein up:annotation ?initiatorMet . ?initiatorMet a up:Initiator_Methionine_Annotation ; rdfs:comment "Removed" . BIND(true AS ?initiatorMetRemoved) } }Use215_human_proteins_with_solved_structure: Count how many reviewed human proteins have at least one experimentally determined 3D structure cross-referenced from a PDB entry
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 (COUNT(DISTINCT ?protein) AS ?proteinsWithStructure) WHERE { ?protein a up:Protein ; up:organism taxon:9606 ; up:reviewed true ; rdfs:seeAlso ?structure . ?structure a up:Structure_Resource ; up:database <http://purl.uniprot.org/database/PDB> . }Use216_human_proteins_by_existence_evidence: Break down reviewed human proteins by their protein-existence evidence level (up:existence): how many are 'very well characterized' with direct evidence at the protein level, as opposed to only evidence at the transcript level, inferred from homology, predicted, or uncertain
PREFIX up: <http://purl.uniprot.org/core/> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> SELECT ?existence (COUNT(*) AS ?proteinCount) WHERE { ?protein a up:Protein ; up:organism taxon:9606 ; up:reviewed true ; up:existence ?existence . } GROUP BY ?existence ORDER BY DESC(?proteinCount)Use217_proteins_in_a_cancer_pathway: Find reviewed human proteins that are part of a cancer-related Reactome pathway (matched by the pathway's own name), using the pathway cross-reference's rdfs:comment as the pathway's human-readable name
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 ?pathway ?pathwayName WHERE { ?protein a up:Protein ; up:organism taxon:9606 ; up:reviewed true ; rdfs:seeAlso ?pathway . ?pathway up:database <http://purl.uniprot.org/database/Reactome> ; rdfs:comment ?pathwayName . FILTER(CONTAINS(?pathwayName, "Cancer")) }Use218_protein_amino_acid_composition: Count how many times each of the 20 standard amino acids occurs in human TP53's (P04637) canonical sequence, using STRLEN(sequence) minus STRLEN(sequence with that residue letter removed) as an amino-acid-counting trick rather than a per-position scan. Note: for performance over a larger set rewrite this as a huge union.
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?residue ?count WHERE { <http://purl.uniprot.org/uniprot/P04637> up:sequence ?sequence . ?sequence a up:Simple_Sequence ; rdf:value ?seq . VALUES ?residue { "A" "R" "N" "D" "C" "Q" "E" "G" "H" "I" "L" "K" "M" "F" "P" "S" "T" "W" "Y" "V" } BIND(STRLEN(?seq) - STRLEN(REPLACE(?seq, ?residue, "")) AS ?count) } ORDER BY DESC(?count)Use219_human_gene_count_vs_isoform_count: Compare the number of reviewed human UniProtKB entries (one canonical accession per gene) to the number of distinct sequence resources those entries carry (the canonical sequence plus every annotated splice isoform), showing directly why searching human in UniProt returns far more sequences than there are protein-coding genes — the full picture also includes unreviewed (TrEMBL) entries on top of this. This is also due to there being more than one 'genome' source (proteome).
PREFIX up: <http://purl.uniprot.org/core/> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> SELECT (COUNT(DISTINCT ?gene) AS ?reviewedGenes) (COUNT(DISTINCT ?isoformSequence) AS ?distinctSequences) WHERE { ?protein a up:Protein ; up:organism taxon:9606 ; up:reviewed true ; up:sequence ?isoformSequence . OPTIONAL { ?protein up:encodedBy ?gene } }Use221_ddbj_to_uniparc: Using a "genome" identifier in INSDC use the DDBJ sparql endpoint to find the CDS identifiers and link these to UniParc records
PREFIX up: <http://purl.uniprot.org/core/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX insdc: <http://ddbj.nig.ac.jp/ontologies/nucleotide/> PREFIX faldo: <http://biohackathon.org/resource/faldo#> SELECT ?ddbj ?emblCds ?uniparc WHERE { SERVICE <https://rdfportal.org/ddbj/sparql> { VALUES ?ddbj { <http://identifiers.org/insdc/OQ416313.1> } GRAPH <http://rdfportal.org/dataset/ddbj>{ ?ddbj rdf:type insdc:Entry. ?ddbj insdc:sequence ?sequence . ?position faldo:reference ?sequence . ?region faldo:begin ?position . ?cds faldo:location ?region ; a insdc:Coding_Sequence ; rdfs:seeAlso ?potentialProtein . BIND(STR(?potentialProtein) AS ?potentialProteinStr) FILTER(STRSTARTS(?potentialProteinStr, 'http://identifiers.org/ncbiprotein/')) BIND(IRI(CONCAT('http://purl.uniprot.org/embl-cds/', SUBSTR(?potentialProteinStr, 36))) AS ?emblCds) } } ?uniparc up:sequenceFor ?emblCds . }Use62_diseases_involving_enzymes: 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 . }Use63_diseases_involving_enzymes_located_in_mitochondrion: Find (Human genetic) diseases that are thought to be related to Enzymes, known to be 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> . }Use64_diseases_related_to_mutation_in_active_site: Find (Human Genetic) diseases, that are related to a natural variant 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) }Use65_distinct_extinct_organisms_in_uniprotkb: 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 ?taxonUse66_distinct_rhea_transport_in_reviewed_uniprot: Count number of unique Rhea transport reactions 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 . }Use67_draft_human_metabolome: Generate a draft human metabolome
PREFIX chemrof: <https://w3id.org/chemrof/> 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) ?chebi . } ?chebi chemrof:smiles_string ?smiles ; chemrof:inchi_key_string ?inchiKey . }Use70_enzymes_interacting_with_molecules_similar_to_dopamine: Look for enzymes catalyzing reactions with 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) ?chebi . } ?protein up:reviewed true ; up:annotation ?caa . ?caa up:catalyticActivity/up:catalyzedReaction ?rhea . }Use71_enzymes_interacting_with_molecules_similar_to_dopamine_with_variants_related_to_disease: Look for enzymes catalyzing reactions with molecules similar to dopamine, with natural variants related to a disease.
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) ?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 . }Use72_enzymes_mapping_to_PDB: 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 . } }Use73_enzymes_related_to_protein: Select Enzyme Classification (EC) classes that have a protein associated to them
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 . } }Use