htmd.projections.metric module

class htmd.projections.metric.Metric(simulations, skip=1, metricdata=None)

Bases: object

Class for calculating projections of a simlist.

  • simulations (list) – A list of simulations produced by simlist
  • skip (int) – Frame skipping. Setting i.e. to 3 will keep only every third frame of each simulation.
  • metricdata (MetricData object) – If a MetricData object is passed in the constructor, Metric will try to update it by only adding simulations which don’t exist in it yet.


>>> metr = Metric(sims)  
>>> metr.set(MetricSelfDistance('protein and name CA', metric='contacts'))  
>>> data = metr.project()  
>>> # Or define your own function which accepts as first argument a Molecule object. Further arguments are passed as
>>> # function/argument tuples
>>> def foo(mol, ref):
>>>     from htmd.molecule.util import molRMSD
>>>     mol.wrap('protein')
>>>     mol.align('protein and name CA', refmol=ref)
>>>     return molRMSD(mol, ref, mol.atomselect('protein and name CA'), ref.atomselect('protein and name CA'))
>>> metr = Metric(sims)
>>> metr.set( (foo, (ref,)) )
>>> data2 = metr.project()




Returns the description of each projected dimension.

Parameters:mol (Molecule object) – A Molecule object which will be used to calculate the descriptions of the projected dimensions.
Returns:map – A DataFrame containing the descriptions of each dimension
Return type:DataFrame object

Applies all projections stored in Metric on all simulations.

Returns:data – Returns a MetricData object containing the projected data.
Return type:MetricData object

Sets the projection to be applied to the simulations.

Parameters:projection (function or Projection object or list of objects) – A function or projection or a list of projections/functions which to use on the simulations