parmed.amber.mask module

Module for evaluating Amber Mask strings and translating them into lists in which a selected atom is 1 and one that’s not is 0.

class parmed.amber.mask.AmberMask(parm, mask)[source]

Bases: object

What is hopefully a fully-fledged Amber mask parser implemented in Python.

Parameters
parmStructure

The topology structure for which to select atoms

maskstr

The mask string that selects a subset of atoms

Methods

Selected([invert])

Generator that returns the indexes of selected atoms

Selection([prnlev, invert])

Parses the mask and analyzes the result to return an atom selection array

Selected(invert=False)[source]

Generator that returns the indexes of selected atoms

Parameters
invertbool, optional

If True, all atoms not selected by the mask will be returned

Returns
generator of int

Each iteration will yield the index of the next atom that has been selected by the mask. Atom indices are 0-based

Selection(prnlev=0, invert=False)[source]

Parses the mask and analyzes the result to return an atom selection array

Parameters
prnlevint, optional

Print debug information on the processing of the Amber mask string. This is mainly useful if you are modifying the mask parser. Default value is 0 (no printout), values between 1 and 8 control the level of output (larger values produce more output). Default 0

invertbool, optional

If True, the returned array will invert the selection of the mask (i.e., selected atoms will not be selected and vice-versa)

Returns
masklist of int

A list with length equal to the number of atoms in the assigned Structure instance. Selected atoms will have a value of 1 placed in the corresponding slot in the return list while atoms not selected will be assigned 0.