Skip to content
Snippets Groups Projects
Commit 569a5582 authored by kieferf's avatar kieferf
Browse files

Add attach_asa parameter to the CalculateSurfaceArea method, attach_asa...

Add attach_asa parameter to the CalculateSurfaceArea method, attach_asa specifies the name of the FloatProperty which the asa is attached (on atom level)

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1879 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent c7361d38
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,27 @@ def _SetupFiles(entity, selection): ...@@ -59,7 +59,27 @@ def _SetupFiles(entity, selection):
tmp_file_handle.close() tmp_file_handle.close()
return (tmp_dir_name, tmp_file_name) return (tmp_dir_name, tmp_file_name)
## \brief Reads Area file (-af) and attach sasa and sesa per atom to an entitiy
#
# \param entity EntityHandle or EntityView for attaching sasa and sesa on atom level
# \param file Filename of area file
# \param property Name of the float property
# \exception RuntimeError if number of atoms in file != number of atoms in entity
def _ParseAreaFile(entity,file, property):
area_fh = open(file)
area_lines = area_fh.readlines()
area_fh.close()
# shift first line
area_lines = area_lines[1:]
if entity.GetAtomCount() != len(area_lines):
raise RuntimeError, "Atom count (%d) unequeal to number of atoms in area file (%d)" % (entity.GetAtomCount(), len(area_lines))
for l in area_lines:
atom_no, sesa, sasa = l.split()
a = entity.atoms[int(atom_no)]
a.SetGenericFloatProperty(property, float(sasa))
## \brief Method which recursively deletes a directory ## \brief Method which recursively deletes a directory
# #
# \warning This method removes also non-empty directories without asking, so # \warning This method removes also non-empty directories without asking, so
...@@ -109,7 +129,8 @@ def _RunMSMS(command): ...@@ -109,7 +129,8 @@ def _RunMSMS(command):
# \return Touplet of lists for (SES, SAS) # \return Touplet of lists for (SES, SAS)
def CalculateSurfaceArea(entity, density=1.0, radius=1.5, all_surf=False, def CalculateSurfaceArea(entity, density=1.0, radius=1.5, all_surf=False,
no_hydrogens=False, selection="", no_hydrogens=False, selection="",
msms_exe=None, msms_env=None, keep_files=False): msms_exe=None, msms_env=None, keep_files=False,
attach_asa = None):
import re import re
# check if msms executable is specified # check if msms executable is specified
...@@ -127,10 +148,15 @@ def CalculateSurfaceArea(entity, density=1.0, radius=1.5, all_surf=False, ...@@ -127,10 +148,15 @@ def CalculateSurfaceArea(entity, density=1.0, radius=1.5, all_surf=False,
(msms_executable, msms_data_file, msms_data_file, density, radius) (msms_executable, msms_data_file, msms_data_file, density, radius)
if all_surf: if all_surf:
command+=" -all" command+=" -all"
if attach_asa != None:
command+=" -af %s" % os.path.join(msms_data_dir, "asa_atom")
# run msms # run msms
stdout_value=_RunMSMS(command) stdout_value=_RunMSMS(command)
# add sesa and asa to entity if attach_asa is specified
if attach_asa != None:
_ParseAreaFile(entity, os.path.join(msms_data_dir, "asa_atom.area"), attach_asa)
# parse MSMS output # parse MSMS output
msms_ases=[] msms_ases=[]
msms_asas=[] msms_asas=[]
...@@ -185,7 +211,7 @@ def CalculateSurface(entity, density=1.0, radius=1.5, all_surf=False, ...@@ -185,7 +211,7 @@ def CalculateSurface(entity, density=1.0, radius=1.5, all_surf=False,
selection+=" and ele!=H" selection+=" and ele!=H"
# setup files for msms # setup files for msms
print selection
(msms_data_dir, msms_data_file)=_SetupFiles(entity, selection) (msms_data_dir, msms_data_file)=_SetupFiles(entity, selection)
# set command line # set command line
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment