Skip to content

Commit

Permalink
Merge pull request #12 from rurimatsuri3/master
Browse files Browse the repository at this point in the history
an example from Riken database
  • Loading branch information
jbpoline committed Aug 18, 2015
2 parents 0fe6c1d + ea4193d commit 0081217
Show file tree
Hide file tree
Showing 6 changed files with 64,919 additions and 1 deletion.
2 changes: 1 addition & 1 deletion use-cases/abide/abide_terms.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

abide:ABIDE_FSIQ a prov:Entity ;
abide:form "WASI" ;
abide:form "WASImorii" ;
abide:term "ABIDE_FIQ" ;
prov:definition "FIQ Standard Score" ;
prov:label "ABIDE vocabulary term" .
Expand Down
157 changes: 157 additions & 0 deletions use-cases/yoko/.ipynb_checkpoints/play_with_allen-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import rdflib"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"g=rdflib.Graph()\n",
"g.parse('rikenbrc_mouse-6-Gene_Turtle.ttl',format='turtle')\n",
"query=\"\"\"\n",
"PREFIX riken: <http://metadb.riken.jp/db>\n",
"SELECT DISTINCT *\n",
"WHERE \n",
"{ ?s ?p ?o .\n",
"}\n",
"\"\"\"\n",
"\n",
"# print every triplet\n",
"#for e in g.query(query):\n",
"# print e"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### this is a simple query"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(rdflib.term.Literal(u'http://www.informatics.jax.org/marker/MGI:97371', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#anyURI')),)\n"
]
}
],
"source": [
"query=\"\"\"\n",
"PREFIX riken: <http://metadb.riken.jp/db>\n",
"SELECT DISTINCT ?url\n",
"WHERE \n",
"{ ?s a <http://metadb.riken.jp/db/rikenbrc_mouse/animal_0000006> .\n",
" ?s <http://www.w3.org/2004/02/skos/core#altLabel> \"Npr1\"^^<http://www.w3.org/2001/XMLSchema#string> .\n",
" ?s <http://metadb.riken.jp/db/brc_beta/brc_0000037> ?url .\n",
"}\n",
"\"\"\"\n",
"for e in g.query(query):\n",
" print e"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def get_url(gene_name):\n",
" \"\"\"\n",
" constr8uct query with name of gene \n",
" \n",
" parameter: \n",
" ----------\n",
" gene_name: String, \n",
" the name of the gene\n",
" \"\"\"\n",
" \n",
" prefix = \"PREFIX riken: <http://metadb.riken.jp/db>\"\n",
" \n",
" query=\"\"\"\n",
"SELECT DISTINCT ?url\n",
"WHERE \n",
"{ ?s a <http://metadb.riken.jp/db/rikenbrc_mouse/animal_0000006> .\n",
" ?s <http://www.w3.org/2004/02/skos/core#altLabel> \"%s\"^^<http://www.w3.org/2001/XMLSchema#string> .\n",
" ?s <http://metadb.riken.jp/db/brc_beta/brc_0000037> ?url .\n",
"}\n",
"\"\"\"%gene_name\n",
" \n",
" # print prefix + query\n",
" return g.query(prefix + query)\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"e is : (rdflib.term.Literal(u'http://www.informatics.jax.org/marker/MGI:1922151', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#anyURI')),)\n",
"<class 'rdflib.term.Literal'> <class 'rdflib.query.ResultRow'>\n",
"dir e[0] is : ['__abs__', '__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__getstate__', '__gt__', '__hash__', '__init__', '__invert__', '__le__', '__len__', '__lt__', '__mod__', '__module__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__pos__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__setstate__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '_comparable_to', '_datatype', '_formatter_field_name_split', '_formatter_parser', '_language', '_literal_n3', '_quote_encode', '_value', 'capitalize', 'center', 'count', 'datatype', 'decode', 'encode', 'endswith', 'eq', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'islower', 'isnumeric', 'isspace', 'istitle', 'isupper', 'join', 'language', 'ljust', 'lower', 'lstrip', 'md5_term_hash', 'n3', 'neq', 'normalize', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'toPython', 'translate', 'upper', 'value', 'zfill']\n",
"http://www.informatics.jax.org/marker/MGI:1922151\n"
]
}
],
"source": [
"for e in get_url(\"Kbtbd11\"):\n",
" print \"e is :\", e\n",
" print type(e[0]), type(e)\n",
" print \"dir e[0] is :\", dir(e[0])\n",
" print e[0]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit 0081217

Please sign in to comment.