Created
March 9, 2020 16:40
-
-
Save yadudoc/6d875d4001693cd848eea4419086276e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute_descript(smile, walltime=1): | |
| """ | |
| import random | |
| import time | |
| if random.randint(0,8) == 0: | |
| time.sleep(1) | |
| """ | |
| from mordred import Calculator, descriptors | |
| from rdkit import Chem | |
| import numpy as np | |
| import pickle | |
| calc = Calculator(descriptors, ignore_3D=True) # this object doesn't need to be created everytime. Can make global I think? | |
| #read smiles | |
| mol = Chem.MolFromSmiles(smile) | |
| if mol is None: | |
| print("Error processing mol") | |
| return pickle.dumps(None) | |
| descs = calc(mol) | |
| data = np.array(descs).flatten().astype(np.float32) #could run in FP16 UNO , something to think about | |
| # data = descs | |
| return pickle.dumps(data) # We do this to avoid a bug in the serialization routines that Parsl | |
| # return data | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if mol is None or len(mol.GetAtoms()) > 100:
try that to filter out biologics