schrodinger.project_surface module¶
Pythonic wrappings for mmsurf surfaces retrieved from a project
-
class
schrodinger.project_surface.
ProjectSurface
(proj_handle, eid, name, proj_row)¶ Bases:
schrodinger.surface.Surface
A Pythonic wrapping for mmsurf surfaces retrieved from a project. ProjectSurface objects are typically accessed via the
schrodinger.project.ProjectRow.surface
SurfaceDict
object or created viaschrodinger.project.ProjectRow.newMolecularSurface
.-
__init__
(proj_handle, eid, name, proj_row)¶ Parameters: - proj_handle (int) – The project handle
- eid (str) – The entry ID of the entry containing the surface
- name (str) – The name of the surface
Note: This method does not confirm that the specified surface exists, as this check is done in
SurfaceDict.__getitem__
. Attempting to get or set values on a non-existent surface will lead to a RuntimeError.
-
__del__
()¶ When this object is garbage collected, terminate the mmlib libraries and delete the mmsurf handle if it’s managed by this object.
-
delete
()¶ Delete this surface. After the surface is deleted, any further attempt to interact with this object will result in a RuntimeError.
-
name
¶ The name of the surface. Note that all surfaces for a given project entry have unique names. :type: str
-
rename
(new_name, overwrite=True)¶ Rename this surface
Parameters: - new_name (str) – The new surface name
- overwrite (bool) – What to do if the new name is the same as an existing surface for this project row. If True, the existing surface will be overwritten. In False, a ValueError will be raised.
-
classmethod
newMolecularSurface
(proj, row, name, asl=None, atoms=None, resolution=0.5, probe_radius=None, vdw_scaling=1.0, mol_surf_type=<MolSurfType.molecular: 2>, overwrite=True)¶ Create a new molecular surface for the specified project row
Parameters: - proj (
schrodinger.project.Project
) – The project that this surface will be part of - row (
schrodinger.project.ProjectRow
) – The project row that this surface will belong to. This is the structure that the surface will be created around. - name (str) – The name of the surface. Note that project rows require
all surfaces to be named uniquely. See
overwrite
. - 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. - overwrite (bool) – What to do if the new surface has the same name as an existing surface for this project row. If True, the existing surface will be overwritten. In False, a ValueError will be raised.
Returns: The new surface
Return type: - proj (
-
classmethod
addSurfaceToProject
(surf, proj, row, overwrite=True, copy=False)¶ Add an existing
Surface
object to a project. Note that, by default, this method will invalidate the inputSurface
object, as the mmsurf handle will be managed by the project.Parameters: - surf (
Surface
) – The surface to add. - proj (
schrodinger.project.Project
) – The project to add the surface to. - row (
schrodinger.project.ProjectRow
) – The project row to add the surface to. - overwrite (bool) – What to do if the new surface has the same name as an existing surface for this project row. If True, the existing surface will be overwritten. In False, a ValueError will be raised.
- copy (bool) – If True, a copy of the surface will be added to the project and the input surface will not be invalidated.
- surf (
-
classmethod
read
(filename)¶ Read surface data from a file.
Parameters: filename (str) – The file to read from. Returns: The read surface. Return type: Surface
-
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.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.structutils.color', '__doc__': '\n Represent a color as either an integer (colormap index), string\n (color name or hex "RRGGBB" value), or an RGB value\n (tuple/list of 3 ints, values 0-255).\n\n Provides the following properties and methods:\n - Color.index = int(Color) - mmcolor index of the closest color\n - Color.name = str(Color) - mmcolor name of the closest color\n - Color.rgb - (tuple of 0-255 ints)\n - equal = (col1 == col2)\n\n When object is initialized from the RGB value, the Color.index and\n Color.name attributes are set to the closest color in the mmcolor palette.\n\n ', '__init__': <function Color.__init__>, '__str__': <function Color.__str__>, '__repr__': <function Color.__repr__>, '__int__': <function Color.__int__>, '__eq__': <function Color.__eq__>, '__ne__': <function Color.__ne__>, 'rgb_float': <property object>, 'hex_string': <property object>, '__dict__': <attribute '__dict__' of 'Color' objects>, '__weakref__': <attribute '__weakref__' of 'Color' objects>, '__hash__': None})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
(other)¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
= None¶
-
__init__
(color)¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__int__
()¶
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.structutils.color'¶
-
__ne__
(other)¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
()¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
()¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
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.
-
class
ColorBy
¶ Bases:
schrodinger.surface.StrEnum
Values for surface color schemes.
-
__class__
¶ alias of
enum.EnumMeta
-
__members__
= mappingproxy(OrderedDict([('source_color', <ColorBy.source_color: 'Color'>), ('partial_charge', <ColorBy.partial_charge: 'Atom Partial Charge'>), ('atom_type', <ColorBy.atom_type: 'Atom Type'>), ('atom_typeMM', <ColorBy.atom_typeMM: 'Atom Type (MacroModel)'>), ('chain_name', <ColorBy.chain_name: 'Chain Name'>), ('element', <ColorBy.element: 'Element'>), ('mol_number', <ColorBy.mol_number: 'Molecule Number'>), ('mol_number_carbon', <ColorBy.mol_number_carbon: 'Element (Molecule Number Carbons)'>), ('residue_charge', <ColorBy.residue_charge: 'Residue Charge'>), ('residue_hydrophobicity', <ColorBy.residue_hydrophobicity: 'Residue Hydrophobicity'>), ('residue_position', <ColorBy.residue_position: 'Residue Position'>), ('residue_type', <ColorBy.residue_type: 'Residue Type'>), ('grid_property', <ColorBy.grid_property: 'Grid Property'>), ('atom_color', <ColorBy.atom_color: 'Atom Color'>), ('cavity_depth', <ColorBy.cavity_depth: 'Cavity Depth'>)]))¶
-
__module__
= 'schrodinger.surface'¶
-
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.
-
__class__
¶ alias of
enum.EnumMeta
-
__members__
= mappingproxy(OrderedDict([('surface', <ColorFrom.surface: 0>), ('vertex', <ColorFrom.vertex: 1>), ('nearest_asl_atom', <ColorFrom.nearest_asl_atom: 2>), ('volume', <ColorFrom.volume: 3>), ('entry', <ColorFrom.entry: 4>)]))¶
-
__module__
= 'schrodinger.surface'¶
-
entry
= 4¶
-
nearest_asl_atom
= 2¶
-
surface
= 0¶
-
vertex
= 1¶
-
volume
= 3¶
-
-
SURFACE_TYPE_NAME
= {<MolSurfType.vdw: 0>: 'van der Waals', <MolSurfType.extended: 1>: 'extended radius', <MolSurfType.molecular: 2>: 'molecular surface'}¶
-
class
Style
¶ Bases:
enum.IntEnum
Surface representation styles.
-
__class__
¶ alias of
enum.EnumMeta
-
__members__
= mappingproxy(OrderedDict([('solid', <Style.solid: 0>), ('mesh', <Style.mesh: 1>), ('dot', <Style.dot: 2>)]))¶
-
__module__
= 'schrodinger.surface'¶
-
dot
= 2¶
-
mesh
= 1¶
-
solid
= 0¶
-
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.project_surface', '__doc__': '\n A Pythonic wrapping for mmsurf surfaces retrieved from a project.\n ProjectSurface objects are typically accessed via the\n `schrodinger.project.ProjectRow.surface` `SurfaceDict` object or created\n via `schrodinger.project.ProjectRow.newMolecularSurface`.\n ', '__init__': <function ProjectSurface.__init__>, '__del__': <function ProjectSurface.__del__>, '_handle': <property object>, '_checkHandle': <function ProjectSurface._checkHandle>, 'delete': <function ProjectSurface.delete>, 'name': <property object>, 'rename': <function ProjectSurface.rename>, '_updateMaestro': <function ProjectSurface._updateMaestro>, 'newMolecularSurface': <classmethod object>, '_addHandleToProject': <classmethod object>, 'addSurfaceToProject': <classmethod object>, '_checkName': <staticmethod object>, 'read': <classmethod object>})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.project_surface'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
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
-
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
-
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_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
-
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
-
copy
()¶ Create a copy of this surface. Note that this method will always return a
Surface
object, even when aProjectSurface
object is copied.Returns: The copied surface Return type: Surface
-
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
-
darken_colors_by_cavity_depth
¶ Whether the colors on the surface should be darkened based on the cavity depth. :type: bool
-
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
-
has_vertex_colors
¶ Does this surface contain manually specified per-vertex colors? :type: bool
-
hide
()¶ Hides the surface.
-
isovalue
¶ The isovalue for the given surface :type: float
-
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
-
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
-
setColoring
(coloring)¶ Set the surface coloring. Must be one of:
-
setTransparency
(val)¶ Set both the front and the back transparency.
Parameters: val (int) – The value to set the transparency to
-
show
()¶ Sets the surface to be visible.
-
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
-
surface_area
¶ The reported surface area of the surface :type: float
-
surface_type
¶ A textual description of the type of surface. :type: str
-
vertex_colors
¶ An array of manually specified per-vertex colors. :type:
numpy.ndarray
-
vertex_coords
¶ A list of all vertex coordinates :type: list
-
vertex_count
¶
-
vertex_normals
¶ The normal for each vertex :type: numpy.ndarray
-
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
-
volume_name
¶ The volume name associated with the given surface :type: str
-
write
(filename)¶ Write this surface to a file. Note that existing files will be overwritten.
Parameters: filename (str) – The file to write to.
-
-
class
schrodinger.project_surface.
SurfaceDict
(proj, row)¶ Bases:
collections.abc.MutableMapping
A dictionary of {surface name:
ProjectSurface
object} for the specified project row. Note that surfaces may not be created by assignment to a dictionary value. Useadd
, {addFromFile}, orschrodinger.project.ProjectRow.newMolecularSurface
instead.SurfaceDict
objects are typically accessed viaschrodinger.project.ProjectRow.surface
.-
__init__
(proj, row)¶ Parameters: - proj (
schrodinger.project.Project
) – The project - row (L{schrodinger.project.ProjectRow) – The project row
- proj (
-
__len__
()¶
-
__getitem__
(name)¶
-
__setitem__
(key, value)¶
-
__delitem__
(name)¶
-
__iter__
()¶
-
add
(surf, overwrite=True, copy=False)¶ Add an existing
Surface
object to the project row. Note that if copy is False (the default), this method will invalidate the inputSurface
object, as the mmsurf handle will be managed by the project.Parameters: - surf (
Surface
) – The surface to add. - overwrite (bool) – What to do if the new surface has the same name as an existing surface for this project row. If True, the existing surface will be overwritten. In False, a ValueError will be raised.
- copy (bool) – If True, a copy of the surface will be added to the project and the input surface will not be invalidated.
Returns: A
ProjectSurface
object for the added surface.Return type: - surf (
-
__abstractmethods__
= frozenset()¶
-
__class__
¶ alias of
abc.ABCMeta
-
__contains__
(key)¶
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.project_surface', '__doc__': '\n A dictionary of {surface name: `ProjectSurface` object} for the specified\n project row. Note that surfaces may not be created by assignment to a\n dictionary value. Use `add`, {addFromFile}, or\n `schrodinger.project.ProjectRow.newMolecularSurface` instead.\n `SurfaceDict` objects are typically accessed via\n `schrodinger.project.ProjectRow.surface`.\n ', '__init__': <function SurfaceDict.__init__>, '__len__': <function SurfaceDict.__len__>, '__getitem__': <function SurfaceDict.__getitem__>, '__setitem__': <function SurfaceDict.__setitem__>, '__delitem__': <function SurfaceDict.__delitem__>, '__iter__': <function SurfaceDict.__iter__>, 'add': <function SurfaceDict.add>, 'addFromFile': <function SurfaceDict.addFromFile>, '__dict__': <attribute '__dict__' of 'SurfaceDict' objects>, '__weakref__': <attribute '__weakref__' of 'SurfaceDict' objects>, '__abstractmethods__': frozenset(), '_abc_registry': <_weakrefset.WeakSet object>, '_abc_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache_version': 49})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
(other)¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
= None¶
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.project_surface'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__reversed__
= None¶
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__slots__
= ()¶
-
__str__
¶ Return str(self).
-
classmethod
__subclasshook__
(C)¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
addFromFile
(filename, name=None, overwrite=True)¶ Read a surface from a file and add it to the project row.
Parameters: - filename (str) – The file to read
- name (str) – If given, the surface will be renamed to this before being loaded into the project.
- overwrite (bool) – What to do if the new surface has the same name as an existing surface for this project row. If True, the existing surface will be overwritten. In False, a ValueError will be raised.
Returns: A
ProjectSurface
object for the added surface.Return type:
-
clear
() → None. Remove all items from D.¶
-
get
(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
-
items
() → a set-like object providing a view on D's items¶
-
keys
() → a set-like object providing a view on D's keys¶
-
pop
(k[, d]) → v, remove specified key and return the corresponding value.¶ If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem
() → (k, v), remove and return some (key, value) pair¶ as a 2-tuple; but raise KeyError if D is empty.
-
setdefault
(k[, d]) → D.get(k,d), also set D[k]=d if k not in D¶
-
update
([E, ]**F) → None. Update D from mapping/iterable E and F.¶ If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
-
values
() → an object providing a view on D's values¶
-