cms_n_common_contacts

mdtools.structure.cms_n_common_contacts(cms)[source]

Get the number of contacts common in all contact matrices.

Parameters:

cms (tuple or list) – List of contact matrices as e.g. generated with mdtools.structure.contact_matrices(). The contact matrices can be given either as NumPy arrays or as SciPy sparse matrices. A mix of NumPy arrays and SciPy sparse matrices is not possible.

Returns:

n_bound_in_all_cms (int) – Number of non-zero elements of the product of all arrays in cms (i.e. the number of non-zero elements that are common in all arrays in cms).

See also

mdtools.structure.contact_matrix()

Construct a boolean contact matrix for two MDAnalysis AtomGroups

mdtools.structure.contact_matrices()

Construct a contact matrix for each frame in a trajectory

mdtools.structure.cms_n_contacts()

Get the number of contacts per contact matrix and the number of contacts common in all contact matrices

Examples

NumPy arrays as input:

>>> cm0 = np.array([[ True,  True, False],
...                 [False,  True,  True]])
>>> cm1 = np.array([[ True, False, False],
...                 [False, False,  True]])
>>> cm2 = np.array([[ True,  True, False],
...                 [False, False,  True]])
>>> mdt.strc.cms_n_common_contacts([cm0,])
4
>>> cms = [cm0, cm1, cm2]
>>> mdt.strc.cms_n_common_contacts(cms)
2

SciPy sparse matrices as input:

>>> from scipy import sparse
>>> cms = [sparse.csr_matrix(cm) for cm in cms]
>>> mdt.strc.cms_n_common_contacts([cms[0],])
4
>>> mdt.strc.cms_n_common_contacts(cms)
2