Package schrodinger :: Module structure :: Class StructureWriter
[hide private]
[frames] | no frames]

Class StructureWriter

                 object --+    
                          |    
_ReaderWriterContextManager --+
                              |
                             StructureWriter

A class for efficient writing of multiple structures to a single structure file. If you are writing a single structure, you can more easily use the Structure.write method.

Options that are not supported for all formats can be set with the setOption method, for example:

   writer = StructureWriter(filename)
   try:
       writer.setOption(stereo=STEREO_FROM_ANNOTATION)
   except OptionError:
       # take action based on unsupported option/value here

Currently, the following options are available:

Instance Methods [hide private]
 
__init__(self, filename, overwrite=True, format=None, stereo=None)
Create a structure writer class based on the format.
 
append(self, ct)
Append the provided structure to the open file.
 
extend(self, cts)
Append all provided structures to the open file.
 
close(self)
Close the file.
 
setOption(self, option, value)
Set a single option for this writer.

Inherited from _ReaderWriterContextManager: __enter__, __exit__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename, overwrite=True, format=None, stereo=None)
(Constructor)

 

Create a structure writer class based on the format.

Parameters:
  • filename (str) - The filename to write to.
  • overwrite (bool) - If False, append to an existing file instead of overwriting it.
  • format (str) - The format of the file. Values should be specified by one of the module-level constants MAESTRO, MOL2, SD, SMILES, or SMILESCSV. If the format is not explicitly specified it will be determined from the suffix of the filename. Multi-structure PDB files are not supported.
  • stereo (enum) - Use of the stereo option in the constructor is pending deprecation. Please use the setOption method instead.

    See the class docstring for documentation on the stereo options.

Overrides: object.__init__

setOption(self, option, value)

 

Set a single option for this writer. This method is meant for options that may not be supported for all writer formats. See the StructureWriter class documentation for details on the available options.

Raises an OptionError subclass (either UnsupportedOption or UnsupportedOptionValue) if unsuccessful.

Parameters:
  • option (str) - The name of the option to set.
  • value - The value for the option. The data type of this parameter depends on the option being set.