Selection class

class chemfiles.Selection(selection)

Select atoms in a Frame with a selection language.

The selection language is built by combining basic operations. Each basic operation follows the <selector>[(<variable>)] <operator> <value> structure, where <operator> is a comparison operator in == != < <= > >=. Refer to the full documentation to know the allowed selectors and how to use them.

Create a new Selection from the given selection string.

evaluate(frame)

Evaluate a Selection for a given Frame, and return a list of matching atoms, either as a list of index or a list of tuples of indexes.

property size

Get the size of this Selection.

The size of a selection is the number of atoms we are selecting together. This value is 1 for the ‘atom’ context, 2 for the ‘pair’ and ‘bond’ context, 3 for the ‘three’ and ‘angles’ contextes and 4 for the ‘four’ and ‘dihedral’ contextes.

property string

Get the selection string used to create this Selection.