<jupyter_start><jupyter_text>Assignment 5 - SPARQL <NAME><jupyter_code>%endpoint https://sparql.uniprot.org/sparql
%format JSON<jupyter_output><empty_output><jupyter_text>Q1. How many protein records are in UniProt?<jupyter_code>PREFIX up: <http://purl.uniprot.org/core/>

SELECT DISTINCT COUNT(?protein) AS ?prot_records
WHERE {
	?protein a up:Protein .
}<jupyter_output><empty_output><jupyter_text>Q2. How many Arabidopsis thaliana protein records are in UniProt?<jupyter_code>PREFIX up: <http://purl.uniprot.org/core/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>

SELECT DISTINCT COUNT(?protein) AS ?ara_prot_records
WHERE {
	?protein a up:Protein .
    ?protein up:organism taxon:3702 .
}<jupyter_output><empty_output><jupyter_text>Q3. Retrieve pictures of Arabidopsis thaliana from UniProt?<jupyter_code>PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>

SELECT DISTINCT ?image
WHERE {
	taxon:3702 foaf:depiction ?image .
}<jupyter_output><empty_output><jupyter_text>Q4. What is the description of the enzyme activity of UniProt Protein Q9SZZ8<jupyter_code>PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>

SELECT DISTINCT ?equation
WHERE {
	uniprotkb:Q9SZZ8 a up:Protein ;
	up:enzyme ?enzyme .
	?enzyme up:activity ?activity .
	?activity rdfs:label ?equation.
}<jupyter_output><empty_output><jupyter_text>Q5.  Retrieve the proteins ids, and date of submission, for proteins that have been added to UniProt this year<jupyter_code>PREFIX up: <http://purl.uniprot.org/core/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT DISTINCT ?protein ?date
WHERE {
	?protein a up:Protein .
	?protein up:created ?date .
    FILTER((xsd:date(?date) >= "2021-01-01"^^xsd:date) && (xsd:date(?date) <= "2021-12-31"^^xsd:date))
}<jupyter_output><empty_output><jupyter_text>Q6. How  many species are in the UniProt taxonomy?<jupyter_code>PREFIX up: <http://purl.uniprot.org/core/>

SELECT DISTINCT COUNT(?taxon) AS ?species
WHERE
{
    ?taxon a up:Taxon ;
    up:rank up:Species .
}<jupyter_output><empty_output><jupyter_text>Q7. How many species have at least one protein record?<jupyter_code>PREFIX up: <http://purl.uniprot.org/core/>

SELECT (COUNT (DISTINCT ?taxon) AS ?species)
WHERE
{
    ?protein a up:Protein .
    ?protein up:organism ?taxon .
    ?taxon a up:Taxon ;
    up:rank up:Species .
}<jupyter_output><empty_output><jupyter_text>Q8. Find the AGI codes and gene names for all Arabidopsis thaliana  proteins that have a protein function annotation description that mentions “pattern formation”<jupyter_code>PREFIX up: <http://purl.uniprot.org/core/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?AGI_code ?gene_name
WHERE {
	?protein a up:Protein .
    ?protein up:organism taxon:3702 .
    ?protein up:encodedBy ?gene .
    ?gene a up:Gene .
    ?gene skos:prefLabel ?gene_name .
    ?gene up:locusName ?AGI_code .
    ?protein up:annotation ?annotation .
    ?annotation a up:Function_Annotation .
    ?annotation rdfs:comment ?text
    FILTER CONTAINS(?text, 'pattern formation')
}<jupyter_output><empty_output><jupyter_text>Q9. What is the MetaNetX Reaction identifier (starts with “mnxr”) for the UniProt Protein uniprotkb:Q18A79<jupyter_code>%endpoint https://rdf.metanetx.org/sparql
%format JSON
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX mnx: <https://rdf.metanetx.org/schema/>

SELECT DISTINCT ?reac_label
WHERE {
    ?protein mnx:peptXref uniprotkb:Q18A79.
	?cata mnx:pept ?protein .
    ?gpr mnx:cata ?cata ;
         mnx:reac ?reac .
    ?reac mnx:mnxr ?stable_reac .
    ?stable_reac rdfs:label ?reac_label .
}<jupyter_output><empty_output><jupyter_text>Q10. What is the official Gene ID (UniProt calls this a “mnemonic”) and the MetaNetX Reaction identifier (mnxr…..) for the protein that has “Starch synthase” catalytic activity in Clostridium difficile (taxon 272563).<jupyter_code>PREFIX up: <http://purl.uniprot.org/core/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX mnx: <https://rdf.metanetx.org/schema/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?gene_id ?reac_label
WHERE {
    SERVICE <https://sparql.uniprot.org/sparql> {
        SELECT DISTINCT ?protein ?gene_id
        WHERE {
            ?protein a up:Protein .
            ?protein up:organism taxon:272563 .
            ?protein up:mnemonic ?gene_id .
            ?protein up:enzyme ?enzyme .
            ?enzyme skos:prefLabel ?text .
            FILTER CONTAINS(?text, 'Starch synthase')
        } 
    }
    SERVICE <https://rdf.metanetx.org/sparql> {
        ?prot mnx:peptXref ?protein .
        ?cata mnx:pept ?prot .
        ?gpr mnx:cata ?cata .
        ?gpr mnx:reac ?reac .
        ?reac mnx:mnxr ?stable_reac .
        ?stable_reac rdfs:label ?reac_label .
     }
}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.021647509578544062, 'mean_word_length': 4.200199203187251, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 75, 'https://': 6, 'lorem ipsum': 0, 'www.': 7, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '293542', 'license': 'MIT', 'n_tokens_mistral': 2161, 'n_tokens_neox': 1959, 'n_words': 422, 'path': 'Assignment5/sparql_queries.ipynb', 'repo_name': 'guillechuma/Retos_Assignment_Solutions', 'size': '5240'}