OEBestOverlay does not actually move the fit molecule. Part of
OEBestOverlayScore is the rotation matrix and translation matrix
necessary to move the fit molecule into the final overlap position.
It is up to the user to apply these transformations. The OpenEye
standard is rotation then translation, but as a convenience,
OEBestOverlayScore has a Transform() (section
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("bestoverlay4.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
21 print "Ref. Title:", refmol.GetTitle(),
22 print "Num Confs:", refmol.NumConfs()
23
24 resCount = 0
25 fitmol = OEMol()
26 while OEReadMolecule(fitfs, fitmol):
27 print "Fit Title:", fitmol.GetTitle(),
28 print "Num Confs:", fitmol.NumConfs()
29
30 scoreiter = OEBestOverlayScoreIter()
31 OESortOverlayScores(scoreiter, best.Overlay(fitmol), OEHighestTanimoto())
32 for score in scoreiter:
33 outmol = OEGraphMol(fitmol.GetConf(OEHasConfIdx(score.fitconfidx)))
34 score.Transform(outmol)
35
36 OESetSDData(outmol, "RefConfIdx", "%-d"%score.refconfidx)
37 OESetSDData(outmol, "Tanimoto", "%-.3f"%score.tanimoto)
38
39 OEWriteMolecule(outfs, refmol.GetConf(OEHasConfIdx(score.refconfidx)))
40 OEWriteMolecule(outfs, outmol)
41
42 resCount +=1
43 if resCount==keepsize:
44 break
45
46 print resCount,"results returned"
47