pyemma.coordinates.data.CustomFeature

class pyemma.coordinates.data.CustomFeature(func=None, *args, **kwargs)

A CustomFeature is the base class for user-defined features. If you want to implement a new fancy feature, derive from this class, calculate the quantity of interest in the map method and return it as an ndarray.

If you have defined a map function that should be classed, you don’t need to derive a class, but you can simply pass a function to the constructor of this class

Parameters:
  • func (function) – will be invoked with given args and kwargs on mapping traj
  • args (list of positional args (optional) passed to func) –
  • kwargs (named arguments (optional) passed to func) –

Examples

We define a feature that transforms all coordinates by \(1 / x^2\):

>>> from pyemma.coordinates import source

Define a function which transforms the coordinates of the trajectory object: >>> my_feature = CustomFeature(lambda x: 1.0 / x.xyz**2) >>> reader = pyemma.coordinates.load(‘traj.xtc’, top=’my_topology.pdb’) # doctest: +SKIP # pass the feature to the featurizer and transform the data >>> reader.featurizer.add_custom_feature(my_feature) # doctest: +SKIP >>> data = reader.get_output() # doctest: +SKIP

__init__(func=None, *args, **kwargs)

Methods

__init__([func])
describe()
map(traj)