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(), wheremis the number of referenceAtomsor compounds andnis the number of selectionAtomsor compounds.refix, selix (
array_likeofints) – 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, duplicate indices will be removed.
- Returns:
cm (
numpy.ndarray) – 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 asnumpy.ndarray.
See also
mdtools.structure.contact_matrix()Construct a boolean contact matrix for two MDAnalysis
AtomGroupsmdtools.structure.cmp_contact_matrix()Convert an
Atomcontact matrix to a compound contact matrix
Examples
>>> cm = np.array([[ True, True, False], ... [False, True, True]]) >>> # 3 missing >>> mdt.strc.cm_fill_missing_cmp_ix(cm, refix=[2, 4]) array([[ True, True, False], [False, False, False], [False, True, True]]) >>> # 2, 3 missing >>> mdt.strc.cm_fill_missing_cmp_ix(cm, selix=[0, 1, 4]) 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.ndarraybefore, no copy is made.>>> result = mdt.strc.cm_fill_missing_cmp_ix( ... cm, refix=[2, 3], selix=[1, 2, 3] ... ) >>> result is cm True