cm_fill_missing_cmp_ix¶
-
mdtools.structure.
cm_fill_missing_cmp_ix
(cm, refix=None, selix=None)[source]¶ Insert elements in a contact matrix at missing intermediate compound indices.
The inserted matrix elements will evaluate to
False
.- Parameters
cm (array_like) – (Boolean) contact matrix of shape
(m, n)
as e.g. generated bymdtools.structure.contact_matrix()
, wherem
is the number of referenceAtoms
or compounds andn
is the number of selectionAtoms
or compounds.refix, selix (array_like of ints) – Array of compound indices corresponding to the reference/selection compounds contained in cm. If the indices contain gaps, these gaps will be filled by this function. Indices must not be negative, dublicate indices will be removed.
- Returns
cm – The input contact matrix with added rows for missing reference compound indices in refix and added columns for missing selection compound indices in selix. If both refix and selix do not have any gaps (i.e. the indices are contiguous), the input matrix is returned instead as
numpy.ndarray
.- Return type
See also
mdtools.structure.contact_matrix()
Construct a boolean contact matrix for two MDAnalysis
AtomGroups
mdtools.structure.cmp_contact_matrix()
Convert an
Atom
contact matrix to a compound contact matrix
Examples
>>> cm = np.array([[ True, True, False], ... [False, True, True]]) >>> mdt.strc.cm_fill_missing_cmp_ix(cm, refix=[2, 4]) # 3 missing array([[ True, True, False], [False, False, False], [False, True, True]]) >>> mdt.strc.cm_fill_missing_cmp_ix(cm, selix=[0, 1, 4]) # 2, 3 missing array([[ True, True, False, False, False], [False, True, False, False, True]])
If both refix and selix do not have any gaps, the input contact matrix is returned as
numpy.ndarray
. If it already was anumpy.ndarray
before, no copy is made.>>> result = mdt.strc.cm_fill_missing_cmp_ix(cm, ... refix=[2, 3], ... selix=[1, 2, 3]) >>> result is cm True