selText

Classes

class selText.SelText(dataset, selT='all')

This class provides methods to easily access various attributes of a given selection.

That is, selected indices, coordinates, residues, segment names,… can be accessed from the given Dataset class using appropriate methods.

Parameters:
  • dataset – a Dataset class instance containing psf and dcd data
  • selText – a selection string (default ‘all’), can also be 1D array of indices

If no frame is selected, all of them will be returned with coordinates() method.

Warning

When multiple frames are used: '...within...frame 0:50:2', the _indices attribute becomes a list of array, corresponding to the selection for each frame. Also, the frames attributes stores the selected frames, such that the :py:method:`coordinates` can only returns the frames that are both in frames class attribute and in the user-requested frames.

append(indices)

Allows to directly append a list of indices to the selection.

astype(t)

Redefines numpy function for SelText type.

coordinates(frames=None)

Returns trajectory coordinates for selected frames.

If frames argument is None, use default frame from selection text. Else, a integer, a range, a slice, a list or a numpy.ndarray can be used.

The returned array is always 3D. In the case of one frame, the shape is (number of atoms, 1, 3).

For multiple frames, it depends on the kind of selection. If 'within' keyword was used, the selection size might change from frame to frame, then a list of 3D coordinates arrays is returned. Else, for ‘static selection’, a 3D array of shape (number of atoms, number of frames, 3) is returned.

getAtom()

Returns atom corresponding to each selected atoms in psf file.

getCharges()

Returns charges corresponding to each selected atoms in psf file.

getIndices()

Returns indices corresponding to each selected atoms in psf file.

getMasses()

Returns masses corresponding to each selected atom in psf file.

getName()

Returns atom name corresponding to each selected atoms in psf file.

getResName()

Returns residues names corresponding to each selected atoms in psf file.

getResidues()

Returns residues corresponding to each selected atoms in psf file.

getSegName()

Returns residues corresponding to each selected atoms in psf file.

getSubSelection(sel, returnOriId=False)

Performs a sub-selection using given selection within already selected indices. Basically, atoms that are both in initial selection and sel corresponding one are returned.

Parameters:
  • sel – sub-selection to use
  • returnOriId – if True, return also indices in the range of the total number of atoms in simulation
getUniqueAtom()

Returns an array of str with each atom in selection apparing only once.

getUniqueName()

Returns an array of str with each atom name in selection apparing only once.

getUniqueResName()

Returns an array of str with each residue name in selection apparing only once.

getUniqueResidues()

Returns an array of str with each residue number in selection apparing only once.

getUniqueSegName()

Returns an array of str with each segment name in selection apparing only once.

writePDB(fileName=None, frame=0, coor=None)

This provides a way to write a simple .pdb file containing selected atoms.

Parameters:
  • fileName – file name to be used. If None (default), the loaded .psf file name is used.
  • frame – frame to be used
  • coor – if not None, it will override the frame argument and directly use the given coordinates instead.