public class MolConverter extends Object
Examples:
MolConverter.Builder
mcbld = new MolConverter.Builder(); mcbld.addInput
("input.sdf", ""); mcbld.setOutput
("out.smiles", "smiles"); mcbld.setOutputFlags
(MolExporter.TEXT
); MolConverter mc = mcbld.build(); while(mc.convert()
); mc.close()
;
mcbld.setOutput
("out.mol", "mol"); mcbld.setOutputFlags
(MolExporter.TEXT
|MolExporter.MULTIPLE
);
Modifier and Type | Class and Description |
---|---|
static class |
MolConverter.Builder
MolConverter builder.
|
static class |
MolConverter.Options
Deprecated.
as of Marvin 5.2.3, use
MolConverter.Builder instead. |
Constructor and Description |
---|
MolConverter(InputStream in,
OutputStream out,
String fmtopts,
boolean useSysEOL)
Creates a MolConverter object.
|
MolConverter(InputStream in,
String ofname,
String fmtopts,
boolean useSysEOL)
Use this constructor if you do not need output buffering but want to
determine output file positions.
|
MolConverter(List<Object> inFiles,
List<String> inOptions,
OutputStream out,
String fmtopts,
boolean useSysEOL)
Deprecated.
as of Marvin 5.2.3, replaced by
MolConverter(Builder) |
MolConverter(List<Object> inFiles,
List<String> inOptions,
OutputStream out,
String fmtopts,
boolean useSysEOL,
String[] incFields)
Deprecated.
as of Marvin 5.2.3, replaced by
MolConverter(Builder) |
MolConverter(List<Object> inFiles,
List<String> inOptions,
OutputStream out,
String fmtopts,
boolean useSysEOL,
String[] incFields,
String enc)
Deprecated.
as of Marvin 5.2.3, replaced by
MolConverter(Builder) |
MolConverter(List<Object> inFiles,
List<String> inOptions,
String ofname,
String fmtopts,
boolean useSysEOL)
Deprecated.
as of Marvin 5.2.3, replaced by
MolConverter(Builder) |
MolConverter(List<Object> inFiles,
OutputStream out,
String fmtopts,
boolean useSysEOL)
Deprecated.
as of Marvin 5.2.3, replaced by
MolConverter(Builder) |
MolConverter(List<Object> inFiles,
String ofname,
String fmtopts,
boolean useSysEOL)
Deprecated.
as of Marvin 5.2.3, replaced by
MolConverter(Builder) |
MolConverter(MolConverter.Builder mcbld)
Creates a MolConverter object.
|
MolConverter(MolConverter.Options opts)
Deprecated.
as of Marvin 5.2.3, use
MolConverter.Builder.build()
instead. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the exporter and the output stream.
|
void |
close(int opts)
Closes the exporter.
|
boolean |
convert()
Convert the next molecule.
|
static MolConverter |
createMolConverter(InputStream instream,
OutputStream outstream,
String[] args,
int[] verbosityLevel)
Creates a MolConverter instance with the attributes specified in the
parameters.
|
static void |
main(String[] args)
Main method.
|
static void |
mainWithoutExit(String[] args)
Same as main(), but never calls System.exit().
|
long |
otell()
Get the current file position.
|
void |
setIgnoreError(boolean ignoreError)
Sets the 'ignoreError' option.
|
void |
setThreadCount(int threadCount)
Sets the number of threads for concurrent processing.
|
public MolConverter(MolConverter.Builder mcbld) throws MolFormatException, MolExportException, IOException, IllegalArgumentException
mcbld
- the builderMolFormatException
- If the molecule file is in a
format that cannot be readMolExportException
- If the molecule cannot be exported in the
specified formatIOException
- If I/O error occured when determining
the file format.IllegalArgumentException
- Invalid format string (fmt).public MolConverter(InputStream in, OutputStream out, String fmtopts, boolean useSysEOL) throws MolFormatException, MolExportException, IOException, IllegalArgumentException
in
- the input molecule stream to convertout
- the output streamfmtopts
- output file format with or without optionsuseSysEOL
- write OS dependent line.separators instead of '\n'MolFormatException
- If the molecule file is in a
format that cannot be readMolExportException
- If the molecule cannot be exported in the
specified formatIOException
- If I/O error occured when determining
the file format.IllegalArgumentException
- Invalid format string (fmt).public MolConverter(InputStream in, String ofname, String fmtopts, boolean useSysEOL) throws MolFormatException, MolExportException, IOException, IllegalArgumentException
in
- the input molecule stream to convertofname
- the output file namefmtopts
- output file format with or without optionsuseSysEOL
- write OS dependent line.separators instead of '\n'MolFormatException
- If the molecule file is in a
format that cannot be readMolExportException
- If the molecule cannot be exported in the
specified formatIOException
- If I/O error occured when determining
the file format.IllegalArgumentException
- Invalid format string (fmt).otell()
,
close()
@Deprecated public MolConverter(List<Object> inFiles, OutputStream out, String fmtopts, boolean useSysEOL) throws MolFormatException, MolExportException, IOException
MolConverter(Builder)
inFiles
- not used in this method since it is unsupported now.out
- not used in this method since it is unsupported now.fmtopts
- not used in this method since it is unsupported now.useSysEOL
- not used in this method since it is unsupported now.MolFormatException
- not thrown from this method since it is unsupported now.MolExportException
- not thrown from this method since it is unsupported now.IOException
- not thrown from this method since it is unsupported now.@Deprecated public MolConverter(List<Object> inFiles, String ofname, String fmtopts, boolean useSysEOL) throws MolFormatException, MolExportException, IOException
MolConverter(Builder)
inFiles
- not used in this method since it is unsupported now.ofname
- not used in this method since it is unsupported now.fmtopts
- not used in this method since it is unsupported now.useSysEOL
- not used in this method since it is unsupported now.MolFormatException
- not thrown from this method since it is unsupported now.MolExportException
- not thrown from this method since it is unsupported now.IOException
- not thrown from this method since it is unsupported now.@Deprecated public MolConverter(List<Object> inFiles, List<String> inOptions, String ofname, String fmtopts, boolean useSysEOL) throws MolFormatException, MolExportException, IOException, IllegalArgumentException
MolConverter(Builder)
inFiles
- not used in this method since it is unsupported now.inOptions
- not used in this method since it is unsupported now.ofname
- not used in this method since it is unsupported now.fmtopts
- not used in this method since it is unsupported now.useSysEOL
- not used in this method since it is unsupported now.MolFormatException
- not thrown from this method since it is unsupported now.MolExportException
- not thrown from this method since it is unsupported now.IOException
- not thrown from this method since it is unsupported now.IllegalArgumentException
@Deprecated public MolConverter(MolConverter.Options opts) throws MolFormatException, MolExportException, IOException, IllegalArgumentException
MolConverter.Builder.build()
instead.opts
- not used in this method since it is unsupported now.MolFormatException
- not thrown from this method since it is unsupported now.MolExportException
- not thrown from this method since it is unsupported now.IOException
- not thrown from this method since it is unsupported now.IllegalArgumentException
@Deprecated public MolConverter(List<Object> inFiles, List<String> inOptions, OutputStream out, String fmtopts, boolean useSysEOL) throws MolFormatException, MolExportException, IOException
MolConverter(Builder)
inFiles
- not used in this method since it is unsupported now.inOptions
- not used in this method since it is unsupported now.out
- not used in this method since it is unsupported now.fmtopts
- not used in this method since it is unsupported now.useSysEOL
- not used in this method since it is unsupported now.MolFormatException
- not thrown from this method since it is unsupported now.MolExportException
- not thrown from this method since it is unsupported now.IOException
- not thrown from this method since it is unsupported now.@Deprecated public MolConverter(List<Object> inFiles, List<String> inOptions, OutputStream out, String fmtopts, boolean useSysEOL, String[] incFields) throws MolFormatException, MolExportException, IOException
MolConverter(Builder)
inFiles
- not used in this method since it is unsupported now.inOptions
- not used in this method since it is unsupported now.out
- not used in this method since it is unsupported now.fmtopts
- not used in this method since it is unsupported now.useSysEOL
- not used in this method since it is unsupported now.incFields
- not used in this method since it is unsupported now.MolFormatException
- not thrown from this method since it is unsupported now.MolExportException
- not thrown from this method since it is unsupported now.IOException
- not thrown from this method since it is unsupported now.@Deprecated public MolConverter(List<Object> inFiles, List<String> inOptions, OutputStream out, String fmtopts, boolean useSysEOL, String[] incFields, String enc) throws MolFormatException, MolExportException, IOException
MolConverter(Builder)
inFiles
- not used in this method since it is unsupported now.inOptions
- not used in this method since it is unsupported now.out
- not used in this method since it is unsupported now.fmtopts
- not used in this method since it is unsupported now.useSysEOL
- not used in this method since it is unsupported now.incFields
- not used in this method since it is unsupported now.enc
- not used in this method since it is unsupported now.MolFormatException
- not thrown from this method since it is unsupported now.MolExportException
- not thrown from this method since it is unsupported now.IOException
- not thrown from this method since it is unsupported now.public void setIgnoreError(boolean ignoreError)
true
then processing is continued with the next molecule on error,
otherwise processing is interrupted on error. Default: false
.ignoreError
- true
if processing should be continued on errorpublic void setThreadCount(int threadCount) throws IllegalStateException
1
CPU.threadCount
- the number of threads, set 0
for the number of CPUs,
1
for single-threaded modeIllegalStateException
- if called after call to convert()
.public boolean convert() throws IOException
IOException
- If an I/O error has occurred.IllegalCharsetNameException
- if the encoding is illegalUnsupportedCharsetException
- if the encoding is unsupportedpublic long otell() throws IOException
IOException
- if the position cannot be determinedpublic void close() throws IOException
MolExportException
- export error.IOException
- in case of any other I/O error.public void close(int opts) throws IOException
MolExporter.C_CLOSE_STREAM
option is used.
If the input stream was opened internally, then the opts
argument has no effect, the output stream is always closed.opts
- closing options for the exporter, applied only if the
output stream is specified by the userMolExportException
- export error.IOException
- in case of any other I/O error.MolExporter.C_CLOSE_STREAM
,
MolExporter.C_FLUSH_STREAM
public static MolConverter createMolConverter(InputStream instream, OutputStream outstream, String[] args, int[] verbosityLevel) throws IOException
instream
- the input stream to take the molecule definition from.
It must be null
when called for command line
usage.outstream
- the output stream to write the result onto. It must be
null
when called for command line usage.args
- space separated options of attributes/options for the
desired MolConverter instance.verbosityLevel
- may be used by the caller to retrieve
(as the first element of the array) the verbosity level
specified in args
. Must be either at least one
element long or (if the caller is not interested in this
value) null
.IllegalCharsetNameException
- if illegal input or output encoding name specifiedUnsupportedCharsetException
- if the specified input or output encoding is unsupportedIOException
public static void main(String[] args) throws IOException
args
- command line argumentsIOException
public static void mainWithoutExit(String[] args) throws IOException
args
- arguments passed to main().IOException