Skip to content

Instantly share code, notes, and snippets.

@yadudoc
Created March 9, 2020 16:40
Show Gist options
  • Select an option

  • Save yadudoc/6d875d4001693cd848eea4419086276e to your computer and use it in GitHub Desktop.

Select an option

Save yadudoc/6d875d4001693cd848eea4419086276e to your computer and use it in GitHub Desktop.
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
@aclyde11
Copy link

aclyde11 commented Mar 9, 2020

if mol is None or len(mol.GetAtoms()) > 100:

try that to filter out biologics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment