Created
September 17, 2013 20:09
-
-
Save slarson/6599881 to your computer and use it in GitHub Desktop.
iPython Notebook that walks through examples of working with RDFLib and NeuroLex.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "Getting started with Python - RDF - NeuroLex" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "# Examples of using Python to work with RDF and NeuroLex.org\n\nHere we show some examples of using Python to read RDF documents from NeuroLex.org and make simple queries." | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "## A simple example\n\nIn this example, we simply get an RDF document and count how many statements it contains." | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import rdflib\n\n#Get a Graph object\ng = rdflib.Graph()\n# pull in an RDF document from NeuroLex, parse, and store.\nresult = g.parse(\"http://neurolex.org/wiki/Special:ExportRDF/birnlex_1489\", format=\"application/rdf+xml\")\n\nprint (\"graph has %s statements.\" % len(g))", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "graph has 375 statements." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\n" | |
} | |
], | |
"prompt_number": 11 | |
}, | |
{ | |
"cell_type": "heading", | |
"level": 2, | |
"metadata": {}, | |
"source": "A more complex example" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "In this example, we grab the RDF and we pull out a specific statement, the definition, and print it.\n\nWe use the following SPARQL query:\n\n SELECT DISTINCT ?b\n WHERE {\n ?a property:Definition ?b .\n }\n\nThis simply looks for anything with the property \"Definition\", binds it to ?b, and returns it as a result." | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import rdflib\nfrom rdflib import plugin\n\n\nplugin.register(\n 'sparql', rdflib.query.Processor,\n 'rdfextras.sparql.processor', 'Processor')\nplugin.register(\n 'sparql', rdflib.query.Result,\n 'rdfextras.sparql.query', 'SPARQLQueryResult')\n\n#Get a Graph object\ng = rdflib.Graph()\n# pull in an RDF document from NeuroLex, parse, and store.\nresult = g.parse(\"http://neurolex.org/wiki/Special:ExportRDF/birnlex_1489\", format=\"application/rdf+xml\")\n\n#Ask a specific question about that RDF document\nqres = g.query(\n \"\"\"SELECT DISTINCT ?b\n WHERE {\n ?a property:Definition ?b .\n }\"\"\",\n initNs=dict(\n property=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/Property-3A\"),\n wiki=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/\")))\n\n\nprint(\"Definition: %s\" % qres.result[0])", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "Definition: Part of the rhombencephalon that lies in the posterior cranial fossa behind the brain stem, consisting of the cerebellar cortex, deep cerebellar nuclei and cerebellar white matter.\nA portion of the brain that helps regulate posture, balance, and coordination. (NIDA Media Guide Glossary)\n" | |
} | |
], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "## Adding a second term to the query\nIn this example we expand the SPARQL query:\n\n SELECT DISTINCT ?def ?label\n WHERE {\n ?a property:Definition ?def .\n ?a property:Label ?label .\n }\n\nWe have added an additional element we want to pull out, the Label. \n\nBecause we have different things to pull out, we have named the definition variable `?def` and the label variable `?label`." | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import rdflib\nfrom rdflib import plugin\n\n\nplugin.register(\n 'sparql', rdflib.query.Processor,\n 'rdfextras.sparql.processor', 'Processor')\nplugin.register(\n 'sparql', rdflib.query.Result,\n 'rdfextras.sparql.query', 'SPARQLQueryResult')\n\n#Get a Graph object\ng = rdflib.Graph()\n# pull in an RDF document from NeuroLex, parse, and store.\nresult = g.parse(\"http://neurolex.org/wiki/Special:ExportRDF/birnlex_1489\", format=\"application/rdf+xml\")\n\n#Ask a specific question about that RDF document\nqres = g.query(\n \"\"\"SELECT DISTINCT ?label ?def\n WHERE {\n ?a property:Label ?label .\n ?a property:Definition ?def .\n }\"\"\",\n initNs=dict(\n property=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/Property-3A\"),\n wiki=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/\")))\n\nprint(\"Label: %s \" % qres.result[0][0])\nprint(\"Definition: %s \" % qres.result[0][1])\n", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "Label: Cerebellum \nDefinition: Part of the rhombencephalon that lies in the posterior cranial fossa behind the brain stem, consisting of the cerebellar cortex, deep cerebellar nuclei and cerebellar white matter.\nA portion of the brain that helps regulate posture, balance, and coordination. (NIDA Media Guide Glossary) \n" | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "Now we take a list of NeuroLex Ids and encode them as URLs\n\nsao185580330\nPATO_0001463\nnlx_15593\nnlx_147643\nsao1394521419\nbirnlex_826\nbirnlex_1565\nbirnlex_1197\nbirnlex_1373\nsao1211023249\nbirnlex_147\nbirnlex_1508\nnlx_inv_090914\nsao1744435799\nnlx_414\nbirnlex_12500\nCHEBI:15765\nbirnlex_7004\nGO:0040011\nPATO_0000051\nsao1417703748\nbirnlex_727\nbirnlex_2339\nbirnlex_2098\nnlx_subcell_20090508\nnlx_subcell_20090511\nbirnlex_1298\nbirnlex_1672\nsao914572699\nsao1071221672\nbirnlex_2337\nbirnlex_954\nsao221389602" | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "IDs = ['sao185580330', 'PATO_0001463', 'nlx_15593', 'nlx_147643', 'sao1394521419', 'birnlex_826', 'birnlex_1565', 'birnlex_1197', 'birnlex_1373', 'sao1211023249', 'birnlex_147', 'birnlex_1508', 'nlx_inv_090914', 'sao1744435799', 'nlx_414', 'birnlex_12500', 'CHEBI:15765', 'birnlex_7004', 'GO:0040011', 'PATO_0000051', 'sao1417703748', 'birnlex_727', 'birnlex_2339', 'birnlex_2098', 'nlx_subcell_20090508', 'nlx_subcell_20090511', 'birnlex_1298', 'birnlex_1672', 'sao914572699', 'sao1071221672', 'birnlex_2337', 'birnlex_954', 'sao221389602']\n \n \nfor index in range(len(IDs)):\n print \"http://neurolex.org/wiki/Special:ExportRDF/\" + IDs[index]\n\nprint len(IDs)\n \n \n \n \n ", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "http://neurolex.org/wiki/Special:ExportRDF/sao185580330\nhttp://neurolex.org/wiki/Special:ExportRDF/PATO_0001463\nhttp://neurolex.org/wiki/Special:ExportRDF/nlx_15593\nhttp://neurolex.org/wiki/Special:ExportRDF/nlx_147643\nhttp://neurolex.org/wiki/Special:ExportRDF/sao1394521419\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_826\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_1565\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_1197\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_1373\nhttp://neurolex.org/wiki/Special:ExportRDF/sao1211023249\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_147\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_1508\nhttp://neurolex.org/wiki/Special:ExportRDF/nlx_inv_090914\nhttp://neurolex.org/wiki/Special:ExportRDF/sao1744435799\nhttp://neurolex.org/wiki/Special:ExportRDF/nlx_414\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_12500\nhttp://neurolex.org/wiki/Special:ExportRDF/CHEBI:15765\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_7004\nhttp://neurolex.org/wiki/Special:ExportRDF/GO:0040011\nhttp://neurolex.org/wiki/Special:ExportRDF/PATO_0000051\nhttp://neurolex.org/wiki/Special:ExportRDF/sao1417703748\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_727\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_2339\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_2098\nhttp://neurolex.org/wiki/Special:ExportRDF/nlx_subcell_20090508\nhttp://neurolex.org/wiki/Special:ExportRDF/nlx_subcell_20090511\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_1298\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_1672\nhttp://neurolex.org/wiki/Special:ExportRDF/sao914572699\nhttp://neurolex.org/wiki/Special:ExportRDF/sao1071221672\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_2337\nhttp://neurolex.org/wiki/Special:ExportRDF/birnlex_954\nhttp://neurolex.org/wiki/Special:ExportRDF/sao221389602\n33\n" | |
} | |
], | |
"prompt_number": 17 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "New example with a loop of ids" | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import rdflib\nfrom rdflib import plugin\n\n\nplugin.register(\n 'sparql', rdflib.query.Processor,\n 'rdfextras.sparql.processor', 'Processor')\nplugin.register(\n 'sparql', rdflib.query.Result,\n 'rdfextras.sparql.query', 'SPARQLQueryResult')\n\n\n\n#************\n#Create list of ids we want to check\nIDs = ['sao185580330', 'PATO_0001463', 'nlx_15593', 'nlx_147643', 'sao1394521419', 'birnlex_826', 'birnlex_1565', 'birnlex_1197', 'birnlex_1373', 'sao1211023249', 'birnlex_147', 'birnlex_1508', 'nlx_inv_090914', 'sao1744435799', 'nlx_414', 'birnlex_12500', 'CHEBI:15765', 'birnlex_7004', 'GO:0040011', 'PATO_0000051', 'sao1417703748', 'birnlex_727', 'birnlex_2339', 'birnlex_2098', 'nlx_subcell_20090508', 'nlx_subcell_20090511', 'birnlex_1298', 'birnlex_1672', 'sao914572699', 'sao1071221672', 'birnlex_2337', 'birnlex_954', 'sao221389602']\n \n \nfor index in range(len(IDs)):\n #Get a Graph object\n g = rdflib.Graph()\n # pull in an RDF document from NeuroLex, parse, and store.\n result = g.parse(\"http://neurolex.org/wiki/Special:ExportRDF/\" + IDs[index], format=\"application/rdf+xml\")\n\n #Ask a specific question about that RDF document\n qres = g.query(\n \"\"\"SELECT DISTINCT ?label ?def\n WHERE {\n ?a property:Label ?label .\n ?a property:Definition ?def .\n }\"\"\",\n initNs=dict(\n property=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/Property-3A\"),\n wiki=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/\")))\n\n try:\n print(\"Label: %s \" % qres.result[0][0])\n print(\"Definition: %s \" % qres.result[0][1])\n except IndexError:\n pass\n\n#*************\n", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "Label: Acetylcholine \nDefinition: A neurotransmitter. Acetylcholine in vertebrates is the major transmitter at neuromuscular junctions, autonomic ganglia, parasympathetic effector junctions, a subset of sympathetic effector junctions, and at many sites in the central nervous system. It is generally not used as an administered drug because it is broken down very rapidly by cholinesterases, but it is useful in some ophthalmological applications (MSH). \nLabel: Action potential " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: A large, brief, all-or-nothing, regenerative electrical potential, that propagates along the axon, muscle fiber, or some dendrites. Action potentials are usually generated at the axon hillock and propagate uni-directionally down the axon. Adapted from Nicholls, Martin and Wallace 3rd edition. \nLabel: Afferent " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: An axon that is incoming into a brain region. Could also refer to the neuron that gives rise to the axon. \nLabel: Antennal lobe " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Synaptic neuropil domain of the deuterocerebrum that is the main target for innervation from the antennal nerve. \nLabel: Astrocyte " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: A class of large neuroglial (macroglial) cells in the central nervous system - the largest and most numerous neuroglial cells in the brain and spinal cord. Astrocytes (from \"star\" cells) are irregularly shaped with many long processes, including those with \"end feet\" which form the glial (limiting) membrane. The cell body of an astrocyte spans 10-20 microns and its processes radiate out for another 20-30 microns. Astrocytes stain for the intermediate filament GFAP. Astrocytes are recognized in the transmission electron microscope by their irregular shape, numerous glycogen granules, a relatively clear cytoplasm and bundles of intermediate filaments (adapted from MSH and Synapse Web)., A class of large neuroglial (macroglial) cells in the central nervous system - the largest and most numerous neuroglial cells in the brain and spinal cord. Astrocytes (from \"star\" cells) are irregularly shaped with many long processes, including those with \"end feet\" which form the glial (limiting) membrane and directly and indirectly contribute to the blood-brain barrier. They regulate the extracellular ionic and chemical environment, and \"reactive astrocytes\" (along with microglia) respond to injury (MSH). \nLabel: Basal ganglia " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Subcortical masses of gray matter in the forebrain and midbrain that are richly interconnected and so viewed as a functional system. The nuclei usually included are the caudate nucleus (caudoputamen in rodents), putamen, globus pallidus, substantia nigra (pars compacta and pars reticulata) and the subthalamic nucleus. Some also include the nucleus accumbens and ventral pallidum. \nLabel: Brainstem " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: The lower portion of the brain through which the forebrain sends information to, and receives information from, the spinal cord and peripheral nerves. Major functions located in the brainstem include those necessary for survival, e.g., breathing, heart rate, blood pressure, and arousal. (NIDA Media Guide Glossary). Note that the definition of brainstem varies in different nomenclatures, for example, some definitions include the diencephalon. \nLabel: CA1 " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Part of hippocampus proper bounded by CA2 and the subiculum, characterized by pyramidal neurons that receive projections from pyramidal neurons of CA3 via the Schaffer collaterals. \nLabel: Caudate nucleus " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Subcortical nucleus of telecephalic origin consisting of an elongated gray mass lying lateral to and bordering the lateral ventricle. It is divided into a head, body and tail in some species. \nLabel: Dendrite " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: A branching protoplasmic process of a neuron that receive and integrate signals coming from axons of other neurons, and convey the resulting signal to the body of the cell (Gene Ontology)., One of several similar processes that issue from the perikaryon of a neuron, generally specialized for receiving synaptic input from other neurons or transduction of signals from the environment. \nLabel: Entorhinal cortex " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Component of the temporal lobe on the mesial surface. The rostral and caudal boundaries of the entorhinal cortex are the rostral end of the collateral sulcus and the caudal end of the amygdala respectively. The medial boundary is the medial aspect of the temporal lobe and the lateral boundary is the collateral sulcus. (DK) \nLabel: Glutamate " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: The carboxylate anion of glutamic acid; and the major excitatory neurotransmitter in the central nervous system of vertebrates, the peripheral nervous system of invertebrates. \nLabel: Granule " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Small, generally round or drop-like shape that is densely packed together with many other cells \nLabel: Huntingtons disease " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: A familial disorder inherited as an autosomal dominant trait and characterized by the onset of progressive CHOREA and DEMENTIA in the fourth or fifth decade of life. Common initial manifestations include paranoia; poor impulse control; DEPRESSION; HALLUCINATIONS; and DELUSIONS. Eventually intellectual impairment; loss of fine motor control; ATHETOSIS; and diffuse chorea involving axial and limb musculature develops, leading to a vegetative state within 10-15 years of disease onset. The juvenile variant has a more fulminant course including SEIZURES; ATAXIA; dementia; and chorea. \nLabel: Morphology " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: A quality inhering in the bearer by virtue of its size, shape, and structure.\n\nCognitive Atlas Definition=(linguistics) the study of the structure and content of word forms; (biology) the study of the form or shape of an organism or part thereof; (materials science), the study of shape, size, texture and phase distribution of physical objects. \nLabel: Neuron " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: The basic cellular units of nervous tissue. Neurons are polarized cells with defined regions consisting of the cell body, an axon, and dendrites, although some types of neurons lack axons or dendrites. Their purpose is to receive, conduct, and transmit impulses in the nervous system. Neurons can be classified a number of different ways: anatomical, physiological, and developmental. Anatomical classes are defined first by the location of the neuron in the nervous system. Neurons are further distinguished from each other by features which include dendritic and axon morphology. Anatomical features also include synaptic connectivity (inputs and outputs) and molecular phenotype(the particular neurotransmitters, receptors, and ion channels expressed by a neuron). Neurons can be classified by their physiological properties. This includes their general function (Sensory, motor, interneuron). Functions can also include whether the neuron is a relay neuron or a local interneuron or whether it is involved in sensory processing or correction of motor responses. Physiological actions can also include the firing properties of the neuron (bursting, tonic, quiescent). Developmental classifications of neurons are based upon the lineage that the cell derives from. The number of neurons in a particular class can vary over orders of magnitude from individual neurons in some classes to millions of neurons in other classes. \nLabel: Nucleus accumbens " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: A region of the brain consisting of a collection of neurons located in the forebrain ventral to the caudate and putamen. (caudoputamen in rodent) and continuous with these structures. There is no distinct boundary between the nucleus accumbens and the caudate/putamen, but in rodents, it can be identified by its lack of traversing fiber bundles in comparison to the dorsal striatum. Its principle neuron is the medium spiny neuron. Together with the neostriatum (caudate nucleus and putamen), the nucleus accumbens forms the striatum. \nLabel: Ontology " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: In both computer science and information science, an ontology represents a set of concepts within a domain and the relationships between those concepts. It is used to reason about the objects within that domain. Ontologies are used in artificial intelligence, the semantic web, software engineering, biomedical informatics and information architecture as a form of knowledge representation about the world or some part of it. Ontologies generally describe: \n* Individuals: the basic or \"ground level\" objects \n* Classes: sets, collections, or types of objects \n* Attributes: properties, features, characteristics, or parameters that objects can have and share \n* Relations: ways that objects can be related to one another \n* Events: the changing of attributes or relations \nLabel: Parkinsons disease " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: * A disease characterized as a progressive motor disability manifested by tremors, shaking, muscular rigidity, and lack of postural reflexes. (PSY) * A progressive, degenerative neurologic disease characterized by a TREMOR that is maximal at rest, retropulsion (i.e. a tendency to fall backwards), rigidity, stooped posture, slowness of voluntary movements, and a masklike facial expression. Pathologic features include loss of melanin containing neurons in the substantia nigra and other pigmented nuclei of the brainstem. LEWY BODIES are present in the substantia nigra and locus coeruleus but may also be found in a related condition (LEWY BODY DISEASE, DIFFUSE) characterized by dementia in combination with varying degrees of parkinsonism. (Adams et al., Principles of Neurology, 6th ed, p1059, pp1067-75) (MSH) * progressive, degenerative disorder of the nervous system characterized by tremors, rigidity, bradykinesia, postural instability, and gait abnormalities; caused by a loss of neurons and a decrease of dopamine in the basal ganglia. (CSP) \nLabel: Perforant path " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Projection arising from entorhinal cortex, predominantly from cells in layers 2 and 3, and terminating in all subdivisions of the hippocampal formation (Adapted from Paxinos, G. The rat central nervous system, 2nd ed, Academic Press, San Diego, 1995, pg. 477) \nLabel: Schaffer collateral " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Part of axon of the CA3 pyramidal neuron that projects to hippocampal area CA1 \nLabel: Stratum radiatum " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Layer of the hippocampus lying just superficial to the stratum lucidum in CA3 and the pyramidal cell layer in CA1 and CA2 defined by the the location of CA3 to CA3 associational fibers and the Schaffer collaterals in area CA1. Adapted from Paxinos, G. The rat central nervous system, 2nd ed, Academic Press, San Diego, 1995, pg. 460) \nLabel: Striatum " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: * Externally Sourced Definition: A region of the brain consisting of the phylogenetically newer part of the Corpus_striatum (Caudate_nucleus and Putamen). \nLabel: Synapse " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: The junction between a nerve fiber of one neuron and another neuron or muscle fiber or glial cell; the site of interneuronal communication. As the nerve fiber approaches the synapse it enlarges into a specialized structure, the presynaptic nerve ending, which contains mitochondria and synaptic vesicles. At the tip of the nerve ending is the presynaptic membrane; facing it, and separated from it by a minute cleft (the synaptic cleft) is a specialized area of membrane on the receiving cell, known as the postsynaptic membrane. In response to the arrival of nerve impulses, the presynaptic nerve ending secretes molecules of neurotransmitters into the synaptic cleft. These diffuse across the cleft and transmit the signal to the postsynaptic membrane (Gene Ontology). \nLabel: Synaptic Vesicle " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Secretory organelles, some 50 nm in diameter, of pre-synaptic nerve terminals; accumulate high concentrations of neurotransmitters and secrete these into the synaptic cleft by fusion with the 'active zone' of the pre-synaptic plasma membrane (Gene Ontology). \nLabel: Thalamus " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Subcortical brain region consisting of paired gray matter bodies in the dorsal diencephalon and forming part of the lateral wall of the third ventricle of the brain. The thalamus represents the major portion of the diencephalon and is commonly divided into cellular aggregates known as nuclear groups.(MeSH). \nLabel: Vesicle " | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nDefinition: Any small, fluid-filled, spherical organelle enclosed by membrane or protein (Gene Ontology). \n" | |
} | |
], | |
"prompt_number": 8 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import rdflib\nfrom rdflib import plugin\n\n\nplugin.register(\n 'sparql', rdflib.query.Processor,\n 'rdfextras.sparql.processor', 'Processor')\nplugin.register(\n 'sparql', rdflib.query.Result,\n 'rdfextras.sparql.query', 'SPARQLQueryResult')\n\n\n\n#************\n#Create list of ids we want to check\nIDs = ['sao185580330', 'PATO_0001463', 'nlx_15593', 'nlx_147643', 'sao1394521419', 'birnlex_826', 'birnlex_1565', 'birnlex_1197', 'birnlex_1373', 'sao1211023249', 'birnlex_147', 'birnlex_1508', 'nlx_inv_090914', 'sao1744435799', 'nlx_414', 'birnlex_12500', 'CHEBI:15765', 'birnlex_7004', 'GO:0040011', 'PATO_0000051', 'sao1417703748', 'birnlex_727', 'birnlex_2339', 'birnlex_2098', 'nlx_subcell_20090508', 'nlx_subcell_20090511', 'birnlex_1298', 'birnlex_1672', 'sao914572699', 'sao1071221672', 'birnlex_2337', 'birnlex_954', 'sao221389602']\n \n \nfor index in range(len(IDs)):\n #Get a Graph object\n g = rdflib.Graph()\n # pull in an RDF document from NeuroLex, parse, and store.\n result = g.parse(\"http://neurolex.org/wiki/Special:ExportRDF/\" + IDs[index], format=\"application/rdf+xml\")\n\n #Ask a specific question about that RDF document\n qres = g.query(\n \"\"\"SELECT DISTINCT ?def\n WHERE {\n ?a property:Definition ?def .\n }\"\"\",\n initNs=dict(\n property=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/Property-3A\"),\n wiki=rdflib.Namespace(\"http://neurolex.org/wiki/Special:URIResolver/\")))\n\n try:\n print( qres.result[0][0])\n except IndexError:\n print IDs[index]\n pass\n\n#*************\n", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "A neurotransmitter. Acetylcholine in vertebrates is the major transmitter at neuromuscular junctions, autonomic ganglia, parasympathetic effector junctions, a subset of sympathetic effector junctions, and at many sites in the central nervous system. It is generally not used as an administered drug because it is broken down very rapidly by cholinesterases, but it is useful in some ophthalmological applications (MSH).\nA large, brief, all-or-nothing, regenerative electrical potential, that propagates along the axon, muscle fiber, or some dendrites. Action potentials are usually generated at the axon hillock and propagate uni-directionally down the axon. Adapted from Nicholls, Martin and Wallace 3rd edition." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nAn axon that is incoming into a brain region. Could also refer to the neuron that gives rise to the axon." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nSynaptic neuropil domain of the deuterocerebrum that is the main target for innervation from the antennal nerve." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nA class of large neuroglial (macroglial) cells in the central nervous system - the largest and most numerous neuroglial cells in the brain and spinal cord. Astrocytes (from \"star\" cells) are irregularly shaped with many long processes, including those with \"end feet\" which form the glial (limiting) membrane. The cell body of an astrocyte spans 10-20 microns and its processes radiate out for another 20-30 microns. Astrocytes stain for the intermediate filament GFAP. Astrocytes are recognized in the transmission electron microscope by their irregular shape, numerous glycogen granules, a relatively clear cytoplasm and bundles of intermediate filaments (adapted from MSH and Synapse Web)., A class of large neuroglial (macroglial) cells in the central nervous system - the largest and most numerous neuroglial cells in the brain and spinal cord. Astrocytes (from \"star\" cells) are irregularly shaped with many long processes, including those with \"end feet\" which form the glial (limiting) membrane and directly and indirectly contribute to the blood-brain barrier. They regulate the extracellular ionic and chemical environment, and \"reactive astrocytes\" (along with microglia) respond to injury (MSH)." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nSubcortical masses of gray matter in the forebrain and midbrain that are richly interconnected and so viewed as a functional system. The nuclei usually included are the caudate nucleus (caudoputamen in rodents), putamen, globus pallidus, substantia nigra (pars compacta and pars reticulata) and the subthalamic nucleus. Some also include the nucleus accumbens and ventral pallidum." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nThe lower portion of the brain through which the forebrain sends information to, and receives information from, the spinal cord and peripheral nerves. Major functions located in the brainstem include those necessary for survival, e.g., breathing, heart rate, blood pressure, and arousal. (NIDA Media Guide Glossary). Note that the definition of brainstem varies in different nomenclatures, for example, some definitions include the diencephalon." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nPart of hippocampus proper bounded by CA2 and the subiculum, characterized by pyramidal neurons that receive projections from pyramidal neurons of CA3 via the Schaffer collaterals." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nSubcortical nucleus of telecephalic origin consisting of an elongated gray mass lying lateral to and bordering the lateral ventricle. It is divided into a head, body and tail in some species." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nA branching protoplasmic process of a neuron that receive and integrate signals coming from axons of other neurons, and convey the resulting signal to the body of the cell (Gene Ontology)., One of several similar processes that issue from the perikaryon of a neuron, generally specialized for receiving synaptic input from other neurons or transduction of signals from the environment." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nbirnlex_147" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nComponent of the temporal lobe on the mesial surface. The rostral and caudal boundaries of the entorhinal cortex are the rostral end of the collateral sulcus and the caudal end of the amygdala respectively. The medial boundary is the medial aspect of the temporal lobe and the lateral boundary is the collateral sulcus. (DK)" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nnlx_inv_090914" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nThe carboxylate anion of glutamic acid; and the major excitatory neurotransmitter in the central nervous system of vertebrates, the peripheral nervous system of invertebrates." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nSmall, generally round or drop-like shape that is densely packed together with many other cells" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nA familial disorder inherited as an autosomal dominant trait and characterized by the onset of progressive CHOREA and DEMENTIA in the fourth or fifth decade of life. Common initial manifestations include paranoia; poor impulse control; DEPRESSION; HALLUCINATIONS; and DELUSIONS. Eventually intellectual impairment; loss of fine motor control; ATHETOSIS; and diffuse chorea involving axial and limb musculature develops, leading to a vegetative state within 10-15 years of disease onset. The juvenile variant has a more fulminant course including SEIZURES; ATAXIA; dementia; and chorea." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nCHEBI:15765" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nbirnlex_7004" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nGO:0040011" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nA quality inhering in the bearer by virtue of its size, shape, and structure.\n\nCognitive Atlas Definition=(linguistics) the study of the structure and content of word forms; (biology) the study of the form or shape of an organism or part thereof; (materials science), the study of shape, size, texture and phase distribution of physical objects." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nThe basic cellular units of nervous tissue. Neurons are polarized cells with defined regions consisting of the cell body, an axon, and dendrites, although some types of neurons lack axons or dendrites. Their purpose is to receive, conduct, and transmit impulses in the nervous system. Neurons can be classified a number of different ways: anatomical, physiological, and developmental. Anatomical classes are defined first by the location of the neuron in the nervous system. Neurons are further distinguished from each other by features which include dendritic and axon morphology. Anatomical features also include synaptic connectivity (inputs and outputs) and molecular phenotype(the particular neurotransmitters, receptors, and ion channels expressed by a neuron). Neurons can be classified by their physiological properties. This includes their general function (Sensory, motor, interneuron). Functions can also include whether the neuron is a relay neuron or a local interneuron or whether it is involved in sensory processing or correction of motor responses. Physiological actions can also include the firing properties of the neuron (bursting, tonic, quiescent). Developmental classifications of neurons are based upon the lineage that the cell derives from. The number of neurons in a particular class can vary over orders of magnitude from individual neurons in some classes to millions of neurons in other classes." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nA region of the brain consisting of a collection of neurons located in the forebrain ventral to the caudate and putamen. (caudoputamen in rodent) and continuous with these structures. There is no distinct boundary between the nucleus accumbens and the caudate/putamen, but in rodents, it can be identified by its lack of traversing fiber bundles in comparison to the dorsal striatum. Its principle neuron is the medium spiny neuron. Together with the neostriatum (caudate nucleus and putamen), the nucleus accumbens forms the striatum." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nIn both computer science and information science, an ontology represents a set of concepts within a domain and the relationships between those concepts. It is used to reason about the objects within that domain. Ontologies are used in artificial intelligence, the semantic web, software engineering, biomedical informatics and information architecture as a form of knowledge representation about the world or some part of it. Ontologies generally describe: \n* Individuals: the basic or \"ground level\" objects \n* Classes: sets, collections, or types of objects \n* Attributes: properties, features, characteristics, or parameters that objects can have and share \n* Relations: ways that objects can be related to one another \n* Events: the changing of attributes or relations" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\n* A disease characterized as a progressive motor disability manifested by tremors, shaking, muscular rigidity, and lack of postural reflexes. (PSY) * A progressive, degenerative neurologic disease characterized by a TREMOR that is maximal at rest, retropulsion (i.e. a tendency to fall backwards), rigidity, stooped posture, slowness of voluntary movements, and a masklike facial expression. Pathologic features include loss of melanin containing neurons in the substantia nigra and other pigmented nuclei of the brainstem. LEWY BODIES are present in the substantia nigra and locus coeruleus but may also be found in a related condition (LEWY BODY DISEASE, DIFFUSE) characterized by dementia in combination with varying degrees of parkinsonism. (Adams et al., Principles of Neurology, 6th ed, p1059, pp1067-75) (MSH) * progressive, degenerative disorder of the nervous system characterized by tremors, rigidity, bradykinesia, postural instability, and gait abnormalities; caused by a loss of neurons and a decrease of dopamine in the basal ganglia. (CSP)" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nProjection arising from entorhinal cortex, predominantly from cells in layers 2 and 3, and terminating in all subdivisions of the hippocampal formation (Adapted from Paxinos, G. The rat central nervous system, 2nd ed, Academic Press, San Diego, 1995, pg. 477)" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nPart of axon of the CA3 pyramidal neuron that projects to hippocampal area CA1" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nLayer of the hippocampus lying just superficial to the stratum lucidum in CA3 and the pyramidal cell layer in CA1 and CA2 defined by the the location of CA3 to CA3 associational fibers and the Schaffer collaterals in area CA1. Adapted from Paxinos, G. The rat central nervous system, 2nd ed, Academic Press, San Diego, 1995, pg. 460)" | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\n* Externally Sourced Definition: A region of the brain consisting of the phylogenetically newer part of the Corpus_striatum (Caudate_nucleus and Putamen)." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nThe junction between a nerve fiber of one neuron and another neuron or muscle fiber or glial cell; the site of interneuronal communication. As the nerve fiber approaches the synapse it enlarges into a specialized structure, the presynaptic nerve ending, which contains mitochondria and synaptic vesicles. At the tip of the nerve ending is the presynaptic membrane; facing it, and separated from it by a minute cleft (the synaptic cleft) is a specialized area of membrane on the receiving cell, known as the postsynaptic membrane. In response to the arrival of nerve impulses, the presynaptic nerve ending secretes molecules of neurotransmitters into the synaptic cleft. These diffuse across the cleft and transmit the signal to the postsynaptic membrane (Gene Ontology)." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nSecretory organelles, some 50 nm in diameter, of pre-synaptic nerve terminals; accumulate high concentrations of neurotransmitters and secrete these into the synaptic cleft by fusion with the 'active zone' of the pre-synaptic plasma membrane (Gene Ontology)." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nA taxonomy, or taxonomic scheme, is composed of taxonomic units known as taxa (singular taxon), or kinds of things that are arranged frequently in a hierarchical structure, typically related by subtype-supertype relationships, also called parent-child relationships. In such a subtype-supertype relationship the subtype kind of thing has by definition the same constraints as the supertype kind of thing plus one or more additional constraints. For example, car is a subtype of vehicle. So any car is also a vehicle, but not every vehicle is a car. So, a thing needs to satisfy more constraints to be a car than to be a vehicle." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nSubcortical brain region consisting of paired gray matter bodies in the dorsal diencephalon and forming part of the lateral wall of the third ventricle of the brain. The thalamus represents the major portion of the diencephalon and is commonly divided into cellular aggregates known as nuclear groups.(MeSH)." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\nAny small, fluid-filled, spherical organelle enclosed by membrane or protein (Gene Ontology)." | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": "\n" | |
} | |
], | |
"prompt_number": 12 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment