Spaces:
Running
Running
Commit
·
6297c37
1
Parent(s):
a046672
Update app.py
Browse files
app.py
CHANGED
@@ -250,6 +250,42 @@ def get_data_from_smile(smile, eluent_list):
|
|
250 |
|
251 |
return X_test
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
def predict_single(smile,PE,EA,DCM,MeOH,Et20):
|
254 |
config = parse_args()
|
255 |
config.add_dipole = False
|
@@ -264,7 +300,14 @@ def predict_single(smile,PE,EA,DCM,MeOH,Et20):
|
|
264 |
return Rf[0]
|
265 |
|
266 |
def predict_xlsx(file):
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
if __name__=='__main__':
|
269 |
|
270 |
|
|
|
250 |
|
251 |
return X_test
|
252 |
|
253 |
+
def get_data_from_xlsx(file_name):
|
254 |
+
file = pd.read_excel(file_name)
|
255 |
+
smiles = file['SMILES'].values
|
256 |
+
PEs = file['PE'].values
|
257 |
+
EAs = file['EA'].values
|
258 |
+
DCMs = file['DCM'].values
|
259 |
+
MeOHs = file['MeOH'].values
|
260 |
+
Et2Os = file['Et2O'].values
|
261 |
+
X_test = np.zeros([len(smiles), 179])
|
262 |
+
for i in range(len(smiles)):
|
263 |
+
smile=smiles[i]
|
264 |
+
eluent_sum = PEs[i] + EAs[i] + DCMs[i] + MeOHs[i] + Et2Os[i]
|
265 |
+
if eluent_sum != 0:
|
266 |
+
eluent_list = [PEs[i] / eluent_sum, EAs[i] / eluent_sum, DCMs[i] / eluent_sum, MeOHs[i] / eluent_sum, Et2Os[i] / eluent_sum]
|
267 |
+
else:
|
268 |
+
eluent_list = [0, 0, 0, 0, 0]
|
269 |
+
compound_mol = Chem.MolFromSmiles(smile)
|
270 |
+
Finger = MACCSkeys.GenMACCSKeys(Chem.MolFromSmiles(smile))
|
271 |
+
fingerprint = np.array([x for x in Finger])
|
272 |
+
compound_finger = fingerprint
|
273 |
+
compound_MolWt = Descriptors.ExactMolWt(compound_mol)
|
274 |
+
compound_TPSA = Chem.rdMolDescriptors.CalcTPSA(compound_mol)
|
275 |
+
compound_nRotB = Descriptors.NumRotatableBonds(compound_mol) # Number of rotable bonds
|
276 |
+
compound_HBD = Descriptors.NumHDonors(compound_mol) # Number of H bond donors
|
277 |
+
compound_HBA = Descriptors.NumHAcceptors(compound_mol) # Number of H bond acceptors
|
278 |
+
compound_LogP = Descriptors.MolLogP(compound_mol) # LogP
|
279 |
+
|
280 |
+
X_test[i, 0:167] = compound_finger
|
281 |
+
X_test[i, 167:173] = 0
|
282 |
+
X_test[i, 173:179] = [compound_MolWt, compound_TPSA, compound_nRotB, compound_HBD, compound_HBA, compound_LogP]
|
283 |
+
|
284 |
+
eluent_array = get_eluent_descriptor(eluent_list)
|
285 |
+
eluent_array = np.array(eluent_array)
|
286 |
+
X_test[i, 167:173] = eluent_array
|
287 |
+
return X_test
|
288 |
+
|
289 |
def predict_single(smile,PE,EA,DCM,MeOH,Et20):
|
290 |
config = parse_args()
|
291 |
config.add_dipole = False
|
|
|
300 |
return Rf[0]
|
301 |
|
302 |
def predict_xlsx(file):
|
303 |
+
file_name=file.name
|
304 |
+
config = parse_args()
|
305 |
+
config.add_dipole = False
|
306 |
+
X_test = get_data_from_xlsx(file_name)
|
307 |
+
Model = Model_ML(config, X_test)
|
308 |
+
Rf = Model.get_Rf()
|
309 |
+
return Rf
|
310 |
+
|
311 |
if __name__=='__main__':
|
312 |
|
313 |
|