moldesign.viewer package¶
-
class
moldesign.viewer.
ChemicalGraphViewer
(mol, carbon_labels=True, names=None, display=False, _forcebig=False, **kwargs)[source]¶ Bases:
nbmolviz.widget2d.MolViz2DBaseWidget
,moldesign.viewer.common.ColorMixin
Create a JSON-format graph representing the chemical structure and draw it using the NBMolViz 2D widget.
Parameters: - mol (moldesign.molecules.AtomContainer) – A collection of atoms (eg a list of atoms, a residue, a molecule. etc)
- carbon_labels (bool) – If True, draw atom names for carbons
- names (List[str]) – (optional) a list of strings to label the atoms in the drawing
(default:
[atom.name for atom in mol.atoms]
) - display (bool) – immediately display this drawing
-
MAXATOMS
= 200¶
-
class
moldesign.viewer.
DistanceGraphViewer
(atoms, distance_sensitivity=(<Quantity(3.0, 'ang')>, <Quantity(7.0, 'ang')>), bond_edge_weight=1.0, minimum_edge_weight=0.2, nonbond_weight_factor=0.66, angstrom_to_px=22.0, charge=-300, **kwargs)[source]¶ Bases:
moldesign.viewer.viewer2d.ChemicalGraphViewer
Create a 2D graph that includes edges with 3D information. This gives a 2D chemical that shows contacts from 3D space.
Parameters: - mol (moldesign.molecules.AtomContainer) – A collection of atoms (eg a list of atoms, a residue, a molecule. etc)
- distance_sensitivity (Tuple[u.Scalar[length]]) – a tuple containing the minimum and
maximum 3D distances to create edges for (default:
(3.0*u.ang, 7.0*u.ang)
) - bond_edge_weight (float) – edge weight for covalent bonds
- nonbond_weight_factor (float) – scale non-covalent edge weights by this factor
- angstrom_to_px (int) – number of pixels per angstrom
- charge (int) – the force-directed layout repulsive “charge”
-
class
moldesign.viewer.
GeometryViewer
(mol=None, style=None, display=False, render=True, **kwargs)[source]¶ Bases:
nbmolviz.drivers3d.MolViz_3DMol
,moldesign.viewer.common.ColorMixin
Viewer for static and multiple-frame geometries
Variables: mol – Buckyball molecule -
DEFAULT_COLOR_MAP
(cats, mplmap='auto')¶
-
DEFAULT_HEIGHT
= 400¶
-
DEFAULT_WIDTH
= 625¶
-
DEF_PADDING
= <Quantity(2.25, 'ang')>¶
-
DISTANCE_UNITS
= <Unit('ang')>¶
-
HIGHLIGHT_COLOR
= '#1FF3FE'¶
-
calc_orb_grid
(orbname, npts, framenum)[source]¶ Calculate orbitals on a grid
Parameters: Returns: orbital values on a grid
Return type: moldesign.viewer.VolumetricGrid
-
draw_atom_vectors
(vecs, rescale_to=1.75, scale_factor=None, opacity=0.85, radius=0.11, render=True, **kwargs)[source]¶ For displaying atom-centered vector data (e.g., momenta, forces) :param rescale_to: rescale to this length (in angstroms) (not used if scale_factor is passed) :param scale_factor: Scaling factor for arrows: dimensions of [vecs dimensions] / [length] :param render: render immediately :param kwargs: keyword arguments for self.draw_arrow
-
handle_selection_event
(selection)[source]¶ Deals with an external selection event :param selection:todo :return:
-
highlight_atoms
(atoms=None, render=True)[source]¶ Parameters: - atoms (list[Atoms]) – list of atoms to highlight. If None, remove all highlights
- render (bool) – render this change immediately
-
orbital_is_selected
¶
-
set_colors
(*args, **kwargs)[source]¶ Parameters: colormap (Mapping[str,List[Atoms]]) – mapping of colors to atoms
-
wfn
¶
-
Submodules¶
moldesign.viewer.bondclicker module¶
-
class
moldesign.viewer.bondclicker.
BondClicker
(mol, **kwargs)[source]¶ Bases:
moldesign.viewer.viewer3d.GeometryViewer
Allow the user to highlight bonds - this is a hack around 3dmol.js to allow clickable bonds.
-
ATOMRADIUS
= 0.35¶
-
BONDCOLOR
= '#C8C8C8'¶
-
DOUBLEOFFSET
= 0.16¶
-
DOUBLERADIUS
= 0.13¶
-
SINGLERADIUS
= 0.18¶
-
TRIPLEOFFSET
= 0.14¶
-
TRIPLERADIUS
= 0.12¶
-
moldesign.viewer.common module¶
-
class
moldesign.viewer.common.
ColorMixin
[source]¶ Bases:
object
-
color_by
(atom_callback, atoms=None, mplmap='auto', render=True, force_cmap=False)[source]¶ - Color atoms according to either:
- an atomic attribute (e.g., ‘chain’, ‘residue’, ‘mass’)
- a callback function that accepts an atom and returns a color or a category
Parameters: - atom_callback (callable OR str) – callable f(atom) returns color OR
category OR an atom attribute (e.g.,
atnum, mass, residue.type
) - atoms (moldesign.molecules.AtomContainer) – atoms to color (default: self.atoms)
- mplmap (str) – name of the matplotlib colormap to use if colors aren’t explicitly specified)
- force_cmap (bool) – force the use of a colormap
- render (bool) – draw these changes immediately
Notes
If you’d like to explicitly specify colors, the callback can return color specifications as an HTML string (
'#1234AB'
), a hexadecimal integer (0x12345AB
), or a CSS3 color keyword ('green'
,'purple'
, etc., see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)If the callback returns an integer, it may be interpreted as a color spec (since RGB colors are just hexadecimal integers). Use
force_cmap=True
to force the creation of a colormap.Returns: mapping of categories to colors Return type: dict
-
moldesign.viewer.viewer2d module¶
-
class
moldesign.viewer.viewer2d.
ChemicalGraphViewer
(mol, carbon_labels=True, names=None, display=False, _forcebig=False, **kwargs)[source]¶ Bases:
nbmolviz.widget2d.MolViz2DBaseWidget
,moldesign.viewer.common.ColorMixin
Create a JSON-format graph representing the chemical structure and draw it using the NBMolViz 2D widget.
Parameters: - mol (moldesign.molecules.AtomContainer) – A collection of atoms (eg a list of atoms, a residue, a molecule. etc)
- carbon_labels (bool) – If True, draw atom names for carbons
- names (List[str]) – (optional) a list of strings to label the atoms in the drawing
(default:
[atom.name for atom in mol.atoms]
) - display (bool) – immediately display this drawing
-
MAXATOMS
= 200¶
-
class
moldesign.viewer.viewer2d.
DistanceGraphViewer
(atoms, distance_sensitivity=(<Quantity(3.0, 'ang')>, <Quantity(7.0, 'ang')>), bond_edge_weight=1.0, minimum_edge_weight=0.2, nonbond_weight_factor=0.66, angstrom_to_px=22.0, charge=-300, **kwargs)[source]¶ Bases:
moldesign.viewer.viewer2d.ChemicalGraphViewer
Create a 2D graph that includes edges with 3D information. This gives a 2D chemical that shows contacts from 3D space.
Parameters: - mol (moldesign.molecules.AtomContainer) – A collection of atoms (eg a list of atoms, a residue, a molecule. etc)
- distance_sensitivity (Tuple[u.Scalar[length]]) – a tuple containing the minimum and
maximum 3D distances to create edges for (default:
(3.0*u.ang, 7.0*u.ang)
) - bond_edge_weight (float) – edge weight for covalent bonds
- nonbond_weight_factor (float) – scale non-covalent edge weights by this factor
- angstrom_to_px (int) – number of pixels per angstrom
- charge (int) – the force-directed layout repulsive “charge”
moldesign.viewer.viewer3d module¶
-
class
moldesign.viewer.viewer3d.
GeometryViewer
(mol=None, style=None, display=False, render=True, **kwargs)[source]¶ Bases:
nbmolviz.drivers3d.MolViz_3DMol
,moldesign.viewer.common.ColorMixin
Viewer for static and multiple-frame geometries
Variables: mol – Buckyball molecule -
DEFAULT_COLOR_MAP
(cats, mplmap='auto')¶
-
DEFAULT_HEIGHT
= 400¶
-
DEFAULT_WIDTH
= 625¶
-
DEF_PADDING
= <Quantity(2.25, 'ang')>¶
-
DISTANCE_UNITS
= <Unit('ang')>¶
-
HIGHLIGHT_COLOR
= '#1FF3FE'¶
-
calc_orb_grid
(orbname, npts, framenum)[source]¶ Calculate orbitals on a grid
Parameters: Returns: orbital values on a grid
Return type: moldesign.viewer.VolumetricGrid
-
draw_atom_vectors
(vecs, rescale_to=1.75, scale_factor=None, opacity=0.85, radius=0.11, render=True, **kwargs)[source]¶ For displaying atom-centered vector data (e.g., momenta, forces) :param rescale_to: rescale to this length (in angstroms) (not used if scale_factor is passed) :param scale_factor: Scaling factor for arrows: dimensions of [vecs dimensions] / [length] :param render: render immediately :param kwargs: keyword arguments for self.draw_arrow
-
handle_selection_event
(selection)[source]¶ Deals with an external selection event :param selection:todo :return:
-
highlight_atoms
(atoms=None, render=True)[source]¶ Parameters: - atoms (list[Atoms]) – list of atoms to highlight. If None, remove all highlights
- render (bool) – render this change immediately
-
orbital_is_selected
¶
-
set_colors
(*args, **kwargs)[source]¶ Parameters: colormap (Mapping[str,List[Atoms]]) – mapping of colors to atoms
-
wfn
¶
-