def get_params(options): mol = get_mol_from_file(options.ligand_path, options.ftype) # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid conf = mol.GetConformer() params = rdShapeHelpers.ComputeConfBox(conf) # change tuples to arrays coords1 = np.array(params[0]) coords2 = np.array(params[1]) # get the centre of the box center = np.mean((coords1, coords2), axis=0) # calculate box dimensions dims = np.abs(coords1 - coords2) # optionally add buffers in each direction - expansion box_dims = [ dims[0] + options.bufx, dims[1] + options.bufy, dims[2] + options.bufz ] optionalvals = "" if options.seed is not None: optionalvals += "seed = " + str(options.seed) + "\n" if options.exhaustiveness is not None: optionalvals += "exhaustiveness = " + str( options.exhaustiveness) + "\n" with open(options.output, "w") as f: f.write(""" size_x = {} size_y = {} size_z = {} center_x = {} center_y = {} center_z = {} {}""".format( box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], optionalvals, ))
def get_params(options): # make sure we have a mol file by initiating rdkit mol object from input mol = Chem.MolFromMolFile(options.ligand_path) if not mol: raise IOError # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid conf = mol.GetConformer() params = rdShapeHelpers.ComputeConfBox(conf) # change tuples to arrays coords1 = np.array(params[0]) coords2 = np.array(params[1]) # get the centre of the box center = np.mean((coords1, coords2), axis=0) # calculate box dimensions dims = np.abs(coords1 - coords2) # optionally add buffers in each direction - expansion box_dims = [ dims[0] + options.bufx, dims[1] + options.bufy, dims[2] + options.bufz ] # if no seed set, then randomly generate one between 0 and 2**31 if options.seed == None: options.seed = randint(0, 2147483647) with open(options.output, 'w') as f: f.write(""" size_x = {} size_y = {} size_z = {} center_x = {} center_y = {} center_z = {} num_modes = 9999 energy_range = 9999 exhaustiveness = {} cpu = 4 seed = {} """.format(box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], options.exhaustiveness, options.seed))
def get_params(options): # make sure we have a mol file by initiating rdkit mol object from input mol = Chem.MolFromMolFile(options.ligand_path) if not mol: raise IOError # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid conf = mol.GetConformer() params = rdShapeHelpers.ComputeConfBox(conf) # change tuples to arrays coords1 = np.array(params[0]) coords2 = np.array(params[1]) # get the centre of the box center = np.mean((coords1, coords2), axis=0) # calculate box dimensions dims = np.abs(coords1 - coords2) # optionally add buffers in each direction - expansion box_dims = [ dims[0] + options.bufx, dims[1] + options.bufy, dims[2] + options.bufz ] optionalvals = "" if options.seed != None: optionalvals += "seed = " + str(options.seed) + "\n" if options.exhaustiveness != None: optionalvals += "exhaustiveness = " + str( options.exhaustiveness) + "\n" with open(options.output, 'w') as f: f.write(""" size_x = {} size_y = {} size_z = {} center_x = {} center_y = {} center_z = {} {}""".format(box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], optionalvals))
def test1Shape(self): fileN = os.path.join(RDConfig.RDBaseDir, 'Code', 'GraphMol', 'ShapeHelpers', 'test_data', '1oir.mol') m = Chem.MolFromMolFile(fileN) rdmt.CanonicalizeMol(m) dims1, offset1 = rdshp.ComputeConfDimsAndOffset(m.GetConformer()) grd = geom.UniformGrid3D(30.0, 16.0, 10.0) rdshp.EncodeShape(m, grd, 0) ovect = grd.GetOccupancyVect() self.failUnless(ovect.GetTotalVal() == 9250) m = Chem.MolFromMolFile(fileN) trans = rdmt.ComputeCanonicalTransform(m.GetConformer()) dims, offset = rdshp.ComputeConfDimsAndOffset(m.GetConformer(), trans=trans) dims -= dims1 offset -= offset1 self.failUnless(feq(dims.Length(), 0.0)) self.failUnless(feq(offset.Length(), 0.0)) grd1 = geom.UniformGrid3D(30.0, 16.0, 10.0) rdshp.EncodeShape(m, grd1, 0, trans) ovect = grd1.GetOccupancyVect() self.failUnless(ovect.GetTotalVal() == 9250) grd2 = geom.UniformGrid3D(30.0, 16.0, 10.0) rdshp.EncodeShape(m, grd2, 0) fileN2 = os.path.join(RDConfig.RDBaseDir, 'Code', 'GraphMol', 'ShapeHelpers', 'test_data', '1oir_conf.mol') m2 = Chem.MolFromMolFile(fileN2) rmsd = rdMolAlign.AlignMol(m, m2) self.failUnless(feq(rdshp.ShapeTanimotoDist(m, m2), 0.2813)) dist = rdshp.ShapeTanimotoDist(mol1=m, mol2=m2, confId1=0, confId2=0, gridSpacing=0.25, stepSize=0.125) self.failUnless(feq(dist, 0.3021)) m = Chem.MolFromMolFile(fileN) cpt = rdmt.ComputeCentroid(m.GetConformer()) dims, offset = rdshp.ComputeConfDimsAndOffset(m.GetConformer()) grd = geom.UniformGrid3D(dims.x, dims.y, dims.z, 0.5, DataStructs.DiscreteValueType.TWOBITVALUE, offset) dims -= geom.Point3D(13.927, 16.97, 9.775) offset -= geom.Point3D(-4.353, 16.829, 2.782) self.failUnless(feq(dims.Length(), 0.0)) self.failUnless(feq(offset.Length(), 0.0)) rdshp.EncodeShape(m, grd, 0) ovect = grd.GetOccupancyVect() self.failUnless(ovect.GetTotalVal() == 9275) geom.WriteGridToFile(grd, '1oir_shape.grd') m = Chem.MolFromMolFile(fileN) lc, uc = rdshp.ComputeConfBox(m.GetConformer()) rdmt.CanonicalizeMol(m) lc1, uc1 = rdshp.ComputeConfBox(m.GetConformer()) lc2, uc2 = rdshp.ComputeUnionBox((lc, uc), (lc1, uc1)) lc -= geom.Point3D(-4.353, 16.829, 2.782) uc -= geom.Point3D(9.574, 33.799, 12.557) self.failUnless(feq(lc.Length(), 0.0)) self.failUnless(feq(uc.Length(), 0.0)) lc1 -= geom.Point3D(-10.7519, -6.0778, -3.0123) uc1 -= geom.Point3D(8.7163, 5.3279, 3.1621) self.failUnless(feq(lc1.Length(), 0.0)) self.failUnless(feq(uc1.Length(), 0.0)) lc2 -= geom.Point3D(-10.7519, -6.0778, -3.01226) uc2 -= geom.Point3D(9.574, 33.799, 12.557) self.failUnless(feq(lc2.Length(), 0.0)) self.failUnless(feq(uc2.Length(), 0.0))