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)
Пример #2
0
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)
Пример #3
0
def test_03SurfaceFromFile():
    print("___________________")
    print("test_03SurfacefroFile")
    print("___________________")
    from mslib import MSMS
    #print "current dir:", os.getcwd()
    m = MSMS(filename='Data/1crn.xyzrn')
Пример #4
0
#!/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)
Пример #5
0
def test_04RScalculations():
    print("___________________")
    print("test_04RScalculations")
    print("___________________")
    from mslib import MSMS, readxyzr, msms
    # compute all components with default probe radius 1.5
    global coords, rad
    m1 = MSMS(coords=coords, radii=rad)
    m1.compute_rs()
    ar = m1.rsr.fst.far0
    print("printing -n, -ct...")
    print(ar._n())
    print(ar._ct())
    print(ar._cp())
    print(ar._cc())
    print(ar._rcc())
    print(ar._ps())
    print(ar._s())
    # recompute reduced surface with probe sphere radius = 2.0
    m1.compute_rs(probe_radius=2.0)
    # Multiple components
    output = readxyzr('Data/1crn.xyzr')
    new_coords = output[0]
    names = output[1]
    #new_coords, names = readxyzr('Data/1crn.xyzr')
    coords = new_coords[:, :3]
    rad = new_coords[:, 3]

    m2 = MSMS(coords=coords, radii=rad)
    # "***** COMPUTE EXTERNAL COMPONENT"
    m2.compute_rs()
    print("Info1:")
    print(m2.info())

    # "      ADD OTHER COMPONENTS"
    m2.compute_rs(allComponents=1)
    print("Info2:")
    print(m2.info())

    # "      CLEAR RSR"
    # "      COMPUTE ONE CAVITY"
    msms.MS_reset_RSR(m2.this)
    m2.compute_rs(atoms=(11, -1, -1))
    print("Info3:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs(atoms=(13, -1, -1))
    print("Info4:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs(atoms=(93, -1, -1))
    print("Info5:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs(atoms=(11, 13, -1))
    print("Info6:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs(atoms=(13, 11, -1))
    print("Info7:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs(atoms=(13, 93, -1))
    print("Info8:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs(atoms=(13, 93, 11))
    print("Info9:")
    print(m2.info())
Пример #6
0
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)))
Пример #7
0
def test_02SurfaceCoordsRadii():
    print("___________________")
    print("test_02SurfaceCoordsRadii")
    print("___________________")
    from mslib import MSMS
    m = MSMS(coords=coords, radii=rad)
Пример #8
0
def test_06Triangulation():
    print("___________________")
    print("test_06Triangulation")
    print("___________________")
    from mslib import MSMS, msms
    # triangulate with default parameters, component = 0

    m = MSMS(coords=coords, radii=rad)
    m.compute_rs(allComponents=1)
    m.compute_ses(0)
    m.compute_ses(1)
    print("trinagulate 1")
    m.triangulate(component=0)
    print(m.info())
    # triangulate with default parameters, component = 1
    print("trinagulate 2")
    m.triangulate(component=1)
    print(m.info())

    # re-triangulate at density = 3.0
    print("trinagulate 3")
    m.triangulate(component=0, density=3.0)
    print(m.info())

    # triangulate all components
    print("trinagulate 4")
    m.triangulate(density=1.1)

    # write triangulation
    #m.write_triangulation('testAll')
    #m.write_triangulation('testAllnoh', no_header=1)
    #m.write_triangulation('testASES', component=1, format=msms.MS_ASES_ASCII)
    #m.write_triangulation('testTAVS', component=0, format=msms.MS_TSES_ASCII_AVS)
    #m.write_triangulation('testAAVS', component=0, format=msms.MS_ASES_ASCII_AVS)
    vfloat, vint, tri = m.getTriangles()
    print("getTriangles(): len(vfloat): %d, len(vint): %d, len(tri): %d" %
          (len(vfloat), len(vint), len(tri)))
    atomindices = [
        131, 120, 143, 147, 128, 146, 142, 137, 139, 130, 135, 136, 134, 129,
        145, 119, 133, 132, 141, 144, 138, 140
    ]
    vfloat, vint, tri = m.getTriangles(atomIndices=atomindices)
    print(
        "getTriangles(atomIndices=atomindices): len(vfloat): %d, len(vint): %d, len(tri): %d"
        % (len(vfloat), len(vint), len(tri)))
    # reset all after triangulation
    msms.MS_reset_RSR(m.this)
    print(m.info())
Пример #9
0
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))
Пример #10
0
def test_04RScalculations():
    print("___________________")
    print("test_04RScalculations")
    print("___________________")
    from mslib import MSMS, readxyzr, msms
    # compute all components with default probe radius 1.5
    global coords, rad
    m1 = MSMS(coords=coords, radii=rad)
    m1.compute_rs()
    ar = m1.rsr.fst.far0
    print("printing -n, -ct...")
    print(ar._n())
    print(ar._ct())
    print(ar._cp())
    print(ar._cc())
    print(ar._rcc())
    print(ar._ps())
    print(ar._s())
    # recompute reduced surface with probe sphere radius = 2.0
    m1.compute_rs(probe_radius=2.0)
    # Multiple components
    output = readxyzr('Data/1crn.xyzr')
    new_coords = output[0]
    names = output[1]
    #new_coords, names = readxyzr('Data/1crn.xyzr')
    coords = new_coords[:,:3]
    rad = new_coords[:,3]

    m2 = MSMS(coords=coords, radii = rad)
    # "***** COMPUTE EXTERNAL COMPONENT"
    m2.compute_rs()
    print("Info1:")
    print(m2.info())
    
    # "      ADD OTHER COMPONENTS"
    m2.compute_rs( allComponents=1 )
    print("Info2:")
    print(m2.info())

    # "      CLEAR RSR"
    # "      COMPUTE ONE CAVITY"
    msms.MS_reset_RSR(m2.this)
    m2.compute_rs( atoms = (11, -1, -1) )
    print("Info3:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs( atoms = (13, -1, -1) )
    print("Info4:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs( atoms = (93, -1, -1) )
    print("Info5:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs( atoms = (11, 13, -1) )
    print("Info6:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs( atoms = (13, 11, -1) )
    print("Info7:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs( atoms = (13, 93, -1) )
    print("Info8:")
    print(m2.info())

    msms.MS_reset_RSR(m2.this)
    m2.compute_rs( atoms = (13, 93, 11) )
    print("Info9:")
    print(m2.info())
Пример #11
0
def test_05SEScalculations():
    print("___________________")
    print("test_05SEScalculations")
    print("___________________")
    from mslib import MSMS, msms
    m = MSMS(coords=coords, radii=rad)
    m.compute_rs(allComponents=1)
    m.compute_ses()
    print(m.info())

    msms.MS_reset_RSR(m.this)
    m.compute_rs(allComponents=1)
    m.compute_ses(0)
    m.compute_ses(1)
    print(m.info())
Пример #12
0
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)))
Пример #13
0
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))
Пример #14
0
def test_06Triangulation():
    print("___________________")
    print("test_06Triangulation")
    print("___________________")
    from mslib import MSMS, msms
    # triangulate with default parameters, component = 0

    m = MSMS(coords=coords, radii = rad)
    m.compute_rs(allComponents=1)
    m.compute_ses(0 )
    m.compute_ses(1)
    print("trinagulate 1")
    m.triangulate( component=0 )
    print(m.info())
    # triangulate with default parameters, component = 1
    print("trinagulate 2")
    m.triangulate( component=1 )
    print(m.info())

    # re-triangulate at density = 3.0
    print("trinagulate 3")
    m.triangulate( component=0, density=3.0 )
    print(m.info())

    # triangulate all components
    print("trinagulate 4")
    m.triangulate( density=1.1 )

    # write triangulation
    #m.write_triangulation('testAll')
    #m.write_triangulation('testAllnoh', no_header=1)
    #m.write_triangulation('testASES', component=1, format=msms.MS_ASES_ASCII)
    #m.write_triangulation('testTAVS', component=0, format=msms.MS_TSES_ASCII_AVS)
    #m.write_triangulation('testAAVS', component=0, format=msms.MS_ASES_ASCII_AVS)
    vfloat, vint, tri = m.getTriangles()
    print("getTriangles(): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri)))
    atomindices = [131, 120, 143, 147, 128, 146, 142, 137, 139, 130, 135,
                   136, 134, 129, 145, 119, 133, 132, 141, 144, 138, 140]
    vfloat, vint, tri = m.getTriangles(atomIndices=atomindices)
    print("getTriangles(atomIndices=atomindices): len(vfloat): %d, len(vint): %d, len(tri): %d" % (len(vfloat), len(vint), len(tri)))
    # reset all after triangulation
    msms.MS_reset_RSR(m.this)
    print(m.info())
Пример #15
0
def test_05SEScalculations():
    print("___________________")
    print("test_05SEScalculations")
    print("___________________")
    from mslib import MSMS, msms
    m = MSMS(coords=coords, radii = rad)
    m.compute_rs( allComponents=1 )
    m.compute_ses()
    print(m.info())

    msms.MS_reset_RSR(m.this)
    m.compute_rs( allComponents=1 )
    m.compute_ses( 0 )
    m.compute_ses( 1 )
    print(m.info())
Пример #16
0
    #if not os.path.exists(protsys+'_l_b.pqr'):
    #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)