Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

willard_chandler.py #332

Merged
merged 0 commits into from
Apr 18, 2024
Merged

willard_chandler.py #332

merged 0 commits into from
Apr 18, 2024

Conversation

Zhu-Liu
Copy link

@Zhu-Liu Zhu-Liu commented Apr 13, 2020

From Line 210:

    ngrid, spacing = utilities.compute_compatible_mesh_params(
        self.mesh, box)
    self.spacing, self.ngrid = spacing, ngrid
    #print ("spacing: ", self.spacing)
    #print ("grid: ", self.ngrid)
    #print ("mesh: ", self.mesh)
    grid = utilities.generate_grid_in_box(box, ngrid, order='xyz')
    kernel, _ = utilities.density_map(pos, grid, self.alpha, box)
    #print ("kernel: ", kernel.__dict__)

    #print ("position: ", pos)
    #print ("position shape: ", np.array(pos).shape)

    kernel.pos = pos.copy()
    self.density_field = kernel.evaluate_pbc_fast(grid)

    # Thomas Lewiner, Helio Lopes, Antonio Wilson Vieira and Geovan
    # Tavares. Efficient implementation of Marching Cubes’ cases with
    # topological guarantees. Journal of Graphics Tools 8(2) pp. 1-15
    # (december 2003). DOI: 10.1080/10867651.2003.10487582
    volume = self.density_field.reshape(
        tuple(np.array(ngrid[::-1]).astype(int)))
    #verts, faces, normals, values = marching_cubes(
    #    volume, None, spacing=tuple(spacing))
    volume_cut = volume.max() - 0.9*volume.ptp()
    verts, faces, normals, values = marching_cubes(
        volume, volume_cut, spacing=tuple(spacing))

    # note that len(normals) == len(verts): they are normals
    # at the vertices, and not normals of the faces
    self.triangulated_surface = [verts, faces, normals]
    self.surface_area = measure.mesh_surface_area(verts, faces)
    #verts += spacing[::-1] / 2.

pytim/patches.py Outdated
def patchMDTRAJ_ReplacementTables():
try:
import mdtraj
if not (mdtraj.formats.pdb.PDBTrajectoryFile._atomNameReplacements=={}):
if not (mdtraj.formats.pdb.PDBTrajectoryFile._atomNameReplacements == {}):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (82 > 79 characters)

from .willard_chandler import WillardChandler
from .chacon_tarazona import ChaconTarazona
from . import observables, utilities, datafiles
from .version import __version__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.version.version' imported but unused

from .sasa import SASA
from .willard_chandler import WillardChandler
from .chacon_tarazona import ChaconTarazona
from . import observables, utilities, datafiles

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.datafiles' imported but unused
'.observables' imported but unused
'.utilities' imported but unused

from .gitim import GITIM
from .sasa import SASA
from .willard_chandler import WillardChandler
from .chacon_tarazona import ChaconTarazona

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.chacon_tarazona.ChaconTarazona' imported but unused

from .itim import ITIM
from .gitim import GITIM
from .sasa import SASA
from .willard_chandler import WillardChandler

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.willard_chandler.WillardChandler' imported but unused

from .simple_interface import SimpleInterface
from .itim import ITIM
from .gitim import GITIM
from .sasa import SASA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.sasa.SASA' imported but unused

@@ -2,18 +2,18 @@
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#from pytim.patches import patchTrajectory, patchOpenMM, patchMDTRAJ

from .simple_interface import SimpleInterface
from .itim import ITIM
from .gitim import GITIM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.gitim.GITIM' imported but unused

@@ -2,18 +2,18 @@
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#from pytim.patches import patchTrajectory, patchOpenMM, patchMDTRAJ

from .simple_interface import SimpleInterface
from .itim import ITIM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.itim.ITIM' imported but unused

@@ -2,18 +2,18 @@
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#from pytim.patches import patchTrajectory, patchOpenMM, patchMDTRAJ

from .simple_interface import SimpleInterface

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.simple_interface.SimpleInterface' imported but unused

@@ -16,6 +16,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import sphinx.ext.autodoc

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'sphinx.ext.autodoc' imported but unused

@Marcello-Sega
Copy link
Owner

Hi,

I don't understand what you would like to merge. You should branch off the master branch, make your changes and then set up a pull request from your branch into the master branch here.

I went through your branches, could it be what you want to merge is https://github.com/Zhu-Liu/pytim/tree/patch-1 ?

If you have some trouble, you can have a look at https://opensource.com/article/19/7/create-pull-request-github or just contact me back.

@Zhu-Liu
Copy link
Author

Zhu-Liu commented May 15, 2020 via email

pytim/version.py Outdated
@@ -1 +1 @@
__version__ = '0.8.1'
__version__ = '0.8.2'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Black would make changes.

label_max = np.argmax(counts)
ids_max = np.where(labels == label_max)[0]
self.cluster_group = self.cluster_group[ids_max]
except AttributeError: # biggest_cluster_only not set

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least two spaces before inline comment

<AtomGroup with 2025 atoms>


>>> inter = pytim.SASA( g, alpha=2.5, max_layers=2, cluster_cut=3.5, biggest_cluster_only=True, molecular=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (119 > 79 characters)

>>> u = mda.Universe(ANTAGONISTIC_GRO)
>>> g = u.atoms.select_atoms('resname bph4')
>>> # Define the interface
>>> inter = pytim.SASA( g, alpha=2.5, max_layers=2, cluster_cut=3.5, biggest_cluster_only=False, molecular=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (120 > 79 characters)

@@ -293,6 +292,9 @@ def _vdwradii_gmx(self, filename):
ILBENZENE_GRO = resource_filename('pytim', 'data/ilbenzene.gro')
pytim_data.add('ILBENZENE_GRO', 'conf', 'GRO', 'BMIM PF4 / benzene interface')

ANTAGONISTIC_GRO = resource_filename('pytim', 'data/antagonistic.gro')
pytim_data.add('ANTAGONISTIC_GRO', 'conf', 'GRO', '3-Methylpyridine, Sodium Tetraphenylborate and water')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (105 > 79 characters)

normal_component[normal_component<-1.0]=-1.0
orthogonal_component = np.sqrt(1-normal_component**2)
phi = np.mod(np.arctan2(normal_component, orthogonal_component),np.pi/2)
return costheta,phi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace after ','

normal_component[normal_component>1.0]=1.0
normal_component[normal_component<-1.0]=-1.0
orthogonal_component = np.sqrt(1-normal_component**2)
phi = np.mod(np.arctan2(normal_component, orthogonal_component),np.pi/2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (80 > 79 characters)
missing whitespace after ','

normal_component = np.sum(v*v_normal,axis=1)
# avoid numerical errors
normal_component[normal_component>1.0]=1.0
normal_component[normal_component<-1.0]=-1.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace around operator

v = v / np.linalg.norm(v,axis=1)[:,np.newaxis]
normal_component = np.sum(v*v_normal,axis=1)
# avoid numerical errors
normal_component[normal_component>1.0]=1.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace around operator

# the surface normal projected on the plane with normal v_dipole
v = (v_surface-v_dipole*costheta[:,np.newaxis])
v = v / np.linalg.norm(v,axis=1)[:,np.newaxis]
normal_component = np.sum(v*v_normal,axis=1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace after ','

options=['']
if molecular: options=['molecular']
self.molecular_plane_vector = Orientation(universe,options=options+['normal'])
self.dipole_vector = Orientation(universe,options=options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace after ','

def __init__(self, universe, molecular=False):
options=['']
if molecular: options=['molecular']
self.molecular_plane_vector = Orientation(universe,options=options+['normal'])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (87 > 79 characters)
missing whitespace after ','
multiple spaces before operator


def __init__(self, universe, molecular=False):
options=['']
if molecular: options=['molecular']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace around operator
multiple statements on one line (colon)

"""

def __init__(self, universe, molecular=False):
options=['']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace around operator

The angles are computed according to Jedlovszky et al., Phys. Chem. Chem. Phys., 2004, 6, 1874–1879

:param: bool molecular: if True, uses the option "molecular=True" in the calculation of the
molecular axes (using pytim.observables.Orientation)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (85 > 79 characters)


The angles are computed according to Jedlovszky et al., Phys. Chem. Chem. Phys., 2004, 6, 1874–1879

:param: bool molecular: if True, uses the option "molecular=True" in the calculation of the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (100 > 79 characters)

""" Two angles characterizing the orientation next to a surface of an axisymmetric molecule
like water.

The angles are computed according to Jedlovszky et al., Phys. Chem. Chem. Phys., 2004, 6, 1874–1879

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (107 > 79 characters)

@@ -57,3 +57,80 @@ def compute(self, inp, kargs=None):
v = np.array(a + b)
v = np.array([el / np.sqrt(np.dot(el, el)) for el in v])
return v

class BivariateAngles(Observable):
""" Two angles characterizing the orientation next to a surface of an axisymmetric molecule

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (91 > 79 characters)

@@ -57,3 +57,80 @@ def compute(self, inp, kargs=None):
v = np.array(a + b)
v = np.array([el / np.sqrt(np.dot(el, el)) for el in v])
return v

class BivariateAngles(Observable):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 1

@@ -28,7 +28,7 @@ def __init__(self, universe, options=''):
def compute(self, inp, kargs=None):
"""Compute the observable.

:param ndarray inp: the input atom group. The length be a multiple
:param ndarray inp: the input atom group. The length must be a multiple

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (80 > 79 characters)

@@ -19,5 +19,5 @@
from .rdf2d import RDF2D
from .free_volume import FreeVolume
from .correlator import Correlator
from .orientation import Orientation
from .orientation import Orientation,BivariateAngles

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'.orientation.BivariateAngles' imported but unused
'.orientation.Orientation' imported but unused
Black would make changes.
missing whitespace after ','

@@ -226,6 +226,7 @@ def _assign_layers(self):
volume, None, spacing=tuple(spacing))
# note that len(normals) == len(verts): they are normals
# at the vertices, and not normals of the faces
self.triangulated_surface = [verts, faces, normals]
# verts and normals have x and z flipped because skimage uses zyx ordering
self.triangulated_surface = [np.fliplr(verts), faces, np.fliplr(normals)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

@@ -226,6 +226,7 @@ def _assign_layers(self):
volume, None, spacing=tuple(spacing))
# note that len(normals) == len(verts): they are normals
# at the vertices, and not normals of the faces
self.triangulated_surface = [verts, faces, normals]
# verts and normals have x and z flipped because skimage uses zyx ordering

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (82 > 79 characters)

pytim/itim.py Outdated
@@ -195,7 +195,7 @@ def __init__(self,
**kargs):

self.autoassign = autoassign

self.biggest_cluster_only = True # necessary for ITIM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least two spaces before inline comment

label_max = np.argmax(counts)
ids_max = np.where(labels == label_max)[0]
self.cluster_group = self.cluster_group[ids_max]
else: # we still filter out molecules which do not belong to any cluster

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least two spaces before inline comment
line too long (84 > 79 characters)

pytim/itim.py Outdated
else:
for index, group in enumerate(self._assign_one_side(up, sort[::-1], _x, _y, _z, _radius)):
self._layers[up][index] = group
for index, group in enumerate(self._assign_one_side(low, sort[::], _x, _y, _z, _radius)):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (101 > 79 characters)

pytim/itim.py Outdated
for q in queue:
q.close()
else:
for index, group in enumerate(self._assign_one_side(up, sort[::-1], _x, _y, _z, _radius)):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (102 > 79 characters)

pytim/itim.py Outdated
# info about universe is lost (do not know why yet)
# must use self._layers[uplow][index] =
# self.universe.atoms[group.indices]
self._layers[uplow][index] = self.universe.atoms[group.indices]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (83 > 79 characters)

@Marcello-Sega Marcello-Sega merged commit 0baf046 into Marcello-Sega-patch-1 Apr 18, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants