Skip to content

Instantly share code, notes, and snippets.

@jctoledo
jctoledo / Q1
Last active December 19, 2015 01:59
Q1: Retrieve transfer RNA genes
DL query: tRNA-gene
#tRNA-gene : http://bio2rdf.org/geneid_vocabulary:tRNA-gene
@jctoledo
jctoledo / Q2
Last active December 19, 2015 01:59
Q2: Retrieve human genes
DL query: gene that 'has_taxid' some 'Homo sapiens [taxid:9606]'
# gene : http://semanticscience.org/resource/SIO_010035
# 'has_taxid' : http://bio2rdf.org/geneid_vocabulary:has_taxid
# 'Homo sapiens [taxid:9606]': http://bio2rdf.org/taxon:9606
@jctoledo
jctoledo / Q3
Created June 27, 2013 19:56
Q3: retrieve genes that are from any mammal but human
DL query: gene that has_taxid some ('Mammalia [taxid: 40674]' and not 'Homo sapiens [taxid:9606]')
# gene : http://semanticscience.org/resource/SIO_010035
# 'Mammalia [taxid: 40674]' : http://bio2rdf.org/taxon:40674
# 'Homo sapiens [taxid:9606]' : http://bio2rdf.org/taxon:9606
# has_taxid : http://bio2rdf.org/geneid_vocabulary:has_taxid
@jctoledo
jctoledo / Q4
Created June 27, 2013 19:59
Q4: retrieve genes that are annotated with a specific enzymatic function:
DL query: gene that 'has function' some 'acetylglucosaminyltransferase activity [go:0008375]'
# gene : http://semanticscience.org/resource/SIO_010035
# 'has function' : http://semanticscience.org/resource/SIO_000225
# 'acetylglucosaminyltransferase activity [go:0008375]' : http://bio2rdf.org/go:0008375
@jctoledo
jctoledo / Q5
Last active December 19, 2015 01:59
Q5: retrieve genes that are annotated with a specific function that was not inferred by computational analysis.
DL query: gene that 'has function' some function that inverse(go_term) some ('has evidence' some (not 'inferred from electronic annotation'))
# gene : http://semanticscience.org/resource/SIO_010035
# 'has function' : http://semanticscience.org/resource/SIO_000225
# function : http://semanticscience.org/resource/SIO_000017
# go_term : http://bio2rdf.org/geneid_vocabulary:go_term
# 'has evidence' : http://semanticscience.org/resource/SIO_000772
# 'inferred from electronic annotation' : http://purl.obolibrary.org/obo/ECO_0000501
@jctoledo
jctoledo / Q6
Created June 27, 2013 20:18
Q6: retrieve organisms that have genes with an enzymatic activity that was not obtained by computational analysis
DL query: 'Mammalia [taxid: 40674]' that inverse(has_taxid) some (gene that 'has function' some (function that inverse(go_term) some ('has evidence' some (not 'inferred from electronic annotation')))
# 'Mammalia [taxon:40674]' : http://bio2rdf.org/taxon:40674
# has_taxid : http://bio2rdf.org/geneid_vocabulary:has_taxid
# gene : http://semanticscience.org/resource/SIO_010035
# 'has function' : http://semanticscience.org/resource/SIO_000225
# function : http://semanticscience.org/resource/SIO_000017
# go_term : http://bio2rdf.org/geneid_vocabulary:go_term
# 'has evidence' : http://semanticscience.org/resource/SIO_000772
# 'inferred from electronic annotation' : http://purl.obolibrary.org/obo/ECO_0000501
@jctoledo
jctoledo / Q7
Created June 27, 2013 20:21
Q7: retrieve a gene that encodes for a certain kind of molecule using SIO
DL query: gene and (encodes some 'small cytoplasmic RNA (scRNA)')
# gene : http://semanticscience.org/resource/SIO_010035
# encodes : http://semanticscience.org/resource/SIO_010078
# 'small cytoplasmic RNA (scRNA)' : http://semanticscience.org/resource/SIO_001231
@jctoledo
jctoledo / Q8
Created June 27, 2013 20:22
Q8: retrieve a gene that encodes for a certain kind of molecule using SO
DL query: gene and (has_quality scRNA_encoding)
# gene : http://semanticscience.org/resource/SIO_010035
# has_quality : http://purl.obolibrary.org/obo/so_has_quality
# scRNA_encoding : http://purl.obolibrary.org/obo/SO_0000575
@jctoledo
jctoledo / Q9
Last active December 19, 2015 01:59
Q9: retrieve orthologous human and mouse genes annotated with function to bind ATP
SPARQL-DL : Type(?human_gene, 'gene'), Type(?mouse_gene, 'gene'), Type(?homologene_group, HomoloGene_Group), PropertyValue(?human_gene, has_taxid, 'Homo sapiens'), PropertyValue(?mouse_gene, has_taxid, 'Mus musculus'), PropertyValue(?human_gene,'has function', 'ATP binding'), PropertyValue(?mouse_gene, 'has function', 'ATP binding'), PropertyValue(?homologene_group, has_gene, ?human_gene), PropertyValue(?homologene_group, has_gene, ?mouse_gene)
# gene : http://semanticscience.org/resource/SIO_010035
# HomoloGene_Group : http://bio2rdf.org/homologene_vocabulary:HomoloGene_Group
# has_taxid : http://bio2rdf.org/geneid_vocabulary:has_taxid
# 'Homo sapiens' : http://bio2rdf.org/taxon:9606
# 'Mus musculus' : http://bio2rdf.org/taxon:10090
# 'has function' : http://semanticscience.org/resource/SIO_000225
# 'ATP binding' : http://bio2rdf.org/go:0005524
# has_gene : http://bio2rdf.org/homologene_vocabulary:has_gene
// For testing reasons one can add a X509TrustManager to a HttpClient to avoid the SSLPeerUnverifiedException
// References:
// http://javaskeleton.blogspot.com/2010/07/avoiding-peer-not-authenticated-with.html
// http://en.wikibooks.org/wiki/Programming:WebObjects/Web_Services/How_to_Trust_Any_SSL_Certificate
// Made some customizations to these guides. Works with Java 7 (no NullPointerException when calling init() of SSLContext) and does not use any deprecated functions of HttpClient, SSLContext...
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;