schrodinger.surface module¶
Pythonic wrappings for mmsurf surfaces
- class schrodinger.surface.Style(value)¶
Bases:
enum.IntEnum
Surface representation styles.
- solid = 0¶
- mesh = 1¶
- dot = 2¶
- class schrodinger.surface.ColorFrom(value)¶
Bases:
enum.IntEnum
Values for surface color sources.
- surface = 0¶
- vertex = 1¶
- nearest_asl_atom = 2¶
- volume = 3¶
- entry = 4¶
- class schrodinger.surface.ColorBy(value)¶
Bases:
schrodinger.StrEnum
Values for surface color schemes.
- source_color = 'Color'¶
- partial_charge = 'Atom Partial Charge'¶
- atom_type = 'Atom Type'¶
- atom_typeMM = 'Atom Type (MacroModel)'¶
- chain_name = 'Chain Name'¶
- element = 'Element'¶
- mol_number = 'Molecule Number'¶
- mol_number_carbon = 'Element (Molecule Number Carbons)'¶
- residue_charge = 'Residue Charge'¶
- residue_hydrophobicity = 'Residue Hydrophobicity'¶
- residue_position = 'Residue Position'¶
- residue_type = 'Residue Type'¶
- grid_property = 'Grid Property'¶
- atom_color = 'Atom Color'¶
- cavity_depth = 'Cavity Depth'¶
- class schrodinger.surface.MolSurfType(value)¶
Bases:
enum.IntEnum
Types of molecular surfaces.
- vdw = 0¶
- extended = 1¶
- molecular = 2¶
- class schrodinger.surface.Surface(handle, manage=True)¶
Bases:
object
A Pythonic wrapping for mmsurf surfaces that are not associated with a project entry. (For surfaces that are associated with a project entry, see
ProjectSurface
below.) Surface objects can be created from an existing mmsurf handle via__init__
, can be read from disk viaread
, or new surfaces can be created vianewMolecularSurface
.- class Style(value)¶
Bases:
enum.IntEnum
Surface representation styles.
- solid = 0¶
- mesh = 1¶
- dot = 2¶
- class ColorBy(value)¶
Bases:
schrodinger.StrEnum
Values for surface color schemes.
- source_color = 'Color'¶
- partial_charge = 'Atom Partial Charge'¶
- atom_type = 'Atom Type'¶
- atom_typeMM = 'Atom Type (MacroModel)'¶
- chain_name = 'Chain Name'¶
- element = 'Element'¶
- mol_number = 'Molecule Number'¶
- mol_number_carbon = 'Element (Molecule Number Carbons)'¶
- residue_charge = 'Residue Charge'¶
- residue_hydrophobicity = 'Residue Hydrophobicity'¶
- residue_position = 'Residue Position'¶
- residue_type = 'Residue Type'¶
- grid_property = 'Grid Property'¶
- atom_color = 'Atom Color'¶
- cavity_depth = 'Cavity Depth'¶
- class ColorFrom(value)¶
Bases:
enum.IntEnum
Values for surface color sources.
- surface = 0¶
- vertex = 1¶
- nearest_asl_atom = 2¶
- volume = 3¶
- entry = 4¶
- class Color(color)¶
Bases:
object
Represent a color as either an integer (colormap index), string (color name or hex “RRGGBB” value), or an RGB value (tuple/list of 3 ints, values 0-255).
- Provides the following properties and methods:
Color.index = int(Color) - mmcolor index of the closest color
Color.name = str(Color) - mmcolor name of the closest color
Color.rgb - (tuple of 0-255 ints)
equal = (col1 == col2)
When object is initialized from the RGB value, the Color.index and Color.name attributes are set to the closest color in the mmcolor palette.
- __init__(color)¶
- property hex_string¶
Returns the color as string of hex RGB values (RRGGBB). For example, pure red will be returned as “FF0000”.
- property rgb_float¶
Returns a tuple of (R, G, B) for this color, each ranging from 0.0 to 1.0.
- SURFACE_TYPE_NAME = {MolSurfType.vdw: 'van der Waals', MolSurfType.extended: 'extended radius', MolSurfType.molecular: 'molecular surface'}¶
- __init__(handle, manage=True)¶
- Parameters
handle (int) – An mmsurf handle to an existing surface
manage (bool) – If True, the mmsurf handle will be deleted when this object is garbage collected.
- delete()¶
Immediately delete the mmsurf handle. After this method has been called, any further attempts to interact with this object will result in an MmException.
- classmethod newMolecularSurface(struc, name, asl=None, atoms=None, resolution=0.5, probe_radius=None, vdw_scaling=1.0, mol_surf_type=MolSurfType.molecular)¶
Create a new molecular surface for the specified surface
- Parameters
struc – The structure to create the surface for
name (str) – The name of the surface.
asl (str or NoneType) – If given, the surface will only be created for atoms in the structure that match the provided ASL. Note that only one of
asl
andatoms
may be given. If neither are given, then the surface will be created for all atoms in the structure.atoms (list or NoneType) – An optional list of atom numbers. If given, the surface will only be created for the specified atoms. Note that only one of
asl
andatoms
may be given. If neither are given, then the surface will be created for all atoms in the structure.resolution (float) – The resolution of the surface, generally between 0 and 1. Smaller numbers lead to a more highly detailed surface.
probe_radius (float) – The radius of the rolling sphere used to calculate the surface. Defaults to 1.4 if
mol_surf_type
isMolSurfType.Molecular
orMolSurfType.Extended
. May not be given ifmol_surf_type
isMolSurfType.vdw
.vdw_scaling (float) – If given, all atomic radii will be scaled by the provided value before the surface is calculated.
mol_surf_type (
MolSurfType
) – The type of surface to create.
- Returns
The new surface
- Return type
- classmethod read(filename)¶
Read surface data from a file.
- Parameters
filename (str) – The file to read from.
- Returns
The read surface.
- Return type
- write(filename)¶
Write this surface to a file. Note that existing files will be overwritten.
- Parameters
filename (str) – The file to write to.
- property name¶
The surface name. :type: str
- rename(value)¶
Set the surface name. This method is provided for compatibility with
ProjectSurface
.
- property volume_name¶
The volume name associated with the given surface :type: str
- property isovalue¶
The isovalue for the given surface :type: float
- property surface_type¶
A textual description of the type of surface. :type: str
- property visible¶
Whether the surface is currently visible. This setting will be remembered, but it will not have any effect until the surface is added to a project and loaded into Maestro. :type: bool
- show()¶
Sets the surface to be visible.
- hide()¶
Hides the surface.
- property front_transparency¶
The transparency of the front of the surface (relative to the workspace camera position). Measured on a scale from 0 (fully opaque) to 100 (fully transparent). :type: int
- property back_transparency¶
The transparency of the back of the surface (relative to the workspace camera position). Measured on a scale from 0 (fully opaque) to 100 (fully transparent). :type: int
- setTransparency(val)¶
Set both the front and the back transparency.
- Parameters
val (int) – The value to set the transparency to
- property darken_colors_by_cavity_depth¶
Whether the colors on the surface should be darkened based on the cavity depth. :type: bool
- property color_source¶
The source of the surface colors. Note that coloring()/setColoring() are recommended over directly manipulating
color_source
, as this will ensure thatcolor_source
is set correctly. :type:ColorFrom
- property color_scheme¶
The color scheme used to determine surface colors. This value may be ignored unless
color_source
is set toColorFrom.NearestAslAtom
. Note that coloring()/setColoring() are recommended over directly manipulatingcolor_scheme
, as this will ensure thatcolor_source
is set correctly. :type:ColorBy
- property color¶
The constant surface color. This value may be ignored unless
color_source
is set toColorFrom.Surface
andcolor_scheme
is set toColorBy.SourceColor
. Note that coloring()/setColoring() are recommended over directly manipulatingcolor
, as this will ensure thatcolor_source
andcolor_scheme
are set correctly. :type:Color
- setColoring(coloring)¶
Set the surface coloring. Must be one of:
- coloring()¶
Return the current surface coloring. Is only guaranteed to return a non-None value if the surface coloring was set via
setColoring
. If the surface coloring cannot be determined, will return None.
- property surface_area¶
The reported surface area of the surface :type: float
- property surface_volume¶
Compute and return surface volume of the surface. Note that unlike surface_area, this is not cached, use appropriately.
- Type
float
- property vertex_coords¶
A list of all vertex coordinates :type: list
- property vertex_count¶
- property vertex_normals¶
The normal for each vertex :type: numpy.ndarray
- property patch_count¶
The number of surface patches (i.e. triangles connecting three adjacent vertices). :type: int
- property patch_vertices¶
A
patch_count
x 3 array containing vertex indices for each surface patch. :type: numpy.array
- property nearest_atom_indices¶
A list of the atom indices closest to each vertex coordinate. Atom indices are listed in a corresponding order to vertex_coords. :type: list
- smoothColors(colors, iterations)¶
Given a list of vertex colors, return a list of smoothed colors. Does not modify the surface in any way.
- Parameters
colors (list or numpy.array) – A list or numpy array of the colors to smooth, where colors are represented as either RGB or RGBA values. Note that if this value is a numpy array, the input array will be modified in place.
iterations (int) – The number of smoothing iterations to carry out.
- Returns
The smoothed colors as a numpy array. If
colors
was a numpy array, the return value will be a reference to the (modified) input array.- Return type
numpy.array
- property vertex_colors¶
An array of manually specified per-vertex colors. :type:
numpy.ndarray
- property has_vertex_colors¶
Does this surface contain manually specified per-vertex colors? :type: bool
- curvatures(curvature_type)¶
Return curvature values for all vertices.
- Parameters
curvature_type – mmsurf.CURVATURE_GAUSS, mmsurf.CURVATURE_MIN, mmsurf.CURVATURE_MAX, mmsurf.CURVATURE_MEAN
- Type
curvature_type: mmsurf.CurvatureType enum
- Return type
numpy.array
- schrodinger.surface.create_isosurface_from_grid_data(dimensions, resolution, origin, isovalue, nonzero=None, grid=None, surface_color=None, name=None, comment=None, surface_type=None)¶
Create a new isosurface from 3D grid data
To create a surface attached to a project entry, use:
from schrodinger import surface from schrodinger.project.surface import ProjectSurface pysurf = surface.create_isosurface_from_grid_data(*args, **kwargs) projsurf = ProjectSurface.addSurfaceToProject(pysurf, ptable, row)
Where ptable is a Project instance and row is the desired ProjectRow instance
- Parameters
dimensions (list) – The number of grid points in the X, Y and Z directions
resolution (list) – The gridpoint spacing in the X, Y and Z directions
origin (list) – The X, Y, Z coordinates of the grid origin
isovalue (float) – The value of the isosurface
nonzero (iterable) – Each item of nonzero is an (x, y, z, value) tuple indicating the value of the grid at the given x, y, z coordinate. All other gridpoints are set to zero. Either nonzero or grid must be supplied but not both.
grid (numpy.array) – A 3-dimensional numpy.array the same size as dimensions, the value at each point is the grid at that point. Either nonzero or grid must be supplied but not both.
surface_color (str or
schrodinger.structutils.color.Color
) – The color of the surface. If a string, must be a color name recognized by the Color class.name (str) – The name of the surface - shows in Maestro’s Manage Surfaces dialog under Surface Name
comment (str) – The comment for the surface - shows in Maestro’s Manage surfaces dialog under Comments
surface_type (str) – The type of the surface - shows in Maestro’s Manage Surfaces dialog under Surface Type. Note - this has nothing to do with the molecular surface type (VDW, EXTENDED, MOLECULAR) property and is a free text field.
- Return type
- Returns
The created isosurface