Marko Toplak avatar Marko Toplak committed 6a26e51

OMIM: uses server files version by default.

Comments (0)

Files changed (1)


 import urllib2
 import shutil
 import re
+import Orange
 from collections import defaultdict
-from Orange.orng import orngServerFiles
 class disease(object):
     """ A class representing a disease in the OMIM database
 class OMIM(object):
     VERSION = 1
-    DEFAULT_DATABASE_PATH = orngServerFiles.localpath("OMIM")
+    DEFAULT_DATABASE_PATH = Orange.utils.serverfiles.localpath("OMIM")
     def __init__(self, local_database_path=None):
         self.local_database_path = local_database_path if local_database_path is not None else self.DEFAULT_DATABASE_PATH
-        if not os.path.exists(self.local_database_path):
-            os.makedirs(self.local_database_path)
-        filename = os.path.join(self.local_database_path, "morbidmap")
-        if not os.path.exists(filename):
-            stream = urllib2.urlopen("")
-            with open(filename, "wb") as file:
-                shutil.copyfileobj(stream, file, length=10)
+        if self.local_database_path == self.DEFAULT_DATABASE_PATH:
+            filename = Orange.utils.serverfiles.localpath_download("OMIM", "morbidmap")
+        else:
+            filename = os.path.join(self.local_database_path, "morbidmap")
     def download_from_NCBI(cls, file=None):
-        data = urllib2.urlopen("").read()
-        if file is None:
-            if not os.path.exists(cls.DEFAULT_DATABASE_PATH):
-                os.mkdir(cls.DEFAULT_DATABASE_PATH)
-            file = open(os.path.join(cls.DEFAULT_DATABASE_PATH, "morbidmap"), "wb")
-        elif isinstance(file, basestring):
+        if isinstance(file, basestring):
             file = open(file, "wb")
-        file.write(data)
+        stream = urllib2.urlopen("")
+        shutil.copyfileobj(stream, file, length=10)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.