contact_map.ContactCount

class contact_map.ContactCount(counter, object_f, n_x, n_y)[source]

Return object when dealing with contacts (residue or atom).

This contains all the information about the contacts of a given type. This information can be represented several ways. One is as a list of contact pairs, each associated with the fraction of time the contact occurs. Another is as a matrix, where the rows and columns label the pair number, and the value is the fraction of time. This class provides several methods to get different representations of this data for further analysis.

In general, instances of this class shouldn’t be created by a user using __init__; instead, they will be returned by other methods. So users will often need to use this object for analysis.

Parameters
  • counter (collections.Counter) – the counter describing the count of how often the contact occurred; key is a frozenset of a pair of numbers (identifying the atoms/residues); value is the raw count of the number of times it occurred

  • object_f (callable) – method to obtain the object associated with the number used in counter; typically mdtraj.Topology.residue() or mdtraj.Topology.atom().

  • n_x (int) – number of objects in the x direction (used in plotting)

  • n_y (int) – number of objects in the y direction (used in plotting)

__init__(counter, object_f, n_x, n_y)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(counter, object_f, n_x, n_y)

Initialize self.

most_common([obj])

Most common values (ordered) with object as keys.

most_common_idx()

Most common values (ordered) with indices as keys.

plot([cmap, vmin, vmax, with_colorbar])

Plot contact matrix (requires matplotlib)

Attributes

counter

collections.Counter: keys use index number; count is contact occurrences

df

pandas.SparseDataFrame: DataFrame representation of the contact matrix

sparse_matrix

scipy.sparse.dok.dok_matrix: sparse matrix representation of contacts