Analysis scripts

A set of small utilities, general for the library

polymerutils.Cload(filename, center=False)[source]

fast polymer loader using weave.inline

..warning:: About to be deprecated

polymerutils.load(filename, h5dictKey=None)[source]

Universal load function for any type of data file


Calculates rotation matrix based on three rotation angles, data2, rotate=True, N=999999, fullReturn=False)[source]

An utility to calculate mean square displacement between two polymer conformations Parameters ———-

data1, dat2 : Mx3 array
First conformation
rotate : bool (true by default)
Compensate for rotation and displacement between conformation
N : int (optional)
If conformations are large, use only M monomers for comparison. If N > M (num. of particles), use all monomers (default)
fullReturn : bool, default=False
Return information about all displacements

MSD : float

Diplacement between conformation

if fullReturn==False: dictionary of results :

See the end of the code for reference

polymerutils.create_spiral(r1, r2, N)[source]

Creates a “propagating spiral”, often used as a starting conformation. Run it with r1=10, r2 = 13, N=5000, and see what it does.

polymerutils.grow_rw(step, size, method='line')[source]

This does not grow a random walk, but the name stuck.

What it does - it grows a polymer in the middle of the sizeXsizeXsize box. It can start with a small ring in the middle (method=”standart”), or it can start with a line (“method=line”). If method=”linear”, then it grows a linearly organized chain from 0 to size.

step has to be less than size^3

polymerutils.createSpiralRing(N, twist, r=0, offsetPerParticle=3.141592653589793, offset=0)[source]

Creates a ring of length N. Then creates a spiral

polymerutils.smooth_conformation(conformation, n_avg)[source]

Smooth a conformation using moving average.

polymerutils.distance_matrix(d1, d2=None)[source]

A brute-force to find a matrix of distances between i-th and j-th particles.


d1 : numpy.array

If the only array supplied, find the pairwise distances.

d2 : numpy.array

If supplied, find distances from every point in d1 to every point in d2.


A brute-force method to find average end-to-end distance v.s. separation.

polymerutils.getCloudGeometry(d, frac=0.05, numSegments=1, widthPercentile=50, delta=0)[source]

Trace the centerline of an extended cloud of points and determine its length and width.

The function switches to the principal axes of the cloud (e1,e2,e3) and applies LOWESS to define the centerline as (x2,x3)=f(x1). The length is then determined as the total length of the centerline. The width is determined as the median shortest distance from the points of clouds to the centerline. On top of that, the cloud can be chopped into numSegments in the order of data entries in d. The centerline is then determined independently for each segment.


d : np.array, 3xN

an array of coordinates

frac : float

The fraction of all points used to determine the local position and slope of the centerline in LOWESS.

numSegments : int

The number of segments to split d into. The centerline in fit independently for each data segment.

widthPercentile : float

The width is determined at widthPercentile of shortest distances from the points to the centerline. The default value is 50, i.e. the width is the median distance to the centerline.

delta : float

The parameter of LOWESS. According to the documentation: “delta can be used to save computations. For each x_i, regressions are skipped for points closer than delta. The next regression is fit for the farthest point within delta of x_i and all points in between are estimated by linearly interpolating between the two regression fits.”


a weave.inline wrapper for polymer simplification code Calculates a simplified topologically equivalent polymer ring

Previous topic

Knot complexity scripts

Next topic

Polymer scalings

This Page