Skip to content

Commit

Permalink
zero radis handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcello-Sega committed Aug 6, 2024
1 parent f6590d1 commit 5a9f553
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pytim/gitim.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def __init__(self,
max_layers=1,
radii_dict=None,
cluster_cut=None,
include_zero_radius=False,
cluster_threshold_density=None,
extra_cluster_groups=None,
biggest_cluster_only=False,
Expand Down Expand Up @@ -155,10 +156,12 @@ def __init__(self,
self.normal = None
self.PDB = {}
self.molecular = molecular
self.include_zero_radius = include_zero_radius
sanity.assign_cluster_params(cluster_cut,
cluster_threshold_density, extra_cluster_groups)
sanity.check_multiple_layers_options()
sanity.assign_radii(radii_dict=radii_dict)
sanity.prune_zero_radius_atoms()

self._assign_symmetry(symmetry)
try:
Expand Down
3 changes: 3 additions & 0 deletions pytim/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class Interface(object):
autoassign, _autoassign =\
_create_property('autoassign',
"(bool) assign layers every time a frame changes")
include_zero_radius, _include_zero_radius=\
_create_property('include_zero_radius',
"(bool) include atoms with zero radius in the analysis (excluded by default)")
cluster_threshold_density, _cluster_threshold_density =\
_create_property('cluster_threshold_density',
"(float) threshold for the density-based filtering")
Expand Down
3 changes: 3 additions & 0 deletions pytim/itim.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def __init__(self,
max_layers=1,
radii_dict=None,
cluster_cut=None,
include_zero_radius=False,
cluster_threshold_density=None,
extra_cluster_groups=None,
info=False,
Expand Down Expand Up @@ -214,11 +215,13 @@ def __init__(self,
self.normal = None
self.PDB = {}
self.molecular = molecular
self.include_zero_radius = include_zero_radius

sanity.assign_cluster_params(cluster_cut,
cluster_threshold_density, extra_cluster_groups)
sanity.assign_normal(normal)
sanity.assign_radii(radii_dict=radii_dict)
sanity.prune_zero_radius_atoms()

self.grid = None
self.use_threads = False
Expand Down
5 changes: 5 additions & 0 deletions pytim/sanity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ def assign_radii(self, radii_dict=None):
except BaseException:
pass

def prune_zero_radius_atoms(self):
if self.interface.include_zero_radius == False:
cond = self.interface.analysis_group.radii > 0.0
self.interface.analysis_group = self.interface.analysis_group[cond]

def patch_radii_dict(self):
""" Fix here by hand common problems with radii assignment """
self.interface.radii_dict['D'] = 0.0
Expand Down
3 changes: 3 additions & 0 deletions pytim/simple_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ def __init__(self,
alpha=1.5,
symmetry='generic',
normal='z',
include_zero_radius=False,
upper=None,
lower=None):

self.symmetry = symmetry
self.universe = universe
self.group = group
self.alpha = alpha
self.include_zero_radius = include_zero_radius
self.upper = upper
self.lower = lower
emptyg = universe.atoms[0:0]
Expand All @@ -99,6 +101,7 @@ def __init__(self,
sanity.assign_universe(universe, group)
sanity.assign_alpha(alpha)
sanity.assign_radii(radii_dict=None)
sanity.prune_zero_radius_atoms()
if normal in [0, 1, 2]:
self.normal = normal
else:
Expand Down
3 changes: 3 additions & 0 deletions pytim/willard_chandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self,
mesh=2.0,
symmetry='spherical',
cluster_cut=None,
include_zero_radius=False,
cluster_threshold_density=None,
extra_cluster_groups=None,
centered=False,
Expand All @@ -124,6 +125,7 @@ def __init__(self,
**kargs):

self.autoassign, self.do_center = autoassign, centered
self.include_zero_radius = include_zero_radius
sanity = SanityCheck(self, warnings=warnings)
sanity.assign_universe(universe, group)
sanity.assign_alpha(alpha)
Expand All @@ -133,6 +135,7 @@ def __init__(self,
self.mesh, self.spacing, self.ngrid, self.PDB = mesh, None, None, {}

sanity.assign_radii(radii_dict=radii_dict)
sanity.prune_zero_radius_atoms()

sanity.assign_cluster_params(cluster_cut,
cluster_threshold_density, extra_cluster_groups)
Expand Down

0 comments on commit 5a9f553

Please sign in to comment.