def test_basics(self): fname = os.path.join(os.environ["RDBASE"], "External", "FreeSASA", "test_data", "1d3z.pdb") mol = Chem.MolFromPDBFile(fname) radii = rdFreeSASA.classifyAtoms(mol) for atom in mol.GetAtoms(): self.assertEqual(expected[atom.GetIdx()][3], radii[atom.GetIdx()]) leeRichards = 5004.79964427 shrakerupley = 5000.340175 sasa = rdFreeSASA.CalcSASA(mol, radii=radii) self.assertTrue((sasa - leeRichards) < 1e-5) opts = rdFreeSASA.SASAOpts(rdFreeSASA.ShrakeRupley, rdFreeSASA.Protor) sasa = rdFreeSASA.CalcSASA(mol, radii=radii, opts=opts) self.assertTrue((sasa - shrakerupley) < 1e-5) apolar = rdFreeSASA.CalcSASA( mol, radii, query=rdFreeSASA.MakeFreeSasaAPolarAtomQuery(), opts=opts) polar = rdFreeSASA.CalcSASA( mol, radii, query=rdFreeSASA.MakeFreeSasaPolarAtomQuery(), opts=opts) self.assertTrue((polar + apolar - 5000.340175) < 1e-5)
def cal_sasa(m): radii = rdFreeSASA.classifyAtoms(m) radii = classifyAtoms(m) # radii = rdFreeSASA.classifyAtoms(m1) sasa = rdFreeSASA.CalcSASA(m, radii, query=rdFreeSASA.MakeFreeSasaAPolarAtomQuery()) return sasa
def test_opts(self): fname = os.path.join(os.environ["RDBASE"], "External", "FreeSASA", "test_data", "1d3z.pdb") mol = Chem.MolFromPDBFile(fname) radii = rdFreeSASA.classifyAtoms(mol) for atom in mol.GetAtoms(): self.assertEqual(expected[atom.GetIdx()][3], radii[atom.GetIdx()]) leeRichards = 5004.79964427 shrakerupley = 5000.340175 opts = rdFreeSASA.SASAOpts() for alg, res in ((rdFreeSASA.ShrakeRupley, shrakerupley), (rdFreeSASA.LeeRichards, leeRichards)): opts.algorithm = alg sasa = rdFreeSASA.CalcSASA(mol, radii=radii, opts=opts) self.assertTrue(abs(sasa - res) < 1e-5) leeRichards = 5009.93014166 shrakerupley = 4977.7709106 opts = rdFreeSASA.SASAOpts() opts.probeRadius = 2.0 for alg, res in ((rdFreeSASA.ShrakeRupley, shrakerupley), (rdFreeSASA.LeeRichards, leeRichards)): opts.algorithm = alg sasa = rdFreeSASA.CalcSASA(mol, radii=radii, opts=opts) self.assertTrue(abs(sasa - res) < 1e-5)
def _get_sasa(i): conf = mol.GetConformer(i) sasa = rdFreeSASA.CalcSASA(mol, radii, confIdx=conf.GetId()) conf.SetDoubleProp("rdkit_free_sasa", sasa) return sasa