Changeset 1784:6a26e5172130 in orange-bioinformatics


Ignore:
Timestamp:
05/20/13 13:00:40 (11 months ago)
Author:
markotoplak
Branch:
default
Children:
1785:b3a53ba8ada0, 1796:a8618bd60eb7
Message:

OMIM: uses server files version by default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiOMIM.py

    r1719 r1784  
    33import shutil 
    44import re 
     5import Orange 
    56 
    67from collections import defaultdict 
    7  
    8 from Orange.orng import orngServerFiles 
    98 
    109class disease(object): 
     
    2423class OMIM(object): 
    2524    VERSION = 1 
    26     DEFAULT_DATABASE_PATH = orngServerFiles.localpath("OMIM") 
     25    DEFAULT_DATABASE_PATH = Orange.utils.serverfiles.localpath("OMIM") 
    2726    def __init__(self, local_database_path=None): 
    2827        self.local_database_path = local_database_path if local_database_path is not None else self.DEFAULT_DATABASE_PATH 
    2928         
    30         if not os.path.exists(self.local_database_path): 
    31             os.makedirs(self.local_database_path) 
    32              
    33         filename = os.path.join(self.local_database_path, "morbidmap") 
    34         if not os.path.exists(filename): 
    35             stream = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap") 
    36             with open(filename, "wb") as file: 
    37                 shutil.copyfileobj(stream, file, length=10) 
    38              
    39              
     29        if self.local_database_path == self.DEFAULT_DATABASE_PATH: 
     30            filename = Orange.utils.serverfiles.localpath_download("OMIM", "morbidmap") 
     31        else: 
     32            filename = os.path.join(self.local_database_path, "morbidmap") 
     33 
    4034        self.load(filename) 
    4135     
    4236    @classmethod 
    4337    def download_from_NCBI(cls, file=None): 
    44         data = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap").read() 
    45         if file is None: 
    46             if not os.path.exists(cls.DEFAULT_DATABASE_PATH): 
    47                 os.mkdir(cls.DEFAULT_DATABASE_PATH) 
    48             file = open(os.path.join(cls.DEFAULT_DATABASE_PATH, "morbidmap"), "wb") 
    49         elif isinstance(file, basestring): 
     38        if isinstance(file, basestring): 
    5039            file = open(file, "wb") 
    51         file.write(data) 
     40        stream = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap") 
     41        shutil.copyfileobj(stream, file, length=10) 
    5242        file.close() 
    5343         
Note: See TracChangeset for help on using the changeset viewer.