Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human Health vocabulary #184

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask instance folder
instance/

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml

# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Created by .ignore support plugin (hsz.mobi)
Binary file not shown.
62 changes: 62 additions & 0 deletions scripts/human-health-vocab/generate-human-health-skos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

import pandas
import urllib.parse
from rdflib import RDF, RDFS, XSD, Graph, URIRef, Literal, Namespace

vocab_uri = "http://data.globalchange.gov/vocab/human-health"

SKOS = Namespace("http://www.w3.org/2004/02/skos/core#")
DCT = Namespace("http://purl.org/dc/terms/")
GCIS = Namespace("http://data.globalchange.gov/gcis.owl#")
MESH = Namespace("http://id.nlm.nih.gov/mesh/")

g = Graph()
g.bind("skos", SKOS)
g.bind("dcterms", DCT)
g.bind("mesh", MESH)

vocab = g.resource(URIRef(vocab_uri))
vocab.add(RDF.type, SKOS.ConceptScheme)
vocab.add(DCT.title, Literal("Human Health Vocabulary"))

csv_file = "TermRelationship_vector_borne_12_22.xlsx"
df = pandas.read_excel(csv_file, sheetname='Term')

for index, row in df.iterrows():
if row["Term"] is not pandas.np.nan:

term = row["Term"].strip()
uri = vocab_uri+"/concept/"+urllib.parse.quote_plus(term)

concept = g.resource(URIRef(uri))
concept.add(RDF.type, SKOS.Concept)
concept.add(SKOS.prefLabel, Literal(term))
concept.add(SKOS.inScheme, vocab)

if row["Definition"] is not pandas.np.nan:
definition = row["Definition"].strip()
concept.add(SKOS.definition, Literal(definition))

if row["extURI"] is not pandas.np.nan:
source = row["extURI"].strip()
concept.add(DCT.source, URIRef(source))

if row["MeSH Unique ID"] is not pandas.np.nan:
mesh_id = row["MeSH Unique ID"].strip()
mesh_uri = MESH+mesh_id
concept.add(SKOS.closeMatch, URIRef(mesh_uri))


df = pandas.read_excel(csv_file, sheetname='SubPredObj')
for index, row in df.iterrows():
if row["Predicate"] is not pandas.np.nan:

_subject = vocab_uri + "/concept/" + urllib.parse.quote_plus(row["Subject"].strip())
_object = vocab_uri + "/concept/" + urllib.parse.quote_plus(row["Object"].strip())

if row["Predicate"] == "skos:narrower":
g.add((URIRef(_subject), SKOS.narrower, URIRef(_object)))
else:
g.add((URIRef(_subject), SKOS.related, URIRef(_object)))

g.serialize("human-health.ttl", format="turtle")
Loading