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 moleculekit.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.


mol (Molecule object) – A Molecule object which will be used to calculate the descriptions of the projected dimensions.


map – A DataFrame containing the descriptions of each dimension

Return type:

DataFrame object


Applies all projections stored in Metric on all simulations.


njobs (int) – Number of parallel jobs to spawn for projection of trajectories. Take care that this can use large amounts of memory as multiple trajectories are loaded at once. If None it will use the default from htmd.config.


data – Returns a MetricData object containing the projected data.

Return type:

MetricData object


Sets the projection to be applied to the simulations.


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