schrodinger.surface module¶
Pythonic wrappings for mmsurf surfaces
-
class
schrodinger.surface.
Style
¶ Bases:
enum.IntEnum
Surface representation styles.
-
solid
= 0¶
-
mesh
= 1¶
-
dot
= 2¶
-
-
class
schrodinger.surface.
ColorFrom
¶ Bases:
enum.IntEnum
Values for surface color sources.
-
surface
= 0¶
-
vertex
= 1¶
-
nearest_asl_atom
= 2¶
-
volume
= 3¶
-
entry
= 4¶
-
-
class
schrodinger.surface.
StrEnum
¶ Bases:
str
,enum.Enum
An enum class where all values are strings. All enum objects stringify to their value.
-
class
schrodinger.surface.
ColorBy
¶ Bases:
schrodinger.surface.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
¶ 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
ColorBy
¶ Bases:
schrodinger.surface.StrEnum
Values for surface color schemes.
-
atom_color
= 'Atom Color'¶
-
atom_type
= 'Atom Type'¶
-
atom_typeMM
= 'Atom Type (MacroModel)'¶
-
cavity_depth
= 'Cavity Depth'¶
-
chain_name
= 'Chain Name'¶
-
element
= 'Element'¶
-
grid_property
= 'Grid Property'¶
-
mol_number
= 'Molecule Number'¶
-
mol_number_carbon
= 'Element (Molecule Number Carbons)'¶
-
partial_charge
= 'Atom Partial Charge'¶
-
residue_charge
= 'Residue Charge'¶
-
residue_hydrophobicity
= 'Residue Hydrophobicity'¶
-
residue_position
= 'Residue Position'¶
-
residue_type
= 'Residue Type'¶
-
source_color
= 'Color'¶
-
-
class
ColorFrom
¶ Bases:
enum.IntEnum
Values for surface color sources.
-
entry
= 4¶
-
nearest_asl_atom
= 2¶
-
surface
= 0¶
-
vertex
= 1¶
-
volume
= 3¶
-
-
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.
-
hex_string
¶ Returns the color as string of hex RGB values (RRGGBB). For example, pure red will be returned as “FF0000”.
-
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: 0>: 'van der Waals', <MolSurfType.extended: 1>: 'extended radius', <MolSurfType.molecular: 2>: 'molecular surface'}¶
-
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: 2>)¶ 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: Surface
-
write
(filename)¶ Write this surface to a file. Note that existing files will be overwritten.
Parameters: filename (str) – The file to write to.
-
name
¶ The surface name. :type: str
-
rename
(value)¶ Set the surface name. This method is provided for compatibility with
ProjectSurface
.
-
volume_name
¶ The volume name associated with the given surface :type: str
-
isovalue
¶ The isovalue for the given surface :type: float
-
surface_type
¶ A textual description of the type of surface. :type: str
-
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.
-
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
-
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
-
darken_colors_by_cavity_depth
¶ Whether the colors on the surface should be darkened based on the cavity depth. :type: bool
-
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
-
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
-
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.Returns: The current surface coloring Return type: ColorBy
,Color
,numpy.ndarray
, or NoneType
-
surface_area
¶ The reported surface area of the surface :type: float
-
vertex_coords
¶ A list of all vertex coordinates :type: list
-
vertex_count
¶
-
vertex_normals
¶ The normal for each vertex :type: numpy.ndarray
-
patch_count
¶ The number of surface patches (i.e. triangles connecting three adjacent vertices). :type: int
-
patch_vertices
¶ A
patch_count
x 3 array containing vertex indices for each surface patch. :type: numpy.array
-
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
-
vertex_colors
¶ An array of manually specified per-vertex colors. :type:
numpy.ndarray
-
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
-
class
-
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 import project_surface pysurf = surface.create_isosurface_from_grid_data(*args, **kwargs) projsurf = project_surface.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