s1 = b.GenerateSubshapeShape(m1) cPickle.dump(s1,file('test_data/square1.shp.pkl','wb+')) print 'm2:' s2 = b.GenerateSubshapeShape(m2) cPickle.dump(s2,file('test_data/square2.shp.pkl','wb+')) ns1 = b.CombineSubshapes(s1,s2) b.GenerateSubshapeSkeleton(ns1) cPickle.dump(ns1,file('test_data/combined.shp.pkl','wb+')) else: s1 = cPickle.load(file('test_data/square1.shp.pkl','rb')) s2 = cPickle.load(file('test_data/square2.shp.pkl','rb')) #ns1 = cPickle.load(file('test_data/combined.shp.pkl','rb')) ns1=cPickle.load(file('test_data/combined.shp.pkl','rb')) v = MolViewer() SubshapeObjects.DisplaySubshape(v,s1,'shape1') SubshapeObjects.DisplaySubshape(v,ns1,'ns1') #SubshapeObjects.DisplaySubshape(v,s2,'shape2') a = SubshapeAligner.SubshapeAligner() pruneStats={} algs =a.GetSubshapeAlignments(None,ns1,m1,s1,b,pruneStats=pruneStats) print len(algs) print pruneStats import os,tempfile from rdkit import Geometry fName = tempfile.mktemp('.grd') Geometry.WriteGridToFile(ns1.coarseGrid.grid,fName) v.server.loadSurface(fName,'coarse','',2.5) os.unlink(fName)
targetConf=tgtConf, queryConf=queryConf, pruneStats=pruneStats): continue # if we made it this far, it's a good alignment yield alignment if __name__ == '__main__': from rdkit.six.moves import cPickle tgtMol, tgtShape = cPickle.load(file('target.pkl', 'rb')) queryMol, queryShape = cPickle.load(file('query.pkl', 'rb')) builder = cPickle.load(file('builder.pkl', 'rb')) aligner = SubshapeAligner() algs = aligner.GetSubshapeAlignments(tgtMol, tgtShape, queryMol, queryShape, builder) print(len(algs)) from rdkit.Chem.PyMol import MolViewer v = MolViewer() v.ShowMol(tgtMol, name='Target', showOnly=True) v.ShowMol(queryMol, name='Query', showOnly=False) SubshapeObjects.DisplaySubshape(v, tgtShape, 'target_shape', color=(.8, .2, .2)) SubshapeObjects.DisplaySubshape(v, queryShape, 'query_shape', color=(.2, .2, .8))