def test_07SurfaceAreaCalculations(): print("____________________________") print("test_07SurfaceAreaCalculations") print("____________________________") from mslib import MSMS, msms m = MSMS(filename='Data/1crn.xyzrn') m.compute() m.compute_ses_area() print(m.sesr.fst.a_reent_area) print(m.sesr.fst.a_toric_area) print(m.sesr.fst.a_contact_area) print(m.sesr.fst.a_ses_area) print(m.sesr.fst.a_sas_area) #m.write_ses_area(filename='testAllComp.area', component=None) #m.write_ses_area(filename='testAllComp.area', component=0) m.compute_numeric_area_vol() m.compute_numeric_area_vol(component=0) m.compute_numeric_area_vol(component=0, mode=msms.MS_NUMERICAL) print(m.sesr.fst.n_ses_volume) m.compute_numeric_area_vol(component=0, mode=msms.MS_SEMI_ANALYTICAL) print(m.sesr.fst.n_ses_volume) print(m.sesr.fst.n_sas_volume) print(m.sesr.fst.n_ses_area) print(m.sesr.fst.n_sas_area) print(m.detailed_info()) print(m.info()) vfloat, vint, tri = m.getTriangles() print("triangles", len(vfloat), len(vint), len(tri))
def test_07SurfaceAreaCalculations() : print("____________________________") print("test_07SurfaceAreaCalculations") print("____________________________") from mslib import MSMS, msms m = MSMS(filename='Data/1crn.xyzrn') m.compute() m.compute_ses_area() print(m.sesr.fst.a_reent_area) print(m.sesr.fst.a_toric_area) print(m.sesr.fst.a_contact_area) print(m.sesr.fst.a_ses_area) print(m.sesr.fst.a_sas_area) #m.write_ses_area(filename='testAllComp.area', component=None) #m.write_ses_area(filename='testAllComp.area', component=0) m.compute_numeric_area_vol() m.compute_numeric_area_vol(component=0) m.compute_numeric_area_vol(component=0, mode=msms.MS_NUMERICAL) print(m.sesr.fst.n_ses_volume) m.compute_numeric_area_vol(component=0, mode=msms.MS_SEMI_ANALYTICAL) print(m.sesr.fst.n_ses_volume) print(m.sesr.fst.n_sas_volume) print(m.sesr.fst.n_ses_area) print(m.sesr.fst.n_sas_area) print(m.detailed_info()) print(m.info()) vfloat, vint, tri = m.getTriangles() print("triangles", len(vfloat), len(vint), len(tri))
def computeMSMSvolume(atmCoords, atmRadii, pRadius, dens ): srf = MSMS(coords=atmCoords, radii=atmRadii) srf.compute(probe_radius=pRadius, density=dens) vf, vi, f = srf.getTriangles() vertices=vf[:,:3] normals=vf[:,3:6] triangles=f[:,:3] return meshVolume(vertices, normals, triangles)
def computeMSMSvolume(atmCoords, atmRadii, pRadius, dens): srf = MSMS(coords=atmCoords, radii=atmRadii) srf.compute(probe_radius=pRadius, density=dens) vf, vi, f = srf.getTriangles() vertices = vf[:, :3] normals = vf[:, 3:6] triangles = f[:, :3] return meshVolume(vertices, normals, triangles)
def test_08BuriedSurfaceCalculations(): print("______________________________") print("test_08BuriedSurfaceCalculations") print("______________________________") from mslib import MSMS, readxyzr, msms output1 = readxyzr('Data/1tpa_e.xyzr') coords_e = output1[0] names = output1[1] #coords_e, names = readxyzr('Data/1tpa_e.xyzr') output2 = readxyzr('Data/1tpa_i.xyzr') coords_i = output2[0] names = output2[1] #coords_i, names = readxyzr('Data/1tpa_i.xyzr') coords = coords_e[:, :3] rad = coords_e[:, 3] m = MSMS(coords=coords, radii=rad) m.compute() m.buriedVertices(coords_i) vfloat, vint, tri = m.getTriangles() indBuried = Numeric.nonzero(vint[:, 2]) print(len(indBuried), " vertices buried") m.resetBuriedVertexArea() m.compute_numeric_area_vol(component=0, mode=msms.MS_SEMI_ANALYTICAL) print(m.sesr.fst.n_ses_volume) print(m.sesr.fst.n_ses_area) m.buriedSurfaceArea() print(m.sesr.fst.n_buried_ses_area) print(m.sesr.fst.n_buried_sas_area) vfloat, vint, tri = m.getBuriedSurfaceTriangles(selnum=1) print( "getBuriedSurfaceTriangles(selnum=1): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri))) vfloat, vint, tri = m.getBuriedSurfaceTriangles(selnum=2) print( "getBuriedSurfaceTriangles(selnum=2): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri))) vfloat, vint, tri = m.getBuriedSurfaceTriangles(selnum=3) print( "getBuriedSurfaceTriangles(selnum=3): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri)))
def test_08BuriedSurfaceCalculations(): print("______________________________") print("test_08BuriedSurfaceCalculations") print("______________________________") from mslib import MSMS, readxyzr, msms output1 = readxyzr('Data/1tpa_e.xyzr') coords_e=output1[0] names = output1[1] #coords_e, names = readxyzr('Data/1tpa_e.xyzr') output2 = readxyzr('Data/1tpa_i.xyzr') coords_i=output2[0] names = output2[1] #coords_i, names = readxyzr('Data/1tpa_i.xyzr') coords = coords_e[:,:3] rad = coords_e[:,3] m = MSMS(coords=coords, radii = rad) m.compute() m.buriedVertices(coords_i) vfloat, vint, tri = m.getTriangles() indBuried = Numeric.nonzero(vint[:,2]) print(len(indBuried)," vertices buried") m.resetBuriedVertexArea() m.compute_numeric_area_vol(component=0, mode=msms.MS_SEMI_ANALYTICAL) print(m.sesr.fst.n_ses_volume) print(m.sesr.fst.n_ses_area) m.buriedSurfaceArea() print(m.sesr.fst.n_buried_ses_area) print(m.sesr.fst.n_buried_sas_area) vfloat, vint, tri = m.getBuriedSurfaceTriangles(selnum=1) print("getBuriedSurfaceTriangles(selnum=1): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri))) vfloat, vint, tri = m.getBuriedSurfaceTriangles(selnum=2) print("getBuriedSurfaceTriangles(selnum=2): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri))) vfloat, vint, tri = m.getBuriedSurfaceTriangles(selnum=3) print("getBuriedSurfaceTriangles(selnum=3): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri)))
#!/usr/bin/env python from mslib import MSMS from forcebalance.nifty import lp_load, lp_dump import numpy as np import os # Designed to be called from GenerateQMData.py # I wrote this because MSMS seems to have a memory leak xyz, radii, density = lp_load(open('msms_input.p')) MS = MSMS(coords = list(xyz), radii = radii) MS.compute(density=density) vfloat, vint, tri = MS.getTriangles() with open(os.path.join('msms_output.p'), 'w') as f: lp_dump(vfloat, f)
#raise ValueError, "File " + protsys+'_l_b.pqr not found' #ligand = protsys+'_l_b.pqr' # read molecule from MolKit import Read mols = Read(receptor) # get coords and radii coords = mols.allAtoms.coords rads = mols.allAtoms.radius print "Computing MSMS" # compute MSMS from mslib import MSMS msms = MSMS(coords=coords, radii=rads) stat = msms.compute(density=6.0) print "error is: ", stat print "Getting triangles" # retrieve triangles vf, vi, tri = msms.getTriangles() print "Decimating mesh" # decimate the mesh verts = vf[:, :3] faces = tri[:, :3] normals = vf[:, 3:6] # I think 2*nbAtoms triangles corresponds to nbAtoms vertices targetTri = 2 * len(mols.allAtoms) dv, ft, dn = decimate(verts, faces, normals, targetTri)