sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

111_uniprot_make_chain_sequence_fasta

Given an UniProt chain identifier, generate the matching sequence as a FASTA

Use at

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 .
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?annId")
  v5("?begin"):::projected 
  v8("?chainFasta")
  v1("?chainSeqId"):::projected 
  v6("?end"):::projected 
  v7("?iupacAA"):::projected 
  v3("?range")
  v4("?reference")
  a1((" "))
  a2((" "))
  bind0[/"'PRO_0000268053'"/]
  bind0 --as--o v1
  bind1[/"concat('http://purl.uniprot.org/annotation/',?chainSeqId)"/]
  v1 --o bind1
  bind1 --as--o v2
  v2 --"up:range"-->  v3
  a1 --"faldo:reference"-->  v4
  a1 --"faldo:position"-->  v5
  v3 --"faldo:begin"-->  a1
  a2 --"faldo:position"-->  v6
  v3 --"faldo:end"-->  a2
  v4 --"rdf:value"-->  v7
  bind2[/"concat('>',?chainSeqId,'
',substring(?iupacAA,?begin,?end - ?begin + '+1^^xsd:integer'))"/]
  v1 --o bind2
  v7 --o bind2
  v5 --o bind2
  v6 --o bind2
  bind2 --as--o v8