In order to maximize chemical similarity along with shape, an OEColorForceField can be added to OEBestOverlay. Once added, color scores will be calculated along with shape overlap scores. By default, the color force field only appears as a post-optimization scoring function. That is, after the shape overlap is maximized, color scores are calculated.
Color force can, however, also be used as part of the optimization. Color optimization is turned on by the SetColorOptimize(bool) member function.
1 #!/usr/bin/env python
2 # Copyright (C) 2005,2006 OpenEye Scientific Software, Inc.
3 import os, sys
4 from openeye.oechem import *
5 from openeye.oeshape import *
6
7 if len(sys.argv)!=5:
8 OEThrow.Usage("bestoverlay-color.py <reffile> <rocs_hits_file> <out.sdf> <keepsize>")
9
10 reffs = oemolistream(sys.argv[1])
11 fitfs = oemolistream(sys.argv[2])
12 outfs = oemolostream(sys.argv[3])
13 keepsize = int(sys.argv[4])
14
15 refmol=OEMol()
16 OEReadMolecule(reffs, refmol)
17
18 best=OEBestOverlay()
19 best.SetRefMol(refmol)
20 best.SetColorForceField(OEColorFFType_ImplicitMillsDean)
21 best.SetColorOptimize(True)
22
23 print "Ref. Title:", refmol.GetTitle(),
24 print "Num Confs:", refmol.NumConfs(),
25 print "Self color: %-.3f"%best.GetRefSelfColor()
26
27 resCount = 0
28 fitmol = OEMol()
29 while OEReadMolecule(fitfs, fitmol):
30 print "Fit Title:", fitmol.GetTitle(),
31 print "Num Confs:", fitmol.NumConfs()
32
33 scoreiter = OEBestOverlayScoreIter()
34 OESortOverlayScores(scoreiter, best.Overlay(fitmol), OEHighestTanimoto())
35 for score in scoreiter:
36 outmol = OEGraphMol(fitmol.GetConf(OEHasConfIdx(score.fitconfidx)))
37 score.Transform(outmol)
38
39 OESetSDData(outmol, "RefConfIdx", "%-d"%score.refconfidx)
40 OESetSDData(outmol, "Tanimoto", "%-.3f"%score.tanimoto)
41 OESetSDData(outmol, "ScaledColor", "%-.3f"%score.scaledcolor)
42
43 OEWriteMolecule(outfs, refmol.GetConf(OEHasConfIdx(score.refconfidx)))
44 OEWriteMolecule(outfs, outmol)
45
46 resCount +=1
47 if resCount==keepsize:
48 break
49
50 print resCount,"results returned"
51