biotite.structure.apply_chain_wise

biotite.structure.apply_chain_wise(array, data, function, axis=None)[source]

Apply a function to intervals of data, where each interval corresponds to one chain.

The function takes an atom array (stack) and an data array (ndarray) of the same length. The function iterates through the chain IDs of the atom array (stack) and identifies intervals of the same ID. Then the data is partitioned into the same intervals, and each interval (also an ndarray) is put as parameter into function. Each return value is stored as element in the resulting ndarray, therefore each element corresponds to one chain.

Parameters
arrayAtomArray or AtomArrayStack

The atom array (stack) to determine the chains from.

datandarray

The data, whose intervals are the parameter for function. Must have same length as array.

functionfunction

The function must have either the form f(data) or f(data, axis) in case axis is given. Every function call must return a value with the same shape and data type.

axisint, optional

This value is given to the axis parameter of function.

Returns
processed_datandarray

Chain-wise evaluation of data by function. The size of the first dimension of this array is equal to the amount of chains.