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
public class SDFWriter extends DefaultChemObjectWriter
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 Modifier and Type Field Description static StringOptAlwaysV3000static StringOptTruncateLongDatastatic StringOptWriteDatastatic StringSD_RECORD_DELIM
-
Constructor Summary
Constructors Constructor Description SDFWriter()SDFWriter(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.SDFWriter(Writer wtr)Create an SDfile writer, the provided writer is buffered if it's not an instance of BufferedWriter.SDFWriter(Writer out, Set<String> acceptedSdTags)Constructs a new SDFWriter that writes to the givenWriter.SDFWriter(Set<String> acceptedSdTags)Writes SD-File to a String including the given properties
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccepts(Class<? extends IChemObject> classObject)Returns whether the givenIChemObjectcan be read or written.voidclose()Flushes the output and closes this object.voidcustomizeJob()voidflush()IResourceFormatgetFormat()Returns theIResourceFormatclass for this IO class.voidsetAlwaysV3000(boolean val)voidsetWriter(OutputStream output)Sets the OutputStream from which this ChemObjectWriter should write the contents.voidsetWriter(Writer out)Sets 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, 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 Detail
-
OptAlwaysV3000
public static final String OptAlwaysV3000
- See Also:
- Constant Field Values
-
OptWriteData
public static final String OptWriteData
- See Also:
- Constant Field Values
-
OptTruncateLongData
public static final String OptTruncateLongData
- See Also:
- Constant Field Values
-
SD_RECORD_DELIM
public static final String SD_RECORD_DELIM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SDFWriter
public SDFWriter(BufferedWriter wtr)
Create an SDfile writer that will output directly to the provided buffered writer.- Parameters:
wtr- writer
-
SDFWriter
public SDFWriter(Writer wtr)
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
public SDFWriter(OutputStream output)
Create an SDfile writer, the provided output stream is wrapped in a UTF-8 buffered writer.- Parameters:
output- out stream
-
SDFWriter
public SDFWriter()
-
SDFWriter
public SDFWriter(Writer out, Set<String> acceptedSdTags)
Constructs a new SDFWriter that writes to the givenWriter.- Parameters:
out- TheWriterto write to
-
SDFWriter
public SDFWriter(OutputStream output, Set<String> acceptedSdTags)
Constructs a new SdfWriter that can write to a givenOutputStream.- Parameters:
output- TheOutputStreamto write to
-
-
Method Detail
-
getFormat
public IResourceFormat getFormat()
Description copied from interface:IChemObjectIOReturns theIResourceFormatclass for this IO class.
-
setWriter
public void setWriter(Writer out) throws CDKException
Description copied from interface:IChemObjectWriterSets the Writer from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
setWriter
public void setWriter(OutputStream output) throws CDKException
Description copied from interface:IChemObjectWriterSets the OutputStream from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
close
public void close() throws IOExceptionFlushes the output and closes this object.- Throws:
IOException- when the wrapper IO class cannot be closed.
-
accepts
public boolean accepts(Class<? extends IChemObject> classObject)
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
public void write(IChemObject object) throws CDKException
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:
accepts(Class)
-
setAlwaysV3000
public void setAlwaysV3000(boolean val)
-
customizeJob
public void customizeJob()
-
flush
public void flush() throws IOException- Throws:
IOException
-
-