moleculekit.atomselect.atomselect module#
- moleculekit.atomselect.atomselect.atomselect(mol, selection, bonds, _debug=False, _analysis=None, _return_ast=False)#
Select atoms of a molecule using an atom selection language.
Parses the selection string into an abstract syntax tree and evaluates it against the molecule’s properties (name, resname, resid, chain, element, coordinates, etc.) and connectivity-derived properties (fragments, waters, ions, lipids, protein/nucleic backbone, …).
- Parameters:
mol (
Molecule) – The molecule on which to perform the atom selection.selection (
str) – The atom selection string, e.g."protein and name CA"or"within 5 of resname MOL".bonds (
ndarray) – The bond connectivity of the molecule, used to compute properties such as fragments and the protein/nucleic classification.
- Returns:
mask – A boolean mask of length
mol.numAtomswhich is True for the selected atoms. If the molecule has no atoms an empty boolean array is returned.- Return type:
Examples
>>> mask = atomselect(mol, "protein and name CA", mol.bonds)
- moleculekit.atomselect.atomselect.get_molprop(mol, molprop, analysis)#
- moleculekit.atomselect.atomselect.traverse_ast(mol, analysis, node)#