|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openscience.cdk.io.DefaultChemObjectWriter ambit2.core.io.MDLWriter
public class MDLWriter
Copied here from CDK source tree in order to handle the aromatic bond issue (this code writes 4 as aromatic bond code);
until a proper fix is available.
Writes MDL mol files and SD files.
A MDL mol file contains a single molecule, whereas a MDL SD file contains
one or more molecules. This class is capable of writing both mol files and
SD files. The correct format is automatically chosen:
write(IChemObject)
is called with a MoleculeSet
as an argument a SD files is writtenthis one
or
writeMolecule(org.openscience.cdk.interfaces.IMolecule)
that one}) is called the first time, a mol file is writtenThus, to write several molecules to a single SD file you can either use write(IChemObject)
and pass
a MoleculeSet
or you can repeatedly call one of the two
writeMolecule methods.
For writing a MDL molfile you can this code:
MDLWriter writer = new MDLWriter(new FileWriter(new File("output.mol"))); writer.write((IMolecule)molecule); writer.close();See {cdk.cite DAL92}. cdk.module io cdk.svnrev $Revision: 9587 $ cdk.keyword file format, MDL molfile cdk.bug 1524466
Field Summary | |
---|---|
java.util.Map |
sdFields
|
Constructor Summary | |
---|---|
MDLWriter()
|
|
MDLWriter(java.io.OutputStream output)
Contructs a new MDLWriter that can write an array of Molecules to a given OutputStream. |
|
MDLWriter(java.io.Writer out)
Contructs a new MDLWriter that can write an array of Molecules to a Writer. |
Method Summary | |
---|---|
boolean |
accepts(java.lang.Class classObject)
|
void |
close()
Flushes the output and closes this object. |
void |
dontWriteAromatic()
Method does not do anything until now. |
org.openscience.cdk.io.formats.IResourceFormat |
getFormat()
|
void |
setSdFields(java.util.Map map)
Here you can set a map which will be used to build sd fields in the file. |
void |
setWriter(java.io.OutputStream output)
|
void |
setWriter(java.io.Writer out)
|
void |
write(org.openscience.cdk.interfaces.IChemObject object)
Writes a IChemObject to the MDL molfile formated output. |
void |
writeMolecule(org.openscience.cdk.interfaces.IMolecule container)
Writes a Molecule to an OutputStream in MDL sdf format. |
Methods inherited from class org.openscience.cdk.io.DefaultChemObjectWriter |
---|
addChemObjectIOListener, fireIOSettingQuestion, getIOSettings, removeChemObjectIOListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.util.Map sdFields
Constructor Detail |
---|
public MDLWriter(java.io.Writer out)
out
- The Writer to write topublic MDLWriter(java.io.OutputStream output)
output
- The OutputStream to write topublic MDLWriter()
Method Detail |
---|
public org.openscience.cdk.io.formats.IResourceFormat getFormat()
public void setWriter(java.io.Writer out) throws org.openscience.cdk.exception.CDKException
org.openscience.cdk.exception.CDKException
public void setWriter(java.io.OutputStream output) throws org.openscience.cdk.exception.CDKException
org.openscience.cdk.exception.CDKException
public void dontWriteAromatic()
public void setSdFields(java.util.Map map)
map
- The map to be used, map of String-String pairspublic void close() throws java.io.IOException
java.io.IOException
public boolean accepts(java.lang.Class classObject)
public void write(org.openscience.cdk.interfaces.IChemObject object) throws org.openscience.cdk.exception.CDKException
object
- class must be of type ChemFile, Molecule or MoleculeSet.
org.openscience.cdk.exception.CDKException
ChemFile
public void writeMolecule(org.openscience.cdk.interfaces.IMolecule container) throws java.lang.Exception
container
- Molecule that is written to an OutputStream
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |