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 String
OptAlwaysV3000
static String
OptTruncateLongData
static String
OptWriteData
-
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> propertiesToWrite)
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> propertiesToWrite)
Constructs a new SDFWriter that writes to the givenWriter
.SDFWriter(Set<String> propertiesToWrite)
Writes SD-File to a String including the given properties
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(Class<? extends IChemObject> classObject)
Returns whether the givenIChemObject
can be read or written.void
close()
Flushes the output and closes this object.void
customizeJob()
void
flush()
IResourceFormat
getFormat()
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
setWriter(Writer out)
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 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
-
-
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> propertiesToWrite)
Constructs a new SDFWriter that writes to the givenWriter
.- Parameters:
out
- TheWriter
to write to
-
SDFWriter
public SDFWriter(OutputStream output, Set<String> propertiesToWrite)
Constructs a new SdfWriter that can write to a givenOutputStream
.- Parameters:
output
- TheOutputStream
to write to
-
-
Method Detail
-
getFormat
public IResourceFormat getFormat()
Description copied from interface:IChemObjectIO
Returns theIResourceFormat
class for this IO class.
-
setWriter
public void setWriter(Writer out) throws CDKException
Description copied from interface:IChemObjectWriter
Sets the Writer from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
setWriter
public void setWriter(OutputStream output) throws CDKException
Description copied from interface:IChemObjectWriter
Sets the OutputStream from which this ChemObjectWriter should write the contents.- Throws:
CDKException
-
close
public void close() throws IOException
Flushes 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: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
public void write(IChemObject object) throws CDKException
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:
accepts(Class)
-
setAlwaysV3000
public void setAlwaysV3000(boolean val)
-
customizeJob
public void customizeJob()
-
flush
public void flush() throws IOException
- Throws:
IOException
-
-