Skip to content
Snippets Groups Projects
Commit 1c853794 authored by tobias's avatar tobias
Browse files

modified MSMS surface calculation

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2648 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 71cd5abc
Branches
Tags
No related merge requests found
......@@ -134,7 +134,8 @@ def _RunMSMS(command):
# \param attach_esa Attaches per atom SESA to specified FloatProp at atom level
# \return Touplet of lists for (SES, SAS)
def CalculateSurfaceArea(entity, density=1.0, radius=1.5, all_surf=False,
no_hydrogens=False, selection="",
no_hydrogens=False, no_hetatoms=False, no_waters=False,
selection="",
msms_exe=None, msms_env=None, keep_files=False,
attach_asa=None, attach_esa=None):
import re
......@@ -144,10 +145,19 @@ def CalculateSurfaceArea(entity, density=1.0, radius=1.5, all_surf=False,
# parse selection
if no_hydrogens:
if selection=="":
selection="ele!=H"
else:
selection+=" and ele!=H"
if selection!='':
selection+=" and "
selection="ele!=H"
if no_hetatoms:
if selection!='':
selection+=" and "
selection="ishetatm=False"
if no_waters:
if selection!='':
selection+=" and "
selection="rname!=HOH"
# setup files for msms
(msms_data_dir, msms_data_file)=_SetupFiles(entity, selection)
......@@ -208,8 +218,10 @@ def CalculateSurfaceArea(entity, density=1.0, radius=1.5, all_surf=False,
# \param keep_files Do not delete temporary files
# \return list of OST SurfaceHandle objects
def CalculateSurface(entity, density=1.0, radius=1.5, all_surf=False,
no_hydrogens=False, selection="",
no_hydrogens=False, no_hetatoms=False, no_waters=False,
selection="",
msms_exe=None, msms_env=None, keep_files=False):
import os
import re
......@@ -218,10 +230,19 @@ def CalculateSurface(entity, density=1.0, radius=1.5, all_surf=False,
# parse selection
if no_hydrogens:
if selection=="":
selection="ele!=H"
else:
selection+=" and ele!=H"
if selection!='':
selection+=" and "
selection="ele!=H"
if no_hetatoms:
if selection!='':
selection+=" and "
selection="ishetatm=False"
if no_waters:
if selection!='':
selection+=" and "
selection="rname!=HOH"
# setup files for msms
......
......@@ -16,13 +16,13 @@ class TestMSMSBindings(unittest.TestCase):
surf=msms.CalculateSurface(self.protein, msms_env='MSMSSERVER')[0]
assert self.num_vert==len(surf.GetVertexIDList()) \
and self.num_tri==len(surf.GetTriIDList()), \
"Number of surface vertices or triangles do not match precalculated values"
"Number of surface vertices (%i) or triangles (%i) do not match precalculated values (%i/%i)"%(len(surf.GetVertexIDList()),len(surf.GetTriIDList()),self.num_vert,self.num_tri)
def testCalculateSurfaceAres(self):
(msms_ases, msms_asas)=msms.CalculateSurfaceArea(self.protein, \
msms_env='MSMSSERVER')
assert self.ases==msms_ases[0] and self.asas==msms_asas[0], \
"SASA or SESA do not match precalculated values"
"SASA (%f) or SESA (%f) do not match precalculated values (%f/%f)"%(msms_asas[0],msms_ases[0],self.asas,self.ases)
if __name__ == "__main__":
......
......@@ -163,7 +163,11 @@ class CalculateSurfaceSettingsDialog(QtGui.QDialog):
vb.addWidget(selection_label, 4, 0)
vb.addWidget(self.selection_field, 4, 1, 1, 2)
self.noh_box=QtGui.QCheckBox("no hydrogens")
vb.addWidget(self.noh_box, 5, 0, 1, 2)
vb.addWidget(self.noh_box, 5, 0)
self.nohet_box=QtGui.QCheckBox("no hetatoms")
vb.addWidget(self.nohet_box, 5, 1)
self.nowat_box=QtGui.QCheckBox("no waters")
vb.addWidget(self.nowat_box, 5, 2)
cancel_btn = QtGui.QPushButton("Cancel", self)
ok_btn = QtGui.QPushButton("OK", self)
......@@ -176,7 +180,8 @@ class CalculateSurfaceSettingsDialog(QtGui.QDialog):
def GetPath(self):
path=QtGui.QFileDialog().getOpenFileName(self, "Choose MSMS Executable")
self.msmsexe_field.setText(path)
if path!='':
self.msmsexe_field.setText(path)
class SurfaceContextMenu(QtCore.QObject):
def __init__(self, context_menu):
......@@ -204,9 +209,12 @@ class SurfaceContextMenu(QtCore.QObject):
cssd.density_spinbox.value(),
cssd.probe_spinbox.value(),
str(cssd.selection_field.text()),
cssd.noh_box.isChecked())
cssd.noh_box.isChecked(),
cssd.nohet_box.isChecked(),
cssd.nowat_box.isChecked())
def __CalculateSurface(self,ent_list,name,msms_exe,density,radius,selection,noh):
def __CalculateSurface(self,ent_list,name,msms_exe,density,
radius,selection,noh,nohet,nowat):
for entity in ent_list:
if isinstance(entity, gfx.Entity):
try:
......@@ -215,11 +223,16 @@ class SurfaceContextMenu(QtCore.QObject):
density=density,
radius=radius,
selection=selection,
no_hydrogens=noh)[0]
no_hydrogens=noh,
no_hetatoms=nohet,
no_waters=nowat)[0]
gfx.Scene().Add(gfx.Surface("%s_%s"%(entity.GetName(),name),s))
except (RuntimeError, CalledProcessError):
LogError("WARNING: Surface could not be calculated")
return
except UserWarning:
LogError("WARNING: Entry with the same name already present in scene")
return
class AlignmentContextMenu(QtCore.QObject):
......@@ -299,4 +312,4 @@ class AlignmentContextMenu(QtCore.QObject):
def _InitContextMenu(app):
cm=app.scene_win.GetContextMenu()
AlignmentContextMenu(cm)
SurfaceContextMenu(cm)
\ No newline at end of file
SurfaceContextMenu(cm)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment