moleculekit.representations module#

class moleculekit.representations.Representations(mol: Molecule)#

Bases: object

Class that stores representations for Molecule.

Parameters:

mol (Molecule) – The Molecule object for which the representations are stored.

Examples

>>> from moleculekit.molecule import Molecule
>>> mol = tryp.copy()
>>> mol.reps.add('protein', 'NewCartoon')
>>> print(mol.reps)                     
rep 0: sel='protein', style='NewCartoon', color='Name'
>>> mol.view() 
>>> mol.reps.remove() 
add(sel: str | ndarray | None = None, style: str | None = None, color: str | int | None = None, frames: list | None = None, opacity: float | None = None)#

Adds a new representation for Molecule.

Parameters:
  • sel (str or np.ndarray) – Atom selection (string, boolean mask, or integer index array) for the representation. See more here

  • style (str) – Representation style. See more here.

  • color (str or int) – Coloring mode (str) or ColorID (int). See more here.

  • frames (list) – List of frames to visualize with this representation. If None it will visualize the current frame only.

  • opacity (float) – Opacity of the representation. 0 is fully transparent and 1 is fully opaque.

append(reps: Representations)#

Append the representations of another Representations object.

Parameters:

reps (Representations object) – The Representations object whose representations will be appended to this one.

Raises:

RuntimeError – If reps is not a Representations object.

list()#

Print all currently stored representations.

Prints, for each representation, its index, atom selection, style and color. Equivalent to printing the Representations object directly.

remove(index: int | None = None)#

Removed one or all representations.

Parameters:

index (int) – The index of the representation to delete. If none is given it deletes all.