-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b42ac64
commit 2543898
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
annotations-anita.ttl;http://aers.data2semantics.org/resource/graph/annotations | ||
annotations-richard.ttl;http://aers.data2semantics.org/resource/graph/annotations | ||
annotations-first-list.n3;http://aers.data2semantics.org/resource/graph/annotations | ||
annotations-second-list.n3;http://aers.data2semantics.org/resource/graph/annotations | ||
patients.nt;http://aers.data2semantics.org/resource/graph/patients | ||
dbpedia_3.7.owl;http://dbpedia.org | ||
instance_types_en.nt;http://dbpedia.org | ||
labels_en.nt;http://dbpedia.org | ||
redirects_en.nt;http://dbpedia.org | ||
nci_thesaurus.owl;http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl | ||
CTCAE_4.03_2010-06-14_v4.03.owl;http://ncicb.nci.nih.gov/xml/owl/EVS/ctcae.owl | ||
diseasome_dump.nt;http://www4.wiwiss.fu-berlin.de/diseasome | ||
drugbank_dump.nt;http://www4.wiwiss.fu-berlin.de/drugbank | ||
sider_dump.nt;http://www4.wiwiss.fu-berlin.de/sider |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
''' | ||
Created on Dec 7, 2012 | ||
@author: hoekstra | ||
''' | ||
from csv import reader | ||
from glob import glob | ||
import argparse | ||
import os.path | ||
import logging | ||
|
||
TRANSLATION_TABLE = 'graph_mappings.csv' | ||
GRAPH_BASE = 'http://aers.data2semantics.org/resource/graph/' | ||
|
||
## GLOBAL SETTINGS | ||
|
||
log = logging.getLogger(__name__) | ||
log.setLevel(logging.DEBUG) | ||
|
||
logHandler = logging.StreamHandler() | ||
logHandler.setLevel(logging.DEBUG) | ||
|
||
logFormatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
logHandler.setFormatter(logFormatter) | ||
|
||
log.addHandler(logHandler) | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument('path',help='Path to prepare') | ||
|
||
args = parser.parse_args() | ||
|
||
path = args.path | ||
if not path.endswith('/') : | ||
path += '/' | ||
|
||
files = [] | ||
|
||
files.extend(glob("{}*.nt".format(path))) | ||
files.extend(glob("{}*.n3".format(path))) | ||
files.extend(glob("{}*.ttl".format(path))) | ||
files.extend(glob("{}*.owl".format(path))) | ||
|
||
r = reader(open(TRANSLATION_TABLE,"r"),delimiter=';') | ||
|
||
table = {} | ||
for row in r: | ||
table.setdefault(row[0], row[1]) | ||
|
||
for p in files : | ||
(dir,f) = os.path.split(p) | ||
|
||
if f in table: | ||
graph_uri = table[f] | ||
log.info("Found graph URI <{}> for '{}'".format(graph_uri,f)) | ||
else : | ||
graph_uri = "{}{}".format(GRAPH_BASE,f) | ||
log.info("Generated graph URI <{}> for '{}'".format(graph_uri,f)) | ||
|
||
|
||
graph_filename = "{}.graph".format(p) | ||
|
||
# Open a file with the graph_filename name, if it already exists: overwrite | ||
graph_file = open(graph_filename,"w") | ||
|
||
graph_file.write("{}\n".format(graph_uri)) | ||
log.info("Wrote <{}> to '{}'".format(graph_uri,graph_filename)) | ||
|
||
|