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.
- 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 - 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> acceptedSdTags) 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 TypeMethodDescriptionbooleanaccepts(Class<? extends IChemObject> classObject) Returns whether the givenIChemObjectcan be read or written.voidclose()Flushes the output and closes this object.voidvoidflush()Returns theIResourceFormatclass for this IO class.voidsetAlwaysV3000(boolean val) voidsetWriter(OutputStream output) Sets the OutputStream from which this ChemObjectWriter should write the contents.voidSets the Writer from which this ChemObjectWriter should write the contents.voidwrite(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, removeChemObjectIOListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
-
SD_RECORD_DELIM
- 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- TheWriterto write to
-
SDFWriter
Constructs a new SdfWriter that can write to a givenOutputStream.- Parameters:
output- TheOutputStreamto write to
-
SDFWriter
Writes SD-File to a String including the given properties
-
-
Method Details
-
getFormat
Description copied from interface:IChemObjectIOReturns theIResourceFormatclass for this IO class. -
setWriter
Description copied from interface:IChemObjectWriterSets the Writer from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
setWriter
Description copied from interface:IChemObjectWriterSets 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:IChemObjectIOReturns whether the givenIChemObjectcan be read or written.- Parameters:
classObject-IChemObjectof which is tested if it can be handled.- Returns:
- true, if the
IChemObjectcan be handled.
-
write
Writes a IChemObject to the MDL SD file formated output. It can only output IChemObjects of typeIChemFile,IAtomContainerSetandIAtomContainerSet.- 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
-