repeat_box#

biotite.structure.repeat_box(atoms, amount=1)[source]#

Repeat the atoms in a box by duplicating and placing them in adjacent boxes.

The output atom array (stack) contains the original atoms (central box) and duplicates of them in the given amount of adjacent boxes. The coordinates of the duplicate atoms are translated accordingly by the box coordinates.

Parameters:
atomsAtomArray or AtomArrayStack

The atoms to be repeated. If atoms is a AtomArrayStack, the atoms are repeated for each model, according to the box of each model.

amountint, optional

The amount of boxes that are created in each direction of the central box. Hence, the total amount of boxes is \((1 + 2 \cdot \text{amount}) ^ 3\). By default, one box is created in each direction, totalling in 27 boxes.

Returns:
repeatedAtomArray or AtomArrayStack

The repeated atoms. Includes the original atoms (central box) in the beginning of the atom array (stack).

indicesndarray, dtype=int, shape=(n,3)

Indices to the atoms in the original atom array (stack). Equal to numpy.tile(np.arange(atoms.array_length()), (1 + 2 * amount) ** 3).

See also

repeat_box_coord

Examples

>>> array = AtomArray(length=2)
>>> array.coord = np.array([[1,5,3], [-1,2,5]], dtype=float)
>>> array.box = np.array([[10,0,0], [0,10,0], [0,0,10]], dtype=float)
>>> repeated, indices = repeat_box(array)
>>> print(repeated.coord)
[[  1.   5.   3.]
 [ -1.   2.   5.]
 [ -9.  -5.  -7.]
 [-11.  -8.  -5.]
 [ -9.  -5.   3.]
 [-11.  -8.   5.]
 [ -9.  -5.  13.]
 [-11.  -8.  15.]
 [ -9.   5.  -7.]
 [-11.   2.  -5.]
 [ -9.   5.   3.]
 [-11.   2.   5.]
 [ -9.   5.  13.]
 [-11.   2.  15.]
 [ -9.  15.  -7.]
 [-11.  12.  -5.]
 [ -9.  15.   3.]
 [-11.  12.   5.]
 [ -9.  15.  13.]
 [-11.  12.  15.]
 [  1.  -5.  -7.]
 [ -1.  -8.  -5.]
 [  1.  -5.   3.]
 [ -1.  -8.   5.]
 [  1.  -5.  13.]
 [ -1.  -8.  15.]
 [  1.   5.  -7.]
 [ -1.   2.  -5.]
 [  1.   5.  13.]
 [ -1.   2.  15.]
 [  1.  15.  -7.]
 [ -1.  12.  -5.]
 [  1.  15.   3.]
 [ -1.  12.   5.]
 [  1.  15.  13.]
 [ -1.  12.  15.]
 [ 11.  -5.  -7.]
 [  9.  -8.  -5.]
 [ 11.  -5.   3.]
 [  9.  -8.   5.]
 [ 11.  -5.  13.]
 [  9.  -8.  15.]
 [ 11.   5.  -7.]
 [  9.   2.  -5.]
 [ 11.   5.   3.]
 [  9.   2.   5.]
 [ 11.   5.  13.]
 [  9.   2.  15.]
 [ 11.  15.  -7.]
 [  9.  12.  -5.]
 [ 11.  15.   3.]
 [  9.  12.   5.]
 [ 11.  15.  13.]
 [  9.  12.  15.]]
>>> print(indices)
[0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1]