schrodinger.application.phase.packages.shape_binary_utils module

class schrodinger.application.phase.packages.shape_binary_utils.ShapeFileWriter(filename, metadata, compress)

Bases: contextlib.AbstractContextManager

__init__(filename, metadata, compress)
Parameters
  • filename (str) – File name (expected to exist if metadata is empty).

  • metadata (str) – Text to be stored as file-scope “metadata”. If empty, “append” opening mode is assumed. If not empty, existing file with the same name will be truncated.

  • compress (bool) – Compress the file using zlib.

append(title, shapes)

Appends shapes to the associated binary file.

Parameters
  • title (str) – Title of the shapes.

  • shapes (list(shape.ShapeStructure)) – List of shape.ShapeStructure instances (may have different number of spheres).

class schrodinger.application.phase.packages.shape_binary_utils.ShapeFileReader(filename, block_size=10000)

Bases: contextlib.AbstractContextManager

__init__(filename, block_size=10000)
Parameters
  • filename (str) – File name.

  • block_size (int) – Number of (title, structures) entries to read in one scoop.

property metadata

File-scope metadata from the associated “shape binary” file.

getBlock(shapes=None, titles=None)

Reads next block of shapes and their titles. Returns (None, None) on EOF, raises RuntimeError on errors. Uses memory associated with shapes and/or titles unless the parameter is None.

Parameters
  • shapes (shape.ShapeStructureVector) – SWIG-wrapped c++ std::vector<shape::ShapeStructure>.

  • titles (shape.ShapeBlockTitleVector) – SWIG-wrapped c++ std::vector<std::pair<std::string, size_t>>.

Returns

Blocks of shapes and their titles. The titles is a vector of (name, number-of-shape-structures) pairs, and shapes is a vector of shape.ShapeStructure instances. len(shapes) == titles[0][1] + titles[1][1] + … + titles[N][1]

Return type

(shape.ShapeStructureVector, shape.ShapeBlockTitleVector)

class schrodinger.application.phase.packages.shape_binary_utils.SingularShapeFileReader(filename)

Bases: schrodinger.application.phase.packages.shape_binary_utils.ShapeFileReader

__init__(filename)
Parameters
  • filename (str) – File name.

  • block_size (int) – Number of (title, structures) entries to read in one scoop.

getBlock(shapes=None, titles=None)

Reads next block of shapes and their titles. Returns (None, None) on EOF, raises RuntimeError on errors. Uses memory associated with shapes and/or titles unless the parameter is None.

Parameters
  • shapes (shape.ShapeStructureVector) – SWIG-wrapped c++ std::vector<shape::ShapeStructure>.

  • titles (shape.ShapeBlockTitleVector) – SWIG-wrapped c++ std::vector<std::pair<std::string, size_t>>.

Returns

Blocks of shapes and their titles. The titles is a vector of (name, number-of-shape-structures) pairs, and shapes is a vector of shape.ShapeStructure instances. len(shapes) == titles[0][1] + titles[1][1] + … + titles[N][1]

Return type

(shape.ShapeStructureVector, shape.ShapeBlockTitleVector)

property metadata

File-scope metadata from the associated “shape binary” file.