Development of web-based tools with
RDKit & Django

Paul Czodrowski, Merck KGaA Darmstadt
Small Molecule Platform, Computational Chemistrypaul.czodrowski@merckgroup.com
RDKit User Group Meeting, London / October 2012

a 3-class aqueous solubility model• Huuskonen dataset(http://dx.doi.org/10.1021/ci9901338 &http://www.cheminformatics.org/datasets/huuskonen/index.html)• Training set: 1025 compounds• Test set: 257 compounds• Classification based on aqueous solubility

2aqueoussolubilitysolubilityclass# compounds≤ -3.00 [low]417> -3.0 & ≤ -1.0

1 [medium]402> -1.02 [high]

206

Paul Czodrowski | October 2012

fingerprint
calculation

code snippet – calculate the descriptors
descr_list= [x[0] for x in Descriptors._descList]
descr_list.remove('MolecularFormula')
descr_obj=MoleculeDescriptors.MolecularDescriptorCalculator(descr_list)
calc_descrs = [descriptor_object.CalcDescriptors(x) for x in cpds]
pts = []
for i,m in enumerate(ms):if m.GetProp('SOL_classification')=='(A) low':
act=2
elif m.GetProp('SOL_classification')=='(B) medium':
act=1
else:
act=0
pts.append([m.GetProp('NAME'),list(calc_descrs[i]),act])

compound name

3Paul Czodrowski | October 2012list of descriptors

activitycode snippet – train the modelndescrs = len(cpds_w_descr[0])-2
attrs = range(1,ndescrs+1)
nPossible = [0]+[2]*ndescrs+[2]boundsPerVar = [0]+[1]*ndescrs+[0]cmp = Composite()cmp.Grow(pts,attrs=[1],nPossibleVals=[3],nTries=10,
buildDriver=CrossValidate.CrossValidationDriver,treeBuilder=SigTreeBuilder,needsQuantization=False,maxDepth=3)

attrs

list of descriptors to use

nPossible

number of possible values of each descriptor

boundsPerVar

number of quantization bounds to automaticallyfind for each descriptor

code snippet – model statistics

5experimentprediction

performanceon the test set

res = ScreenComposite.ShowVoteResults(range(len(pts)), pts, cmp, \3, 0,errorEstimate=True)class0class1class2class089

170

class11390

7class20833

Paul Czodrowski | October 2012

overall accuracy: 83 %

fingerprintsof training set

code snippet – similarity search
fps = [AllChem.GetMorganFingerprintAsBitVect(x,2,2048) for x in ms]
pts = []
for i,m in enumerate(ms):pts.append([m,m.GetProp('SOL_classification'),fps[i]])cPickle.dump(pts,file('cpds.pkl','wb+'))similarity search

sol_trainset = cPickle.load('cpds.pkl", "rb"))
top3 = TopNContainer(3)refFP = AllChem.GetMorganFingerprintAsBitVect(mol,2,2048)
hits = top3.GetPts()
for datasetmol in sol_trainset:
sol_TL = datasetmol[1]fp = datasetmol[2]tani = DataStructs.TanimotoSimilarity(refFP,fp)
top3.Insert((tani,sol_TL,datasetmol[0]))hits = top3.GetPts()hits.reverse()
6

Paul Czodrowski | October 2012

how-to-set-up a simple website

urls.pysettings.py
manage.py
media/
templates/start_site.html
templates/results.html
webinter/views.py

7Paul Czodrowski | October 2012

development
environment

productive
environment

Comes withdjango installation

Apache/WSGI

pitfalls Django/WSGI/SLES• our setup:•Apache server 2.2.12 on SLES 11SP1 (64 bit) with a separate virtualHostconfigured (to have it answering on and with an application-specifichostname)•python (compiled by user)• WSGIPythonHome in django.wsgi not properly recognized• LD_LIBRARY_PATH setting of original Apache shall not be modified• necessary to run distinct Apache (httpd-django.conf besides httpd.conf)

Any experience with virtualenv?
8Paul Czodrowski | October 2012

django code snippets
urls.py

views.py

9settings.py

results.html

Acknowledgments• Daniel Kuhn
• Michael Krug
• Christian Griebel, Frank Morawietz, Trung Phan An• Friedrich Rippmann• Klaus Urbahns• Greg Landrum• RDKit mailing list!

10Paul Czodrowski | October 2012