From 76458898674c9fc860e25936b28b90f637ad6833 Mon Sep 17 00:00:00 2001 From: Marcello Sega Date: Thu, 20 Jul 2017 15:00:53 +0200 Subject: [PATCH] cleanup --- docs/source/micelle.rst | 26 +++++++++++++------------- pytim/gitim.py | 41 ++++++++++++++--------------------------- setup.py | 4 +++- 3 files changed, 30 insertions(+), 41 deletions(-) diff --git a/docs/source/micelle.rst b/docs/source/micelle.rst index df5f3100..ef6b7734 100644 --- a/docs/source/micelle.rst +++ b/docs/source/micelle.rst @@ -68,7 +68,7 @@ Some statistics It's easy to calculate some simple statistical properties. For example, the percentage of atoms of DPC at the surface is >>> print "percentage of atoms at the surface: {:.1f}".format(len(inter.layers[0])*100./len(g)) - percentage of atoms at the surface: 37.4 + percentage of atoms at the surface: 37.8 This is a rather high percentage, but is due to the small size of the micelle (large surface/volume ratio) @@ -80,26 +80,26 @@ We can also easily find out which atom is more likely to be found at the surface ... surface = np.sum(inter.layers[0].names == name ) ... print('{:>4s} ---> {:>2.0f}%'.format(name, surface*100./total)) C1 ---> 86% - C2 ---> 57% - C3 ---> 75% + C2 ---> 60% + C3 ---> 78% N4 ---> 0% - C5 ---> 69% + C5 ---> 71% C6 ---> 88% - O7 ---> 60% - P8 ---> 0% - O9 ---> 72% + O7 ---> 57% + P8 ---> 2% + O9 ---> 71% O10 ---> 82% O11 ---> 49% - C12 ---> 34% - C13 ---> 38% - C14 ---> 12% + C12 ---> 32% + C13 ---> 40% + C14 ---> 15% C15 ---> 23% - C16 ---> 9% - C17 ---> 17% + C16 ---> 11% + C17 ---> 18% C18 ---> 11% C19 ---> 18% C20 ---> 11% - C21 ---> 14% + C21 ---> 12% C22 ---> 17% C23 ---> 17% diff --git a/pytim/gitim.py b/pytim/gitim.py index 9b841464..38f2ff66 100755 --- a/pytim/gitim.py +++ b/pytim/gitim.py @@ -6,10 +6,10 @@ """ import numpy as np -from scipy.spatial import Delaunay from scipy.spatial import distance from pytim import utilities import pytim +from pytetgen import Delaunay class GITIM(pytim.PYTIM): @@ -25,8 +25,6 @@ class GITIM(pytim.PYTIM): (from GROMOS 43a1) will be used. :param int max_layers: the number of layers to be identified :param bool info: print additional info - :param bool multiproc: parallel version (default: True. \ - Switch off for debugging) Example: @@ -43,7 +41,7 @@ class GITIM(pytim.PYTIM): >>> layer = interface.layers[0] >>> interface.writepdb('gitim.pdb',centered=False) >>> print repr(layer) - + """ _surface = None @@ -62,7 +60,6 @@ def __init__( molecular=True, extra_cluster_groups=None, info=False, - multiproc=True, centered=False, **kargs): @@ -87,13 +84,10 @@ def __init__( if(self.symmetry == 'planar'): sanity.assign_normal(normal) - self.grid = None - self.use_threads = False - self.use_kdtree = True - self.use_multiproc = multiproc - pytim.PatchTrajectory(universe.trajectory, self) + self._assign_layers() + self._atoms = self.LayerAtomGroupFactory( self._layers[:].sum().indices, self.universe) @@ -152,7 +146,8 @@ def circumradius(self, simplex): # out of points alinged in the plane return 0 else: - raise + raise RuntimeError(err.message) + v = r_i[1] - r_i[0] A = - (rad_i[0] - np.dot(u, v)) @@ -179,21 +174,14 @@ def alpha_shape(self, alpha): points, box, delta,method='3d' ) # add points at the vertices of the expanded (by 2 alpha) box - for dim in range(8): - # [0,0,0],[0,0,1],[0,1,0],...,[1,1,1] - tmp = np.array( - np.array( - list( - np.binary_repr( - dim, - width=3)), - dtype=np.int8), - dtype=np.float) - tmp *= (box + delta) - tmp += gitter[dim] # added to prevent coplanar points - tmp[tmp < box / 2.] -= delta - tmp = np.reshape(tmp, (1, 3)) - extrapoints = np.append(extrapoints, tmp, axis=0) + cube_vertices = np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 1.0, 0.0], + [0.0, 1.0, 1.0], [1.0, 0.0, 0.0], [1.0, 0.0, 1.0], + [1.0, 1.0, 0.0], [1.0, 1.0, 1.0]]) + for dim,vertex in enumerate(cube_vertices): + vertex = vertex * box + delta + gitter[dim] # added to prevent coplanar points + vertex [vertex < box / 2.] -= 2*delta + vertex = np.reshape(vertex, (1, 3)) + extrapoints = np.append(extrapoints, vertex, axis=0) extraids = np.append(extraids, -1) # print utilities.lap() @@ -236,7 +224,6 @@ def _assign_layers(self): self.label_group(self.cluster_group.atoms, 0.0) size = len(self.cluster_group.positions) - self._seen = np.zeros(size, dtype=np.int8) alpha_ids = self.alpha_shape(self.alpha) diff --git a/setup.py b/setup.py index 59d1f7ce..a02dbceb 100644 --- a/setup.py +++ b/setup.py @@ -90,7 +90,9 @@ # your project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html - install_requires=['MDAnalysis>=0.15','PyWavelets>=0.5.2','numpy>=1.12.0','scipy>=0.18','scikit-image>=0.13.0','cython>=0.24.1','sphinx>=1.4.3','matplotlib'], + install_requires=['MDAnalysis>=0.15','PyWavelets>=0.5.2','numpy>=1.12.0', + 'scipy>=0.18','scikit-image>=0.13.0','cython>=0.24.1', + 'sphinx>=1.4.3','matplotlib','pytetgen'], # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax,