Package install :: Package MoSTBioDat :: Package DataBase :: Package ImportData :: Package Data2DB :: Module ZINC2DB_version_7
[hide private]
[frames] | no frames]

Source Code for Module install.MoSTBioDat.DataBase.ImportData.Data2DB.ZINC2DB_version_7

  1  #!/usr/bin/env python 
  2   
  3  ############################################################### 
  4  # ZINC2DB_version7.py                                         # 
  5  # SDF parser and ZINC Import module for ZINC version 7 (2007) # 
  6  ############################################################### 
  7   
  8  ###################################################### 
  9  # Copyright (c) 2007-2008 Andrzej Bak                # 
 10  # ARC Seibersdorf & University of Silesia            # 
 11  # Author: Andrzej Bak <Andrzej.Bak@us.edu.pl>        # 
 12  # License: GNU General Public License, version: 3    # 
 13  # URL: http://chemoinformatyka.us.edu.pl/mostbiodat/ # 
 14  # Version: 1, 06.01.2010                             # 
 15  ###################################################### 
 16   
 17  try: 
 18      import sys 
 19      from MoSTBioDat.DataBase.ImportData.Data2DB.SDFile import SDFile 
 20      from MoSTBioDat.DataBase.ImportData.Data2DB.PropZINC import PropZINC 
 21      from MoSTBioDat.DataBase.ImportData.Data2DB.SDict2DB import SDict2DB 
 22      from MoSTBioDat.DataBase.ImportData.Data2DB.PropDrugBank import PropDrugBank 
 23      import os 
 24  except ImportError,e: 
 25      print 'Error: %s' %e 
 26      sys.exit(1) 
 27   
 28  ######### MAIN ############################################################## 
 29  if __name__=='__main__': 
 30      print '*** Testing Input Object creation and DataBase import ***' 
 31       
 32  #    ## GENERAL SETTINGS ### 
 33  #    dictionarypath='/tmp/InpuTest' #path to shelve dictionary object 
 34  #    ZINCstdnum=87 # [0 ... ZINCstdnum] 
 35  #    ZINCextnum=7 # [0 .... ZINCstdnum] 
 36  #     
 37  #    ZINCstdnum=0 # [0 ... ZINCstdnum] 
 38  #    ZINCextnum=0 # [0 .... ZINCstdnum] 
 39  #     
 40  #    ####### parse standard ZINC SDF file ##########################  
 41  #     
 42  #    print '*** DataBase  STANDART shelve dictionary creation ***' 
 43  #    for i in range(ZINCstdnum+1): 
 44  #        sdfilename="/tmp/ZINC/3_p0.%s.sdf.gz" %i 
 45  #        indictfilename='ZINCStdInp%s' %i 
 46  #        A=SDFile(sdfile=sdfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
 47  #        A.parseSDFOE() 
 48  #        A=PropZINC(propfile='/tmp/ZINC/3_prop.xls',dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
 49  #        A.proParse() 
 50  #         
 51  #    print 'Done!' 
 52  # 
 53  #    ##### parse extended SDF file ############################## 
 54  #    print '*** DataBase  EXTENDED shelve dictionary creation ***'     
 55  #    for i in range(ZINCextnum+1): 
 56  #        sdfilename="/tmp/ZINC/3_p1.%s.sdf.gz" %i 
 57  #        indictfilename='ZINCExtInp%s' %i 
 58  #        A=SDFile(sdfile=sdfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
 59  #        A.parseSDFOE() 
 60  #        A=PropZINC(propfile='/tmp/ZINC/3_prop.xls',dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
 61  #        A.proParse() 
 62  #         
 63  #    print 'Done!'     
 64  #    ##### END OF IMPORT OBJECT CREATION ########################### 
 65  #     
 66  #    ###### parse ADDITIONAL DATABASE SDF files  ######################      
 67  #    ########### PubChem ############################################## 
 68  # 
 69  #    print '*** Parse PubChem SDF files ***' 
 70  #    ## STANDART FILES ### 
 71  #    for i in range(ZINCstdnum+1): 
 72  #        sdfiledir="/tmp/PubChem/SDF_270508" 
 73  #        sdfilelist=os.listdir(sdfiledir) 
 74  #        indictfilename='ZINCStdInp%s' %i 
 75  #        print '********************************************************************************' 
 76  #        for sdfilename in sdfilelist: 
 77  #            print 'Object: ', indictfilename,'#','DataBase: PubChem #', 'SDFile: ', sdfilename 
 78  #            print '****************************************************************************' 
 79  #            sdfullfilename=os.path.join(sdfiledir,sdfilename) 
 80  #            A=SDFile(sdfile=sdfullfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
 81  #            A.parseSDFOE(coords=False,nbonds=False,natoms=False,tag=True,overTag=True) 
 82  #     
 83  #    ### EXTENDED FILES ### 
 84  #    for i in range(ZINCextnum+1): 
 85  #        sdfiledir="/tmp/PubChem/SDF_270508" 
 86  #        sdfilelist=os.listdir(sdfiledir)  
 87  #        indictfilename='ZINCExtInp%s' %i 
 88  #        print '********************************************************************************' 
 89  #        for sdfilename in sdfilelist: 
 90  #            print 'Object: ', indictfilename,'#','DataBase: PubChem #', 'SDFile: ', sdfilename 
 91  #            print '****************************************************************************' 
 92  #            sdfullfilename=os.path.join(sdfiledir,sdfilename) 
 93  #            A=SDFile(sdfile=sdfullfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
 94  #            A.parseSDFOE(coords=False,nbonds=False,natoms=False,tag=True,overTag=True) 
 95  # 
 96  #    ############ DrugBank ################################################################# 
 97  #    print '*** Parse DrugBank SDF file ***' 
 98  #    ### STANDART FILES ### 
 99  #    for i in range(ZINCstdnum+1): 
100  #        sdfiledir="/tmp/DrugBank/DrugBank_260508" 
101  #        sdfilelist=os.listdir(sdfiledir) 
102  #        indictfilename='ZINCStdInp%s' %i 
103  #        print '****************************************************************************' 
104  #        for sdfilename in sdfilelist: 
105  #            print 'Object: ', indictfilename,'#', 'DataBase: DrugBank #','SDFile: ', sdfilename 
106  #            print '****************************************************************************' 
107  #            sdfullfilename=os.path.join(sdfiledir,sdfilename) 
108  #            A=SDFile(sdfile=sdfullfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
109  #            A.parseSDFOE(coords=False,nbonds=False,natoms=False,tag=True,overTag=True) 
110  #            A=PropDrugBank(propfile='/tmp/DrugBank/drugcard_set.txt',dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
111  #            A.proParse() 
112  #            A=PropDrugBank(propfile='/tmp/DrugBank/drugcard_set.txt',dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
113  #            A.proParseonDrugDBNum() 
114  #    ### EXTENDED FILES ### 
115  #    for i in range(ZINCextnum+1): 
116  #        sdfiledir="/tmp/DrugBank/DrugBank_260508" 
117  #        sdfilelist=os.listdir(sdfiledir) 
118  #        indictfilename='ZINCExtInp%s' %i 
119  #        print '****************************************************************************' 
120  #        for sdfilename in sdfilelist: 
121  #            print 'Object: ', indictfilename,'#', 'DataBase: DrugBank #','SDFile: ', sdfilename 
122  #            print '****************************************************************************' 
123  #            sdfullfilename=os.path.join(sdfiledir,sdfilename) 
124  #            A=SDFile(sdfile=sdfullfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
125  #            A.parseSDFOE(coords=False,nbonds=False,natoms=False,tag=True,overTag=True) 
126  #            A=PropDrugBank(propfile='/tmp/DrugBank/drugcard_set.txt',dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
127  #            A.proParse() 
128  #            A=PropDrugBank(propfile='/tmp/DrugBank/drugcard_set.txt',dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
129  #            A.proParseonDrugDBNum() 
130  #    
131  #    ############# Ligand Info ############################################################# 
132  #    print '*** Parse Ligand Info SDF file ***' 
133  #    ## STANDART FILES ### 
134  #    for i in range(ZINCstdnum+1): 
135  #        sdfiledir="/tmp/Ligand_info" 
136  #        sdfilelist=os.listdir(sdfiledir) 
137  #        indictfilename='ZINCStdInp%s' %i 
138  #        print '************************************************************************' 
139  #        for sdfilename in sdfilelist: 
140  #            print 'Object: ', indictfilename,'#', 'DataBase: Ligand Info #','SDFile: ', sdfilename 
141  #            print '****************************************************************************' 
142  #            sdfullfilename=os.path.join(sdfiledir,sdfilename) 
143  #            A=SDFile(sdfile=sdfullfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
144  #            A.parseSDFOE(coords=False,nbonds=False,natoms=False,tag=['Drug'],overTag=True) 
145  #     
146  #    ## EXTENDED FILES ### 
147  #    for i in range(ZINCextnum+1): 
148  #        sdfiledir="/tmp/Ligand_info" 
149  #        sdfilelist=os.listdir(sdfiledir) 
150  #        indictfilename='ZINCExtInp%s' %i 
151  #        print '************************************************************************' 
152  #        for sdfilename in sdfilelist: 
153  #            print 'Object: ', indictfilename,'#', 'DataBase: Ligand Info #','SDFile: ', sdfilename 
154  #            print '****************************************************************************' 
155  #            sdfullfilename=os.path.join(sdfiledir,sdfilename) 
156  #            A=SDFile(sdfile=sdfullfilename,dictpath=dictionarypath,dictfilename=indictfilename,path='/tmp/Log',filename='parser') 
157  #            A.parseSDFOE(coords=False,nbonds=False,natoms=False,tag=['Drug'],overTag=True) 
158  # 
159  #    ########### END OF ADDITIONAL DATABASE PARSING ########## 
160  #     
161  #    ############ DATBASE IMPORT ############################ 
162  #    print '*** Import data from ZINC shelve dictionary *** '    
163  #    ########## BASE IMPORT ################################# 
164  #    for i in range(ZINCstdnum+1): 
165  #        indbfilepath='/tmp/InpuTest/ZINCStdInp%s'%i 
166  #        A=SDict2DB(dbfilepath=indbfilepath, 
167  #               path='/tmp/Log',filename='ZINCImporTest', 
168  #               host='localhost',db='',user='',passwd='',log=False) 
169  #        A.SDict2DB(baseImport=True,lowercasetablenames=True) 
170  ##    ############# EXTENDED IMPORT ##############################  
171  #    for i in range(ZINCextnum+1): 
172  #        indbfilepath='/tmp/InpuTest/ZINCExtInp%s'%i 
173  #        A=SDict2DB(dbfilepath=indbfilepath, 
174  #               path='/tmp/Log',filename='ZINCImporTest', 
175  #               host='localhost',db='',user='root',passwd='',log=False) 
176  #        A.SDict2Tab(baseImport=False,lowercasetablenames=True) 
177  #    ####################################################### 
178