polychrom.starting_conformations module

polychrom.starting_conformations.create_constrained_random_walk(N: int, constraint_f: Callable[[Tuple[float, float, float]], bool], starting_point=(0, 0, 0), step_size=1.0, polar_fixed=None) bool[source]

Creates a constrained freely joined chain of length N with step step_size. Each step of a random walk is tested with the constraint function and is rejected if the tried step lies outside of the constraint. This function is much less efficient than create_random_walk().

Parameters
  • N (int) – The number of steps

  • constraint_f (callable) – The constraint function. Must accept a tuple of 3 floats with the tentative position of a particle and return True if the new position is accepted and False is it is forbidden.

  • starting_point (a tuple of (float, float, float)) – The starting point of a random walk.

  • step_size (float) – The size of a step of the random walk.

  • polar_fixed (float, optional) – If specified, the random_walk is forced to fix the polar angle at polar_fixed. The implementation includes backtracking if no steps were possible, but if seriously overconstrained, the algorithm can get stuck in an infinite loop.

polychrom.starting_conformations.create_random_walk(step_size, N)[source]

Creates a freely joined chain of length N with step step_size

polychrom.starting_conformations.create_spiral(r1, r2, N)[source]

Creates a “propagating spiral”, often used as an easy mitotic-like starting conformation.

Run it with r1=10, r2 = 13, N=5000, and see what it does.

polychrom.starting_conformations.grow_cubic(N, boxSize, method='standard')[source]

This function grows a ring or linear polymer on a cubic lattice in the cubic box of size boxSize.

If method==”standard, grows a ring starting with a 4-monomer ring in the middle

if method ==”extended”, it grows a ring starting with a long ring going from z=0, center of XY face, to z=boxSize center of XY face, and back.

If method=”linear”, then it grows a linearly organized chain from 0 to size. The chain may stick out of the box by one, (N%2 != boxSize%2), or be flush with the box otherwise

Parameters
  • N (chain length. Must be even for rings.) –

  • boxSize (size of a box where polymer is generated.) –

  • method ("standard", "linear" or "extended") –