diff --git a/modules/bindings/pymod/msms.py b/modules/bindings/pymod/msms.py index 7f9e089ffe63b92f036fe35151593205b25ae6c9..4b1638f2ae3f561ecc1e5f42dd5f5994a319a164 100644 --- a/modules/bindings/pymod/msms.py +++ b/modules/bindings/pymod/msms.py @@ -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 diff --git a/modules/bindings/tests/test_msms.py b/modules/bindings/tests/test_msms.py index 8cd56ee5a5b8577ba2c82a39e408bc01c60a4617..61810be5576058d45cbe6b929052eb9522ca1531 100755 --- a/modules/bindings/tests/test_msms.py +++ b/modules/bindings/tests/test_msms.py @@ -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__": diff --git a/modules/gui/pymod/init_context_menu.py b/modules/gui/pymod/init_context_menu.py index 85e991a02fc9937b2d878b2d183ddf0b05e4e40d..b26e5d3d71d7c6e1f0e35697af3f8db1d339fb81 100644 --- a/modules/gui/pymod/init_context_menu.py +++ b/modules/gui/pymod/init_context_menu.py @@ -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)