Changeset 1519:b5ea81f44308 in orange-bioinformatics


Ignore:
Timestamp:
11/29/11 18:47:19 (2 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
94e941368049102d30d00761a17967943e50cb9b
Message:

Fixed the ncbi omim download path.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiOMIM.py

    r1007 r1519  
    22import sys, os 
    33import urllib2 
     4import shutil 
    45import re 
    56 
     
    2425    DEFAULT_DATABASE_PATH = orngServerFiles.localpath("OMIM") 
    2526    def __init__(self, local_database_path=None): 
    26         self.local_database_path = local_database_path if local_database_path else self.DEFAULT_DATABASE_PATH 
    27         self.load() 
     27        self.local_database_path = local_database_path if local_database_path is not None else self.DEFAULT_DATABASE_PATH 
     28         
     29        if not os.path.exists(self.local_database_path): 
     30            os.makedirs(self.local_database_path) 
     31             
     32        filename = os.path.join(self.local_database_path, "morbidmap") 
     33        if not os.path.exists(filename): 
     34            stream = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap") 
     35            with open(filename, "wb") as file: 
     36                shutil.copyfileobj(stream, file, length=10) 
     37             
     38             
     39        self.load(filename) 
    2840     
    2941    @classmethod 
    3042    def download_from_NCBI(cls, file=None): 
    31         data = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/morbidmap").read() 
     43        data = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap").read() 
    3244        if file is None: 
    3345            if not os.path.exists(cls.DEFAULT_DATABASE_PATH): 
     
    4759        return instance  
    4860     
    49     def load(self): 
    50         orngServerFiles.localpath_download("OMIM", "morbidmap") 
    51         lines = open(os.path.join(self.local_database_path, "morbidmap")).read().split("\n") 
     61    def load(self, filename): 
     62        file = open(filename, "rb") 
     63        lines = file.read().split("\n") 
    5264        self._disease_dict = dict([(disease(line), line) for line in lines if line]) 
    5365         
Note: See TracChangeset for help on using the changeset viewer.