Permalink
Browse files

[#58] get data from biolink

  • Loading branch information...
1 parent 13770bf commit a04dc24d7602a14c8f6e44f5c68a2f87c51ab6a2 @jnguyenx jnguyenx committed Apr 7, 2017
Showing with 41 additions and 0 deletions.
  1. +41 −0 scripts/configuration-generator.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+
+# grab the curie mapping
+# scan the current directory for the tsvs
+# output an owlsim config file
+
+import yaml
+import urllib2
+import fnmatch
+import os
+
+def main():
+
+ # Getting tsv file path
+ tsvs = []
+ for root, _, filenames in os.walk('.'):
+ for filename in fnmatch.filter(filenames, '*.tsv'):
+ tsvs.append(os.path.abspath(os.path.join(root, filename))) # Check that: it looks insane to get the absolute path...
+
+ dataTsvs = [filename for filename in tsvs if not filename.endswith('label.tsv')]
+ labelTsvs = [filename for filename in tsvs if filename.endswith('label.tsv')]
+
+ # Note: the yaml dump is buggy with the empty string key, so I'm just appending the raw string and add indentation manually
+ curies = urllib2.urlopen("https://raw.githubusercontent.com/monarch-initiative/dipper/master/dipper/curie_map.yaml").read()
+
+ data = dict(
+ ontologyUris = ['http://purl.obolibrary.org/obo/upheno/monarch.owl'],
+ ontologyDataUris = [],
+ dataTsvs = dataTsvs,
+ labelTsvs = labelTsvs
+ )
+
+ print("Generating owlsim configuration")
+ with open('configuration.yaml', 'w') as outfile:
+ yaml.dump(data, outfile, default_flow_style=False)
+ outfile.write("curies:\n")
+ outfile.write(' '.join(curies.splitlines(True)))
+
+
+if __name__ == "__main__":
+ main()

0 comments on commit a04dc24

Please sign in to comment.