|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.formats.MolExporter
public class MolExporter
Molecule exporter class.
The output file format can be specified as an argument to the constructor of this class. Many different output file formats are supported like "mol", "sdf", "smiles", "png", "jpeg", etc.
By default, in case of machines with multiple processors processing is concurrent,
otherwise single-threaded. By default, the number of worker threads is the number
of processors - the number of concurrent threads can be set in
setThreadCount(int).
Experimental feature (may change in the future!):
"chemaxon.struc.Molecule" format for
testing Molecule serialization. In this case processing is single-threaded.
| Field Summary | |
|---|---|
static int |
C_CLOSE_STREAM
Close the underlying stream. |
static int |
C_FLUSH_STREAM
Flush the output stream and force any buffered output bytes to be written out. |
static MolFilter |
FILTER_DIM0
Molecule filter for cleaning 0D molecules only. |
static int |
MULTIPLE
Use this flag to produce multiple output files. |
static int |
TEXT
Use this flag to write text files with OS dependent line separators. |
| Constructor Summary | |
|---|---|
MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts)
Creates a molecule exporter. |
|
MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts,
boolean text,
java.lang.String[] incFields)
Creates a molecule exporter. |
|
MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts,
boolean text,
java.lang.String[] incFields,
java.lang.String enc)
Creates a molecule exporter. |
|
MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts,
java.lang.String enc)
Creates a molecule exporter. |
|
MolExporter(java.lang.String fname,
java.lang.String fmtWithOpts)
Creates a molecule exporter. |
|
MolExporter(java.lang.String fname,
java.lang.String fmtWithOpts,
int outflags,
java.lang.String[] incFields,
java.lang.String enc)
Creates a molecule exporter. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the MolExportModule and the underlying stream. |
void |
close(int opts)
Closes the MolExportModule and, optionally, the underlying stream. |
static java.lang.String |
convertToString(MDocument document,
java.lang.String fmt,
int flags)
Converts the document to text format. |
static byte[] |
exportToBinFormat(MDocument document,
java.lang.String fmt)
Creates a binary representation of the document. |
static byte[] |
exportToBinFormat(Molecule molecule,
java.lang.String fmt)
Creates a binary representation of the molecule. |
static java.lang.String |
exportToFormat(MDocument document,
java.lang.String fmt)
Creates a string representation of the document. |
static java.lang.String |
exportToFormat(Molecule molecule,
java.lang.String fmt)
Creates a string representation of the molecule. |
static java.lang.Object |
exportToObject(MDocument document,
java.lang.String fmt)
Creates a String, byte[] array or Image representation of the document. |
static java.lang.Object |
exportToObject(Molecule[] mols,
java.lang.String fmt,
MolExportModule cv)
Creates a String, byte[] array or Image representation of the given molecules. |
static java.lang.Object |
exportToObject(Molecule molecule,
java.lang.String fmt)
Creates a String, byte[] array or Image representation of the molecule. |
protected void |
finalize()
|
void |
flush()
Flushes the output stream and forces any buffered output bytes to be written out. |
java.lang.String |
getFormat()
Gets the output file format. |
boolean |
isCleanable()
Tests whether cleaning is meaningful for the chosen output format. |
void |
setClean(int cleanDim,
java.lang.String cleanOpts)
Sets molecule cleaning in exporter. |
void |
setClean(int cleanDim,
java.lang.String cleanOpts,
MolFilter cleanFilter)
Sets molecule cleaning in exporter. |
void |
setErrorProcessor(ErrorProcessor errorProcessor)
Sets the error handler interface for concurrent mode. |
void |
setThreadCount(int threadCount)
Sets the number of threads for concurrent processing. |
boolean |
write(Molecule m)
Writes a molecule into the stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TEXT
MolExporter(String, String, int, String[], String),
MolConverter.Builder.setOutputFlags(int),
Constant Field Valuespublic static final int MULTIPLE
MolExporter(String, String, int, String[], String),
MolConverter.Builder.setOutputFlags(int),
Constant Field Valuespublic static final int C_CLOSE_STREAM
close(int),
Constant Field Valuespublic static final int C_FLUSH_STREAM
close(int),
Constant Field Valuespublic static final MolFilter FILTER_DIM0
0D molecules only.
setClean(int, java.lang.String, chemaxon.util.MolFilter)| Constructor Detail |
|---|
public MolExporter(java.lang.String fname,
java.lang.String fmtWithOpts,
int outflags,
java.lang.String[] incFields,
java.lang.String enc)
throws MolExportException,
java.io.IOException,
java.lang.IllegalArgumentException
fname - the output filenamefmtWithOpts - the output file format and the optionsoutflags - output flags, it can be a combination of TEXT
and MULTIPLEincFields - SDF fields to include in table or nullenc - charset name or null
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported
public MolExporter(java.lang.String fname,
java.lang.String fmtWithOpts)
throws MolExportException,
java.io.IOException,
java.lang.IllegalArgumentException
fname - the output filename with extensionfmtWithOpts - the output file format and the options
MolExportException - export error occurred
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported
public MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts,
boolean text,
java.lang.String[] incFields,
java.lang.String enc)
throws MolExportException,
java.io.IOException,
java.lang.IllegalArgumentException
out - the output streamfmtWithOpts - the output file format and the optionstext - write OS dependent line.separators instead of '\n'incFields - SDF fields to include in table or nullenc - charset name or null
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported
public MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts)
throws MolExportException,
java.io.IOException,
java.lang.IllegalArgumentException
out - the output streamfmtWithOpts - the output file format and the options
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported
public MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts,
boolean text,
java.lang.String[] incFields)
throws MolExportException,
java.io.IOException,
java.lang.IllegalArgumentException
out - the output streamfmtWithOpts - the output file format and the optionstext - write OS dependent line.separators instead of '\n'incFields - SDF fields to include in table or null
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported
public MolExporter(java.io.OutputStream out,
java.lang.String fmtWithOpts,
java.lang.String enc)
throws MolExportException,
java.io.IOException,
java.lang.IllegalArgumentException
out - the output streamfmtWithOpts - the output file format and the optionsenc - charset name or null
MolExportException - export error occured
java.io.IOException - output error occurred when writing the header
java.lang.IllegalArgumentException - Invalid format string (fmtWithOpts).
java.nio.charset.IllegalCharsetNameException - if the encoding is illegal
java.nio.charset.UnsupportedCharsetException - if the encoding is unsupported| Method Detail |
|---|
public void setThreadCount(int threadCount)
throws java.lang.IllegalStateException
1 CPU.
threadCount - the number of threads, set 0 for the number of CPUs,
1 for single-threaded mode
java.lang.IllegalStateException - if called after call to write(chemaxon.struc.Molecule)
public void setClean(int cleanDim,
java.lang.String cleanOpts)
throws java.lang.IllegalStateException
cleanDim - the cleaning dimensioncleanOpts - the cleaning options
java.lang.IllegalStateException - if called after call to write(chemaxon.struc.Molecule)setThreadCount(int)
public void setClean(int cleanDim,
java.lang.String cleanOpts,
MolFilter cleanFilter)
throws java.lang.IllegalStateException
cleanDim - the cleaning dimensioncleanOpts - the cleaning optionscleanFilter - the molecule filter to tell which molecule is to be cleaned,
set FILTER_DIM0 to clean only 0D molecules
null for no filtering (cleaning all)
java.lang.IllegalStateException - if called after call to write(chemaxon.struc.Molecule)setThreadCount(int)
public void setErrorProcessor(ErrorProcessor errorProcessor)
throws java.lang.IllegalStateException
close()
in concurrent mode. To change this, set specific ErrorProcessor
implementation which can handle each error individually during the writing process and
can decide whether to continue the export or not. If the export is stopped on an error
then this error is always thrown in close().
In single-threaded mode export errors are thrown in write(chemaxon.struc.Molecule),
separately for each molecule.
java.lang.IllegalStateException - if called after call to write(chemaxon.struc.Molecule)setThreadCount(int)public java.lang.String getFormat()
public boolean isCleanable()
public boolean write(Molecule m)
throws MolExportException,
java.io.IOException
m - the molecule
true on success, false if Molecule is
not written due to a previous error in concurrent mode - in this case,
call close() which will throw the error and close the exporter
MolExportException - export error
java.io.IOException
public void close()
throws MolExportException,
java.io.IOException
MolExportModule and the underlying stream.
IMPORTANT: call this or close(int) at the end, after the last call to
write(chemaxon.struc.Molecule), because this method
flushes the output stream and closes concurrent processing properly.
MolExportException - on export error.
java.io.IOException - in case of any other I/O error.
public void close(int opts)
throws MolExportException,
java.io.IOException
MolExportModule and, optionally, the underlying stream.
IMPORTANT: call this or close() at the end, after the last call to
write(chemaxon.struc.Molecule), because this method
flushes the output stream and closes concurrent processing properly.
opts - closing options, C_CLOSE_STREAM
or C_FLUSH_STREAM.
MolExportException - export error.
java.io.IOException - in case of any other I/O error.
public void flush()
throws MolExportException,
java.io.IOException
MolExportException - on export error.
java.io.IOException - if an I/O error occurs.
protected void finalize()
throws MolExportException,
java.io.IOException
finalize in class java.lang.ObjectMolExportException
java.io.IOException
public static java.lang.Object exportToObject(MDocument document,
java.lang.String fmt)
throws java.io.IOException
import java.awt.Image; ... String s1 = (String)MolExporter.exportToObject(document, "mol"); String s2 = (String)MolExporter.exportToObject(document, "smiles:a-H"); // aromatize, remove H Image img = (Image)MolExporter.exportToObject(document, "image:w300,h300,#ffff00"); byte[] d3 = (byte[])MolExporter.exportToObject(document, "ppm:w300,h300,#ffff00"); byte[] d4 = (byte[])MolExporter.exportToObject(document, "png:w300,h300,b32,#00ffff00"); byte[] d5 = (byte[])MolExporter.exportToObject(document, "jpeg:w300,h300,Q95,#ffff00,spacefill");
document - the document to exportfmt - the format descriptor string
java.io.IOException - Export error.
java.lang.IllegalArgumentException - Invalid format string.
java.lang.SecurityException - Export module cannot be loaded because of security reasons
(firewall).exportToFormat(chemaxon.struc.MDocument, java.lang.String),
exportToBinFormat(chemaxon.struc.MDocument, java.lang.String)
public static java.lang.String convertToString(MDocument document,
java.lang.String fmt,
int flags)
throws java.io.IOException
document - the document to convertfmt - the molecule file format or nullflags - conversion options
java.io.IOException - Export error
public static final java.lang.String exportToFormat(MDocument document,
java.lang.String fmt)
throws java.io.IOException
s1 = MolExporter.exportToFormat(document, "mol"); s2 = MolExporter.exportToFormat(document, "smiles:a-H"); // aromatize and remove Hydrogens
document - the document to exportfmt - the format descriptor string
java.io.IOException - Export error
java.lang.IllegalArgumentException - Invalid format string.
java.lang.SecurityException - Export module cannot be loaded because of
security reasons (firewall).exportToBinFormat(chemaxon.struc.MDocument, java.lang.String),
exportToObject(chemaxon.struc.MDocument, java.lang.String)
public static final byte[] exportToBinFormat(MDocument document,
java.lang.String fmt)
throws java.io.IOException
exportToFormat method, and also with the binary
image formats (jpeg, msbmp, png, ppm). When creating an image,
display
options can also be specified in the format descriptor string.
Format and options are separated by a colon, multiple options can be
separated by commas. See the possible formats and their options on the
File Formats in Marvin
page. Examples:
byte[] d1 = MolExporter.exportToBinFormat(document, "mrv"); byte[] d2 = MolExporter.exportToBinFormat(document, "smiles:a-H"); // aromatize and remove H byte[] d3 = MolExporter.exportToBinFormat(document, "ppm:w300,h300,#ffff00"); byte[] d4 = MolExporter.exportToBinFormat(document, "png:w300,h300,b32,#00ffff00"); byte[] d5 = MolExporter.exportToBinFormat(document, "jpeg:w300,h300,Q95,#ffff00,spacefill");
document - the document to exportfmt - the format descriptor string
java.io.IOException - Export error.
java.lang.IllegalArgumentException - Invalid format string.
java.lang.SecurityException - Export module cannot be loaded because of
security reasons (firewall).exportToFormat(chemaxon.struc.MDocument, java.lang.String),
exportToObject(chemaxon.struc.MDocument, java.lang.String)
public static final java.lang.String exportToFormat(Molecule molecule,
java.lang.String fmt)
throws java.io.IOException
s1 = MolExporter.exportToFormat(molecule, "mol"); s2 = MolExporter.exportToFormat(molecule, "smiles:a-H"); // aromatize and remove Hydrogens
molecule - the molecule to exportfmt - the format descriptor string
java.io.IOException - Export error.
java.lang.IllegalArgumentException - Invalid format string.
java.lang.SecurityException - Export module cannot be loaded because of
security reasons (firewall).
public static final byte[] exportToBinFormat(Molecule molecule,
java.lang.String fmt)
throws java.io.IOException
exportToFormat method, and also with the binary image
formats (jpeg, msbmp, png, ppm). When creating an image,
display
options can also be specified in the format descriptor string.
Format and options are separated by a colon, multiple options can be
separated by commas. See the possible formats and their options on the
File Formats in Marvin
page. Examples:
byte[] d1 = MolExporter.exportToBinFormat(molecule, "mol"); byte[] d2 = MolExporter.exportToBinFormat(molecule, "smiles:a-H"); // aromatize and remove H byte[] d3 = MolExporter.exportToBinFormat(molecule, "ppm:w300,h300,#ffff00"); byte[] d4 = MolExporter.exportToBinFormat(molecule, "png:w300,h300,b32,#00ffff00"); byte[] d5 = MolExporter.exportToBinFormat(molecule, "jpeg:w300,h300,Q95,#ffff00,spacefill");
molecule - the molecule to exportfmt - the format descriptor string
java.io.IOException - Export error.
java.lang.IllegalArgumentException - Invalid format string.
java.lang.SecurityException - Export module cannot be loaded because of
security reasons (firewall).
public static java.lang.Object exportToObject(Molecule molecule,
java.lang.String fmt)
throws java.io.IOException
import java.awt.Image; ... String s1 = (String)MolExporter.exportToObject(molecule, "mol"); String s2 = (String)MolExporter.exportToObject(molecule, "smiles:a-H"); // aromatize, remove H Image img = (Image)MolExporter.exportToObject(molecule, "image:w300,h300,#ffff00"); byte[] d3 = (byte[])MolExporter.exportToObject(molecule, "ppm:w300,h300,#ffff00"); byte[] d4 = (byte[])MolExporter.exportToObject(molecule, "png:w300,h300,b32,#00ffff00"); byte[] d5 = (byte[])MolExporter.exportToObject(molecule, "jpeg:w300,h300,Q95,#ffff00,spacefill");
molecule - the molecule to exportfmt - the format descriptor string
java.io.IOException - Export error.
java.lang.IllegalArgumentException - Invalid format string.
java.lang.SecurityException - Export module cannot be loaded because of
security reasons (firewall).
public static java.lang.Object exportToObject(Molecule[] mols,
java.lang.String fmt,
MolExportModule cv)
throws java.io.IOException
mols - the molecules to exportfmt - the format descriptor stringcv - the export module
java.io.IOException - export errorexportToObject(Molecule, String)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||