Physical Properties

Classes

class physical.region(sides)

Define a region as an extrusion of a polygon in the z direction

__init__(sides)
Parameters:sides – number of sides making up the region in the xy plane
Returns:region
xyregion(corners)
Parameters:corners – points defining the corners of the polygon making up the xy region
Returns:a region defined by corners

Functions

physical.thickness(filename, ref_atoms, grid, *traj, **kwargs)
Parameters:
  • filename – name of .gro file
  • ref_atoms – atoms which thickness will be based on
  • traj – trajectory of positions
Returns:

trajectory of thicknesses or single thickness based on max/min z coordinate of reference atoms

physical.conc(t, comp, b)

Calculate the concentration of the specified component :param t: mdtraj trajectory object for system being studied :param comp: component which you want the concentration of :param b: buffer. distance into membrane to go before starting calculation :return: concentration

physical.avg_pore_loc(npores, pos, box, buffer=0, spline=False, npts=20, progress=False, bins=False, spline_name='spline.pl')

Calculate average pore location for each pore at each frame

Parameters:
  • no_pores (int) – the number of pores in the unit cell
  • pos (numpy.ndarray, shape(ncomponents, 3) or numpy.ndarray, shape(nframes, ncomponents, 3)) – the coordinates of the component(s) which you are using to locate the pore centers
  • box (numpy.ndarray, shape(nframes, 3, 3)) – box vectors (t.unitcell_vectors when trajectory is load with mdtraj)
  • buffer (float) – fraction (of membrane thickness) of top and bottom of membrane to exclude from p2p calculations
  • spline (bool) – trace pore centers with a spline
  • npts (int) – number of points making up the spline in each pore
  • progress (bool) – show progress bar while constructing splines
  • bins (bool) – return the bin centers of each spline for plotting purposes
  • spline_name (str) – name of spline. Include absolute path if not in same directory where script was run
Returns:

numpy array containing the x, y coordinates of the center of each pore at each frame

physical.p2p(p_centers, distances)
Parameters:
  • p_centers – the x, y locations of the pore centers in the format return from avg_pore_loc()
  • distances – the number of distinct distances between pores
Returns:

all of the pore to pore distances

physical.limits(pos, pcenters)

Estimate the pore ‘radius’ based on the position of some component and it’s maximum deviation from the pore center :param: pos: the positions of all atoms included in making the estimate :param: pcenters: the x,y positions of the pore centers for each frame :return: an approximate pore radius. Beyond which, we have entered the alkane region

physical.put_in_box(pt, x_box, y_box, m, angle)
Parameters:
  • pt – The point to place back in the box
  • x_box – length of box in x dimension
  • y_box – length of box in y dimension
  • m – slope of box vector
  • angle – angle between x axis and y box vector
Returns:

coordinate shifted into box

physical.trace_pores(pos, box, npoints, npores=4, progress=True, save=True, savename='spline.pl')

Find the line which traces through the center of the pores :param pos: positions of atoms used to define pore location (args.ref) [natoms, 3] :param box: xy box vectors, [2, 2], mdtraj format (t.unitcell_vectors) :param npoints: number of points for spline in each pore :param npores: number of pores in unit cell (assumed that atoms are number sequentially by pore. i.e. pore 1 atom numbers all precede those in pore 2) :param progress: set to True if you want a progress bar to be shown :param save: save spline as pickled object :param savename: path to spline. If absolute path is not provided, will look in current directory

Returns:points which trace the pore center
physical.center_of_mass(pos, mass_atoms)

Calculate center of mass of residues over a trajectory

Parameters:pos – xyz coordinates of atoms

:param mass_atoms : mass of atoms in order they appear in pos

Returns:center of mass of each residue at each frame
physical.residue_center_of_mass(t, res)

Calculate the center of mass versus time of a residue in an MD trajectory

Parameters:
  • t (object) – mdtraj trajectory object
  • res (str) – name of residue to track
Returns:

center of mass of residue versus time

physical.compdensity(coord, pore_centers, box, cut=1.5, nbins=50, spline=False)

Measure the density of a component as a function of the distance from the pore centers.

Parameters:
  • coord (numpy.ndarray) – the coordinates of the component(s) which you want a radial distribution of at each frame
  • pore_centers (numpy.ndarray) – a numpy array of the locations of each pore center at each trajectory frame
  • cut (float) – cutoff distance for distance calculations. Will not count anything further than cut from the pore center
  • nbins (int) – number of bins in r direction
  • spline (bool) – calculate RDF with respect to spline
Returns:

Radial distance from pore center r, and the density of a species, whose positions are defined by

coordinates, as a function the distance from the pore center.

physical.distance_from_pore_center(coord, pore_centers, box, spline=False)

Measure the density of a component as a function of the distance from the pore centers.

Parameters:
  • coord – the coordinates of the component(s) which you want a radial distribution of at each frame
  • pore_centers – a numpy array of the locations of each pore center at each trajectory frame
  • cut – cutoff distance for distance calculations. Will not count anything further than cut from the pore center

:param

Returns:Radial distance of each individual solute/component, defined by coords, as a function of time
physical.radial_distance_spline(spline, com, box)

Calculate radial distance from pore center based on distance from center of mass to closest z point in spline

Parameters:
  • spline (np.ndarray [npts_spline, 3]) – coordinates of spline for a single pore and frame
  • com (np.ndarray [n_com, 3]) – atomic center of mass z-coordinates
  • zbox (float) – z box dimension (nm)
Returns:

array of distances from pore center

physical.minimum_image_distance(dist, box)

Calculate minimum image distances from a vector of distances. This assumes a monoclinic unit cell where the x box vector is fixed along the x-axis, the z-box vector is perpendicular to the xy plane, and the y-box vector makes an angle, theta, with the x-axis.

Parameters:
  • d – a vector of distances (n, 3) where n is number of points
  • box – box vectors meant to enclose d, mdtraj format: (3, 3)
Returns:

physical.partition(com, pore_centers, r, buffer=0, unitcell=None, npores=4, spline=False)

Partition residue center of masses into tail and pore region

Parameters:
  • com (numpy.ndarray (nT, ncom, 3)) – positions of centers of mass of particle whose partition we are calculating
  • pore_centers (numpy.ndarray (nT, npores, 2) or (nT, npores, 3) or (nT, npores, npts, 3) if spline=True where) – positions of pore centers
  • r – pore radius, outside of which atoms will be considered in the tail region
  • buffer – z distance (nm) to cut out from top and bottom of membrane (in cases where there is a water gap)
  • unitcell – unitcell vectors in mdtraj format (t.unitcell_vectors). Only needed if buffer and/or spline is used
  • npores – number of pores
  • spline – calculate partition with respect to pore spline
  • spline_path – directory where spline is located

npts=number of points in spline :type r: float :type buffer: float :type unitcell: numpy.ndarray (nT, 3, 3) :type npores: int :type spline: bool :type spline_path: str

Return part:boolean numpy array with shape (nT, com.shape[1]) where True indicates a center of mass that is

inside the inner region (i.e. < r)

physical.wrap_box(positions, box, tol=1e-06)

Put all atoms in box

Parameters:
  • positions (np.ndarray) – xyz atomic position [n_atoms, 3]
  • box (np.ndarray) – box vectors [3, 3] (as obtained from mdtraj t.unitcell_vectors)
Returns:

positions moved into box