sparql-examples

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

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

neXtProt/NXQ_00140

Proteins that interact with viral proteins

Use at

PREFIX : <http://nextprot.org/rdf/>
PREFIX nextprot_cv: <http://nextprot.org/rdf/terminology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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 ?entry WHERE {
 ?entry :isoform ?iso.
 optional {?iso :interactionInfo ?itinfo .}
 {
 ?itinfo rdfs:comment ?txt.
 filter(contains(?txt,"viral") || contains(?txt,"virus")).
 } # refers to a virus in the free-text interactionInfo topic
UNION
 { ?iso :uniprotKeyword / :term nextprot_cv:KW-0945.} # host-virus interaction keyword
UNION
 {
 SERVICE <https://sparql.uniprot.org/sparql> {
 SELECT distinct ?viralinteractor WHERE # get viral proteins with an IntAct xref
 {
	?viralinteractor a up:Protein .
	?viralinteractor rdfs:seeAlso ?db .
	?db up:database <http://purl.uniprot.org/database/IntAct> .
 	?viralinteractor up:organism ?tax .
	?tax up:scientificName ?orgname.
	filter(contains(?orgname,"virus"))
 }
 }
 ?entry :isoform / :binaryInteraction ?it .
 ?it :interactant ?interactant; :quality :GOLD. # NeXtprot entries with a GOLD IntAct binary interaction
 ?interactant skos:exactMatch ?viralinteractor . # interactant must be in the uniprot service result set to select the entry
 }
UNION
 {
 SERVICE <https://sparql.uniprot.org/sparql> {
 SELECT distinct ?humprotein WHERE # get human proteins that share a PDB xref with a viral protein (same PDB id)
 {
	?humprotein a up:Protein .
 ?humprotein up:organism taxon:9606 .
	?humprotein rdfs:seeAlso ?db .
	?db up:database <http://purl.uniprot.org/database/PDB> .
	?viralprotein a up:Protein .
	?viralprotein rdfs:seeAlso ?db .
 ?viralprotein up:organism ?tax .
	?tax up:scientificName ?orgname.
	filter(contains(?orgname,"virus"))
 }
 }
 ?entry skos:exactMatch ?humprotein .
 }
}
order by ?entry
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?db")
  v1("?entry"):::projected 
  v11("?humprotein")
  v10("?interactant")
  v2("?iso")
  v9("?it")
  v3("?itinfo")
  v5("?orgname")
  v8("?tax")
  v4("?txt")
  v6("?viralinteractor")
  v12("?viralprotein")
  a1((" "))
  a2((" "))
  c14([http://purl.uniprot.org/database/IntAct]):::iri 
  c22(["taxon:9606"]):::iri 
  c20([":GOLD"]):::iri 
  c23([http://purl.uniprot.org/database/PDB]):::iri 
  c11(["up:Protein"]):::iri 
  c8([":terminology/KW-0945"]):::iri 
  v1 --":isoform"-->  v2
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v2 -.":interactionInfo".->  v3
  end
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    subgraph union1[" Union "]
    subgraph union1l[" "]
      style union1l fill:#abf,stroke-dasharray: 3 3;
      subgraph union2[" Union "]
      subgraph union2l[" "]
        style union2l fill:#abf,stroke-dasharray: 3 3;
        subgraph s1["https://sparql.uniprot.org/sparql"]
          style s1 stroke-width:4px;
          f0[["contains(?orgname,'virus')"]]
          f0 --> v5
          v11 --"a"-->  c11
          v11 --"up:organism"-->  c22
          v11 --"rdfs:seeAlso"-->  v7
          v7 --"up:database"-->  c23
          v12 --"a"-->  c11
          v12 --"rdfs:seeAlso"-->  v7
          v12 --"up:organism"-->  v8
          v8 --"up:scientificName"-->  v5
        end
        v1 --"skos:exactMatch"-->  v11
      end
      subgraph union2r[" "]
        style union2r fill:#abf,stroke-dasharray: 3 3;
        subgraph s1["https://sparql.uniprot.org/sparql"]
          style s1 stroke-width:4px;
          f1[["contains(?orgname,'virus')"]]
          f1 --> v5
          v6 --"a"-->  c11
          v6 --"rdfs:seeAlso"-->  v7
          v7 --"up:database"-->  c14
          v6 --"up:organism"-->  v8
          v8 --"up:scientificName"-->  v5
        end
        v1 --":isoform"-->  a2
        a2 --":binaryInteraction"-->  v9
        v9 --":interactant"-->  v10
        v9 --":quality"-->  c20
        v10 --"skos:exactMatch"-->  v6
      end
      union2r <== or ==> union2l
      end
    end
    subgraph union1r[" "]
      style union1r fill:#abf,stroke-dasharray: 3 3;
      v2 --":uniprotKeyword"-->  a1
      a1 --":term"-->  c8
    end
    union1r <== or ==> union1l
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    f2[["(contains(?txt,'viral') || contains(?txt,'virus'))"]]
    f2 --> v4
    v3 --"rdfs:comment"-->  v4
  end
  union0r <== or ==> union0l
  end