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:
-
stereo
-
This option controls how stereochemical properties are written.
It does not affect the output geometry.
-
This option is supported for
SD
,
SMILES
, and SMILESCSV
, although not all
options are supported for SD
.
-
Option values are
NO_STEREO
,
STEREO_FROM_ANNOTATION_AND_GEOM
,
STEREO_FROM_ANNOTATION
, and
STEREO_FROM_GEOMETRY
.
-
The default value is
STEREO_FROM_ANNOTATION_AND_GEOM
.
-
With
STEREO_FROM_ANNOTATION_AND_GEOM
, current
annotation properties of the Structure are used when present.
Chiral atoms without annotation properties will have their
stereochemistry determined from geometry (if possible) and will
be written with definite stereochemical configuration.
-
With
NO_STEREO
, no stereochemical information will
be written.
-
With
STEREO_FROM_ANNOTATION
, stereochemical
information will be written based only on the current
annotations. Use this option to allow for specification of
stereochemistry on some centers while leaving others undefined.
This should be faster than identifying stereochemistry from the
3D geometry.
-
With
STEREO_FROM_GEOMETRY
, stereochemistry will be
written for all chiral atoms based on the 3D geometry. This
option is not supported for SD
format.
|
__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__
|
__init__(self,
filename,
overwrite=True,
format=None,
stereo=None)
(Constructor)
|
|
Create a structure writer class based on the format.
- Parameters:
- 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.
|