Package org.openscience.cdk.io
Class SDFWriter
java.lang.Object
org.openscience.cdk.io.ChemObjectIO
org.openscience.cdk.io.DefaultChemObjectWriter
org.openscience.cdk.io.SDFWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IChemObjectIO
,IChemObjectWriter
Writes MDL SD files ([Dalby, A. et. al.. Journal of Chemical Information and Computer Sciences. 1992. 32]). A MDL SD file contains one or more molecules,
complemented by properties.
- Source code:
- main
- IO options:
Name Question Default WriteAromaticBondTypes Should aromatic bonds be written as bond type 4? false WriteMajorIsotopes Write atomic mass of any non-null atomic mass including major isotopes (e.g. [12]C) true writeProperties Should molecule properties be written as non-structural data true WriteQueryFormatValencies Should valencies be written in the MDL Query format? (deprecated) false TruncateLongData Truncate long data files >200 characters false ProgramName Program name to write at the top of the molfile header, should be exactly 8 characters long CDK ForceWriteAs2DCoordinates Should coordinates always be written as 2D? false WriteDefaultProperties Write trailing zero's on atom/bond property blocks even if they're not used. true writeV3000 Write all records as V3000 false - Belongs to CDK module:
- io
- Keywords:
- file format, MDL SD file
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSDFWriter
(BufferedWriter wtr) Create an SDfile writer that will output directly to the provided buffered writer.SDFWriter
(OutputStream output) Create an SDfile writer, the provided output stream is wrapped in a UTF-8 buffered writer.SDFWriter
(OutputStream output, Set<String> propertiesToWrite) Constructs a new SdfWriter that can write to a givenOutputStream
.Create an SDfile writer, the provided writer is buffered if it's not an instance of BufferedWriter.Constructs a new SDFWriter that writes to the givenWriter
.Writes SD-File to a String including the given properties -
Method Summary
Modifier and TypeMethodDescriptionboolean
accepts
(Class<? extends IChemObject> classObject) Returns whether the givenIChemObject
can be read or written.void
close()
Flushes the output and closes this object.void
void
flush()
Returns theIResourceFormat
class for this IO class.void
setAlwaysV3000
(boolean val) void
setWriter
(OutputStream output) Sets the OutputStream from which this ChemObjectWriter should write the contents.void
Sets the Writer from which this ChemObjectWriter should write the contents.void
write
(IChemObject object) Writes a IChemObject to the MDL SD file formated output.Methods inherited from class org.openscience.cdk.io.ChemObjectIO
addChemObjectIOListener, addSetting, addSettings, fireIOSettingQuestion, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openscience.cdk.io.IChemObjectIO
addChemObjectIOListener, addSetting, addSettings, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
-
Field Details
-
OptAlwaysV3000
- See Also:
-
OptWriteData
- See Also:
-
OptTruncateLongData
- See Also:
-
-
Constructor Details
-
SDFWriter
Create an SDfile writer that will output directly to the provided buffered writer.- Parameters:
wtr
- writer
-
SDFWriter
Create an SDfile writer, the provided writer is buffered if it's not an instance of BufferedWriter. For flush control etc please create withBufferedWriter
.- Parameters:
wtr
- writer
-
SDFWriter
Create an SDfile writer, the provided output stream is wrapped in a UTF-8 buffered writer.- Parameters:
output
- out stream
-
SDFWriter
public SDFWriter() -
SDFWriter
Constructs a new SDFWriter that writes to the givenWriter
.- Parameters:
out
- TheWriter
to write to
-
SDFWriter
Constructs a new SdfWriter that can write to a givenOutputStream
.- Parameters:
output
- TheOutputStream
to write to
-
SDFWriter
Writes SD-File to a String including the given properties
-
-
Method Details
-
getFormat
Description copied from interface:IChemObjectIO
Returns theIResourceFormat
class for this IO class. -
setWriter
Description copied from interface:IChemObjectWriter
Sets the Writer from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
setWriter
Description copied from interface:IChemObjectWriter
Sets the OutputStream from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
close
Flushes the output and closes this object.- Throws:
IOException
- when the wrapper IO class cannot be closed.
-
accepts
Description copied from interface:IChemObjectIO
Returns whether the givenIChemObject
can be read or written.- Parameters:
classObject
-IChemObject
of which is tested if it can be handled.- Returns:
- true, if the
IChemObject
can be handled.
-
write
Writes a IChemObject to the MDL SD file formated output. It can only output IChemObjects of typeIChemFile
,IAtomContainerSet
andIAtomContainerSet
.- Parameters:
object
- an acceptableIChemObject
- Throws:
CDKException
- is thrown if the output does not support the data in the object- See Also:
-
setAlwaysV3000
public void setAlwaysV3000(boolean val) -
customizeJob
public void customizeJob() -
flush
- Throws:
IOException
-