aquaduct.geom.master module

part2type_dict = {0: 's', 1: 'c', 2: 's'}

Part number to GenericPathTypeCodes dictionary.

parts = (0, 1, 2)

Parts enumerate.

class CTypeSpathsCollectionWorker(spaths=None, ctype=None, bias_long=5, smooth=None, lock=None)[source]

Bases: object

Worker class for averaging spaths in points of master path.

__init__(spaths=None, ctype=None, bias_long=5, smooth=None, lock=None)[source]

Core method for averaging spaths in to master path.

Averaging is done in chunks.

Parameters:
  • spaths (list) – List of separate paths to average.
  • ctype (InletClusterGenericType) – CType of spaths.
  • bias_long (int) – Bias towards long paths used in lens_norm().
  • smooth (Smooth) – Smoothing method.
coords_types_prob_widths(sp_slices_)[source]

Calculates average coordinates, type and width in given chunk.

Parameter sp_slices_ is tuple of length equal to number of spaths. It contains slices for all spaths respectively. With these slices spaths are cut and only resulting chunks are used for calculations.

Therefore, this method average spaths in one point of master math. This point is defined by slices submitted as sp_lices_ parameter.

Algorithm of averaging (within current chunks of spaths):

  1. Coordinates for all spaths are collected.

  2. Lengths of all spaths are collected (from cached variables) and kept as lists of lengths equal to chunks’ sizes.

    Note

    Lengths of collected lengths of spaths are of the same size as coordinates

  3. New coordinates are calculated as weighted average of collected coordintates with numpy.average(). As weights collected lengths are used.

    Note

    Function numpy.average() is called with flatten coordinates and lengths.

  4. Width of average path is calculated as mean value of flatten coordinates mutual distances.

  5. Type of average paths is calculated as probability (frequency) of scope_name.

Parameters:sp_slices (tuple) – Slices that cut chunks from all paths.
Return type:3 element tuple
Returns:coordinates, type (frequency), and width of averaged spaths in current point
__call__(nr_sp_slices_)[source]

Callable interface.

Parameters:nr_sp_slices (tuple) – Two element tuple: nr and sp_slice
class CTypeSpathsCollection(spaths=None, ctype=None, bias_long=5, pbar=None, threads=1)[source]

Bases: object

Object for grouping separate paths that belong to the same CType. Method get_master_path() allows for calculation of average path.

parts = (0, 1, 2)

Enumeration of spath parts.

__init__(spaths=None, ctype=None, bias_long=5, pbar=None, threads=1)[source]
Parameters:
  • spaths (list) – List of separate paths.
  • ctype (InletClusterGenericType) – CType of spaths.
  • bias_long (int) – Bias towards long paths used in lens_norm().
  • pbar – Progress bar object.
  • threads (int) – Number of available threads.
beat()[source]

Touch progress bar, if any.

update()[source]

Update progres bar by one, if any.

lens()[source]

Returns total lengths of all paths.

If ctype in #:# and not 0 and not None then take length of object part only.

Returns:Total (or object part) lengths of all paths.
Return type:numpy.ndarray
lens_norm()[source]

Returns normalized lengths calculated by lens().

Applied normalization is twofold:

  1. All lengths are divided by maximal length, and
  2. All lengths are subjected to pow() function with p = bias_long.
Returns:Normalized total (or object part) lengths of all paths.
Return type:numpy.ndarray
lens_real()[source]

Returns real lengths of all paths.

Returns:Sizes of all paths.
Return type:list
full_size()[source]

Returns desired size of master path.

Returns:Size of master path.
Return type:int
static simple_types_distribution(types)[source]

Calculates normalized sizes of incoming, object, and outgoing parts of spath using generic types.

It is assumed that spath has object part.

Parameters:types (list) – List of generic types.
Return type:3 element list
Returns:Normalized sizes of incomin, object, and outgoing parts.
types_distribution()[source]
Return type:numpy.matrix
Returns:median values of simple_types_distribution() for all spaths.
types_prob_to_types(types_prob)[source]

Changes types probabilities as returned by CTypeSpathsCollectionWorker.coords_types_prob_widths() to types.

Parameters:types_prob (list) – List of types probabilities.
Return type:list
Returns:List of GenericPathTypeCodes.
get_master_path(smooth=None, resid=(0, 0))[source]

Averages spaths into one master path.

This is done in steps:

  1. Master path is an average of bunch of spaths. Its length is determined by full_size() method.
  2. All spaths are then divided in to chunks according to xzip_xzip() function with N set to lenght of master path. This results in list of length equal to the length of master path. Elements of this lists are slice objects that can be used to slice spaths in appropriate chunks.
  3. Next, for each element of this list CTypeSpathsCollectionWorker.coords_types_prob_widths() method is called. Types probabilities are changed to types wiht types_prob_to_types().
  4. Finally, all data are used to create appropriate MasterPath. If this fails None is returned.
Parameters:
  • smooth (Smooth) – Smoothing method.
  • resid (int) – Residue ID of master path.
Return type:

MasterPath

Returns:

Average path as MasterPath object or None if creation of master path failed.

class FakeSingleResidueSelection(resid, frames, coords)[source]

Bases: aquaduct.traj.sandwich.SingleResidueSelection

__init__(resid, frames, coords)[source]
coords(*args, **kwargs)[source]
coords_smooth(sranges, smooth)[source]