natms_per_cmp¶
-
mdtools.structure.
natms_per_cmp
(ag, compound, return_array=False, return_cmp_ix=False, check_contiguos=False)[source]¶ Get the number of
Atoms
of each compound in an MDAnalysisAtomGroup
.- Parameters
ag (MDAnalysis.core.groups.AtomGroup) – The MDAnalysis
AtomGroup
for which to get the number ofAtoms
per compound.compound ({‘group’, ‘segments’, ‘residues’, ‘fragments’, ‘atoms’}) – The compounds of ag for which to get the number of
Atoms
. If'atoms'
, the output will simply be1
or an array of ones (depending on the value of return_array). Else, the number ofAtoms
in the entire group or of eachSegment
,Residue
orfragment
in ag is returned. Refer to the MDAnalysis’ user guide for an explanation of these terms. Note that in any case, even if compound is e.g.'residues'
, only theAtoms
belonging to ag are taken into account, even if the compound might comprise additionalAtoms
that are not contained in ag.return_array (bool, optional) – If
True
, natms_per_cmp (the output of this function) will always be an array with a length equal to the number of compounds in ag. IfFalse
, natms_per_cmp will be an integer if all compounds in ag have the same number ofAtoms
. However, if this is not the case, natms_per_cmp will be an array even if return_array isFalse
.return_cmp_ix (bool, optional) – If
True
, additionally return the unique indices of the compounds as assigned by MDAnalysis. If compound is e.g.'residues'
, this isnp.unique(ag.resindices)
.check_contiguos (bool, optional) – If
True
(default), check ifAtoms
belonging to the same compound form a contiguous set in the inputAtomGroup
. This is e.g. important when constructing compound contact matrices fromAtom
contact matrices withmdtools.structure.cmp_contact_matrix()
.
- Returns
natms_per_cmp (int or numpy.ndarray) – Number of
Atoms
of each compound contained in ag. If return_array isFalse
and all compounds in ag have the same number ofAtoms
, a single integer is returned. If return_array isTrue
or if not all compounds in ag have the same number ofAtoms
, an array is returned containing the number ofAtoms
of each single compound in ag.cmp_ix (array_like) – Unique compound indices as assigned by MDAnalysis. Only returned if return_cmp_ix is
True
.
See also
mdtools.structure.cmp_contact_matrix()
Convert an
Atom
contact matrix to a compound contact matrixmdtools.structure.cmp_contact_count_matrix()
Take an
Atom
contact matrix and sum the contacts of allAtoms
belonging to the same compoundmdtools.structure.contact_hists()
Bin the number of contacts between reference and selection compounds into histograms