Skip to content

Instantly share code, notes, and snippets.

@bas-stringer
Last active May 1, 2016 05:30
Show Gist options
  • Save bas-stringer/cc12376bd6159f1ce66b4e6d5b91a81e to your computer and use it in GitHub Desktop.
Save bas-stringer/cc12376bd6159f1ce66b4e6d5b91a81e to your computer and use it in GitHub Desktop.
SCRY @ ISWC'16
PREFIX enriched: <http://www.scry.com/enriched/>
PREFIX uniprot: <http://www.uniprot.org/uniprot/>
PREFIX bfo: <http://purl.obolibrary.org/obo/>
PREFIX nif: <http://ontology.neuinfo.org/NIF/Backend/NIF-Quality.owl#>
PREFIX tissue: <http://purl.obolibrary.org/obo/caloha.obo#>
PREFIX scry: <http://scry.rocks/>
PREFIX blast: <http://scry.rocks/blast/>
PREFIX in: <http://scry.rocks/input?>
PREFIX out: <http://scry.rocks/output?>
SELECT ?tissue_name (COUNT(DISTINCT ?homolog) AS ?homologs) {
# Bind the UniProt ID URI of the query protein
BIND (uniprot:P68871 as ?uniprot)
# Invoke BLAST through SCRY and retrieve the ID lines of hits
SERVICE <http://my.scry.endpoint> {
GRAPH ?g1 {blast:fetch_sequence in: ?uniprot ; out: ?seq }
GRAPH ?g2 {blast:blast in: ?seq ;
in:evalue "1e-20" ;
out:id ?id .}
}
# Parse the UniProt ID section out of the ID lines -- this relies on using a properly formatted database at the SCRY instance
BIND(STRBEFORE(STRAFTER(?id,'|'),'|') AS ?up_id)
# Cast the ID into a URI
BIND(URI(CONCAT("http://www.uniprot.org/uniprot/",?up_id)) AS ?homolog)
FILTER(?homolog != ?uniprot)
# Find the query protein's expression levels in all known tissues; filter tissues where it is not detected
?ensg enriched:xref ?uniprot .
GRAPH ?nanopub {
?ensg bfo:BFO_0000066 ?hpa_tissue ;
nif:nlx_qual_1010003 ?level .
?hpa_tissue a ?tissue
}
FILTER (!regex(?level, "Not"))
# Same for the homologs, but only check for tissues which are already bound...
?hom_ensg enriched:xref ?homolog .
GRAPH ?hom_nanopub {
?hom_ensg bfo:BFO_0000066 ?hpa_tissue ;
nif:nlx_qual_1010003 ?hom_level .
}
FILTER (!regex(?hom_level, "Not"))
# Last but not least, name all the tissues
GRAPH enriched:CALOHA {
?tissue tissue:name ?tissue_name .
}
} GROUP BY ?tissue_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment