Skip to content

Instantly share code, notes, and snippets.

@nakao
Last active December 19, 2015 02:18
Show Gist options
  • Save nakao/5881623 to your computer and use it in GitHub Desktop.
Save nakao/5881623 to your computer and use it in GitHub Desktop.
List human proteins which have natural variants described also in OMIM. The query returns protein id, gene label, mutation(cf. A301R), omim id and citation id at UniProt SPARQL endpoint http://beta.sparql.uniprot.org/sparql .
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX owl:<http://www.w3.org/2002/07/owl#>
PREFIX bibo:<http://purl.org/ontology/bibo/>
PREFIX dc:<http://purl.org/dc/terms/>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX up:<http://purl.uniprot.org/core/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT ?protein ?geneLabel ?hgsv ?omim ?citation
WHERE
{
?protein a up:Protein ;
up:organism <http://purl.uniprot.org/taxonomy/9606> ; # Human
up:annotation ?annotation ;
up:annotation ?diseaseA ;
up:encodedBy ?gene .
?gene skos:prefLabel ?geneLabel .
?diseaseA a up:Disease_Annotation ; # Disease annotated protein
up:disease ?disease .
?disease up:mnemonic ?dMnemonic ; # Disease initials, like "ALS"
rdfs:seeAlso ?omim .
?omim up:database <http://purl.uniprot.org/database/MIM> .
?annotation a up:Natural_Variant_Annotation ; #
rdfs:comment ?text ;
up:substitution ?sub ;
up:range ?range .
?range up:begin ?begin ;
up:end ?end .
?reif a rdf:Statement ;
rdf:subject ?protein ;
rdf:predicate up:annotation ;
rdf:object ?annotation ;
up:attribution ?attribution .
?attribution up:source ?citation . # citation of Natural Variant Annotation
BIND(strlen(?sub) as ?len) # length of substitution of a natural variation
FILTER (?len > 1 || ?len = 0)
BIND(IF(?len >0, "ins", "del") AS ?insdel) # positive length sub -> ins
FILTER (contains(?text, ?dMnemonic)) # Desisese mnemonic contains Natural Variant Annotation text
?protein up:sequence ?sequence .
?sequence rdf:value ?value ;
up:precursor true .
BIND(substr(?value,?begin,(?end-?begin)+1) AS ?rep) # At a Natural Variant Annotation position, pick the original amino acid in protein sequence.
BIND(concat(?rep,str(?begin),?sub) AS ?hgsv) # make "A301R" mutation code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment