htmd.projections.metricdistance module

class htmd.projections.metricdistance.MetricDistance(sel1, sel2, groupsel1=None, groupsel2=None, metric='distances', threshold=8, pbc=True, truncate=None)

Bases: htmd.projections.projection.Projection

Creates a MetricDistance object

Parameters:
  • sel1 (str) – Atom selection string for the first set of atoms. See more here
  • sel2 (str) – Atom selection string for the second set of atoms. If sel1 != sel2, it will calculate inter-set distances. If sel1 == sel2, it will calculate intra-set distances. See more here
  • groupsel1 (['all','residue'], optional) – Group all atoms in sel1 to the single minimum distance. Alternatively can calculate the minimum distance of a residue containing the atoms in sel1.
  • groupsel2 (['all','residue'], optional) – Same as groupsel1 but for sel2
  • metric (['distances','contacts'], optional) – Set to ‘contacts’ to calculate contacts instead of distances
  • threshold (float, optional) – The threshold under which a distance is considered in contact
  • pbc (bool, optional) – Set to false to disable distance calculations using periodic distances
  • truncate (float, optional) – Set all distances larger than truncate to truncate
  • update – Not functional yet
Returns:

proj

Return type:

MetricDistance object

copy()

Produces a deep copy of the object

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

Project molecule.

Parameters:mol (Molecule) – A Molecule object to project.
Returns:data – An array containing the projected data.
Return type:np.ndarray
class htmd.projections.metricdistance.MetricSelfDistance(sel, groupsel=None, metric='distances', threshold=8, pbc=True, truncate=None)

Bases: htmd.projections.metricdistance.MetricDistance

copy()

Produces a deep copy of the object

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

Project molecule.

Parameters:mol (Molecule) – A Molecule object to project.
Returns:data – An array containing the projected data.
Return type:np.ndarray
htmd.projections.metricdistance.contactVecToMatrix(vector, atomIndexes)
htmd.projections.metricdistance.reconstructContactMap(vector, mapping, truecontacts=None, plot=True, figsize=(7, 7), dpi=80, title=None, outfile=None, colors=None)

Plots a given vector as a contact map

Parameters:
  • vector (np.ndarray or list) – A 1D vector of contacts
  • mapping (pd.DataFrame) – A pandas DataFrame which describes the dimensions of the projection
  • truecontacts (np.ndarray or list) – A 1D vector of true contacts
  • plot (bool) – To plot or not to plot
  • figsize (tuple) – The size of the final plot in inches
  • dpi (int) – Dots per inch
  • outfile (str) – Path of file in which to save the plot
Returns:

cm – The input vector converted into a 2D numpy array

Return type:

np.ndarray

Examples

>>> reconstructContactMap(contacts, mapping)
To use it with distances instead of contacts pass ones as the concat vector
>>> reconstructContactMap(np.ones(dists.shape, dtype=bool), mapping, colors=dists)