28
28
29
29
from pyworkflow .protocol import params
30
30
31
- from pwchem .utils import performBatchThreading , findThreadFiles , concatFiles , splitFile , makeSubsets
32
- from pwchem import Plugin as pwchemPlugin
31
+ from pwchem .utils import findThreadFiles , concatFiles , splitFile , makeSubsets , insistentRun
33
32
from pwchem .constants import RDKIT_DIC
34
- from pwchem .objects import SmallMoleculesLibrary
35
33
36
34
from autodock import Plugin as autodockPlugin
37
35
from autodock .protocols import ProtChemAutodockGPU
@@ -69,7 +67,7 @@ def _defineParams(self, form):
69
67
help = 'Whether to use a SMI library SmallMoleculesLibrary object as input' )
70
68
71
69
group .addParam ('inputLibrary' , params .PointerParam , pointerClass = "SmallMoleculesLibrary" ,
72
- label = 'Input library: ' , condition = 'useLibrary' ,
70
+ label = 'Input library: ' , condition = 'useLibrary' , allowsNull = True ,
73
71
help = "Input Small molecules library to predict" )
74
72
group .addParam ('batchSize' , params .IntParam , label = 'Batch size (MB): ' , default = 100 , condition = 'useLibrary' ,
75
73
expertLevel = params .LEVEL_ADVANCED , help = 'Batch size for running conplex in batches' )
@@ -178,7 +176,7 @@ def trainingStep(self):
178
176
args += f'-ef { autodockPlugin .getChemPropFile ()} '
179
177
180
178
modelsPath = os .path .abspath (autodockPlugin .getPluginHome ('models' ))
181
- pwchemPlugin . runCondaCommand (self , args , GCR_DIC , f'python { scriptName } ' , cwd = self ._getPath ())
179
+ insistentRun (self , f'python { scriptName } ' , args , envDic = GCR_DIC , cwd = self ._getPath ())
182
180
183
181
shutil .copytree (os .path .abspath (self ._getPath (sysName )), os .path .join (modelsPath , sysName ), dirs_exist_ok = True )
184
182
self .mergeAllSMIFiles (True , gpuIdx )
@@ -195,7 +193,8 @@ def predictionStep(self, i, gpuIdx, inMols=None, inSMIFile=None):
195
193
smisFile = self .buildSMIsFile (inMols , writeScores = False , gpuIdx = gpuIdx , it = i )
196
194
elif inSMIFile :
197
195
smisFile = self .getInputSMIFile (writeScores = False , gpuIdx = gpuIdx , it = i )
198
- os .link (inSMIFile , smisFile )
196
+ if not os .path .exists (smisFile ):
197
+ os .link (inSMIFile , smisFile )
199
198
200
199
modelsPath = os .path .abspath (autodockPlugin .getPluginHome ('models' ))
201
200
shutil .copytree (os .path .join (modelsPath , sysName ), os .path .abspath (self ._getPath (sysName )), dirs_exist_ok = True )
@@ -205,7 +204,7 @@ def predictionStep(self, i, gpuIdx, inMols=None, inSMIFile=None):
205
204
if self .getEnumText ('encoder' ) == CHEMPROP :
206
205
args += f'-ef { autodockPlugin .getChemPropFile ()} '
207
206
208
- pwchemPlugin . runCondaCommand (self , args , GCR_DIC , f'python { scriptName } ' , cwd = self ._getPath ())
207
+ insistentRun (self , f'python { scriptName } ' , args , envDic = GCR_DIC , cwd = self ._getPath ())
209
208
210
209
def createOutputStep (self ):
211
210
for gpuIdx in self .getInputGpuIdxs ():
@@ -219,7 +218,8 @@ def createOutputStep(self):
219
218
with open (oLibFile , 'w' ) as f :
220
219
for smiName , score in smiScoreDic .items ():
221
220
if not self .applyFilter .get () or score < self .outThres .get ():
222
- f .write (f'{ mapDic [smiName ]} \t { score } \n ' )
221
+ prevLine = "\t " .join (mapDic [smiName ].split ())
222
+ f .write (f'{ prevLine } \t { score } \n ' )
223
223
224
224
prevHeaders = inLib .getHeaders ()
225
225
outputLib = inLib .clone ()
@@ -326,11 +326,15 @@ def buildSMIsFile(self, dMols, writeScores=True, gpuIdx=0, it=0):
326
326
if molFile .endswith ('.smi' ):
327
327
self .writeSMIs (dMols , writeScores , it , origin = 'file' , gpuIdx = gpuIdx )
328
328
else :
329
- getFileFunc = 'getPoseFile' if writeScores else 'getFileName'
330
- molFile = getattr (dMols [0 ], getFileFunc )()
329
+ getFileFuncs = ['getPoseFile' , 'getFileName' ]
330
+ fileFuncIdx = 0 if writeScores else 1
331
+ molFile = getattr (dMols [0 ], getFileFuncs [fileFuncIdx ])()
332
+ molFile2 = getattr (dMols [0 ], getFileFuncs [abs (fileFuncIdx - 1 )])()
331
333
332
334
if self .checkHasSMI (molFile ):
333
335
smiFile , mapFile = self .writeSMIs (dMols , writeScores , it , origin = 'Meeko' , gpuIdx = gpuIdx )
336
+ elif self .checkHasSMI (molFile2 ):
337
+ smiFile , mapFile = self .writeSMIs (dMols , not writeScores , it , origin = 'Meeko' , gpuIdx = gpuIdx )
334
338
else :
335
339
inMolsFile = self .writeInputMolsFile (dMols , writeScores , it , gpuIdx = gpuIdx )
336
340
mapFile = self .getMapSMIFile (writeScores , it , gpuIdx = gpuIdx )
0 commit comments