htmd.projections.metric module

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

Bases: object

Class for calculating projections of a simlist.

Parameters
  • 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.

Examples

>>> 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()

Methods

Attributes

getMapping(mol)

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

project(njobs=None)

Applies all projections stored in Metric on all simulations.

Parameters

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.

Returns

data – Returns a MetricData object containing the projected data.

Return type

MetricData object

set(projection)

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