chemaxon.descriptors
Class MDFileWriter

java.lang.Object
  extended by chemaxon.descriptors.MDWriter
      extended by chemaxon.descriptors.MDFileWriter

public class MDFileWriter
extends MDWriter

Writes chemical descriptor sets (MDSet)s into text files. The output file can either be a bunch of descriptor files, in which case one MDSet component is associated with one file; or it can also be an SDfile, in which case custom tags are written along with the molecule and with its existing tags that store the MolecularDescriptors in a format that MDFileReader can interpret.
In the output one component is written per file. The unique identifier of MDSet objects is printed in all files. Always blank space is used as a separator character. The descriptor file contains two header lines, the first is the type name of the descriptor, while the second is the configuration string used in the descriptor generation.

Since:
JChem 2.0
Author:
Miklos Vargyas

Field Summary
 
Fields inherited from class chemaxon.descriptors.MDWriter
mdNames
 
Constructor Summary
MDFileWriter(int nComponents)
          Creates a new MDFileWriter object that stores MDSets that have the given number of components.
MDFileWriter(java.lang.String[] descrNames, java.lang.String[] types, MDParameters[] settings)
          Creates and initialises a new MDFileWriter object that stores MDSets in the named text files component-wise.
MDFileWriter(java.lang.String[] descrNames, java.lang.String[] types, java.lang.String[] settings)
          Creates and initialises a new MDFileWriter object that stores MDSets in the named text files component-wise.
MDFileWriter(java.lang.String SDfileName, int nComponents)
          Creates and initializes a new MDFileWriter object that stores MDSets in the named SDfile.
MDFileWriter(java.lang.String SDfileName, java.lang.String[] descrNames, java.lang.String[] types, MDParameters[] settings)
          Creates and initializes a new MDFileWriter object that stores MDSets in the named SDfile.
MDFileWriter(java.lang.String SDfileName, java.lang.String[] descrNames, java.lang.String[] types, java.lang.String[] settings)
          Creates and initializes a new MDFileWriter object that stores MDSets in the named SDfile.
MDFileWriter(java.lang.String descrName, java.lang.String type, MDParameters settings)
          Creates and initializes a new MDFileWriter object that stores MDSets in the named text file.
MDFileWriter(java.lang.String descrName, java.lang.String type, java.lang.String settings)
          Creates and initializes a new MDFileWriter object that stores MDSets in the named text file.
 
Method Summary
 void close()
          Closes the stream, after that no more operations are permitted.
 MDParameters getMDParameters(int id)
          Gets the actual parameter settings of the specified component.
 MDSet getMDSet()
          Gets the last molecular descriptor set generated and put into the output file.
 void put(MDSet ds)
          Writes the given MDSet object into the output files as readable text.
 void put(Molecule mol, int id)
          Generates the MDSet object from the given molecular structure and writes result.
 void put(Molecule mol, java.lang.String naturalId)
          Generates the MDSet for the given Molecule and writes the descriptors into the output with the given identifier.
 void setBinaryOutputFormat(boolean binaryOutputFormat)
          Sets binary output format.
 void setComponent(int index, java.lang.String descrName, java.lang.String type, MDParameters settings)
          Sets an individual MDSet component's type and corresponding parameters.
 void setComponent(int index, java.lang.String descrName, java.lang.String type, java.lang.String settings)
          Sets an individual MDSet component's type and corresponding parameters.
 void setDecimalOutputFormat(boolean decimalOutputFormat)
          Sets decimal output format.
 void setPrintId(boolean printId)
          Sets whether unique internal ID-s of structures have to be printed into the output table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MDFileWriter

public MDFileWriter(java.lang.String[] descrNames,
                    java.lang.String[] types,
                    MDParameters[] settings)
             throws MDWriterException
Creates and initialises a new MDFileWriter object that stores MDSets in the named text files component-wise. With this constructor the client of this class can feed in Molecules without dealing with details of generating descriptors.

Parameters:
descrNames - output file names
types - class names of components
settings - parameter setting of component
Throws:
MDWriterException - in case of any failures

MDFileWriter

public MDFileWriter(java.lang.String[] descrNames,
                    java.lang.String[] types,
                    java.lang.String[] settings)
             throws MDWriterException
Creates and initialises a new MDFileWriter object that stores MDSets in the named text files component-wise. With this constructor the client of this class can feed in Molecules without dealing with details of generating descriptors.

Parameters:
descrNames - output file names
types - class names of components
settings - parameter setting of component
Throws:
MDWriterException - in case of any failures

MDFileWriter

public MDFileWriter(int nComponents)
Creates a new MDFileWriter object that stores MDSets that have the given number of components. Components have to be specified by calling setComponent().

Parameters:
nComponents - number of components of the MDSet to be written

MDFileWriter

public MDFileWriter(java.lang.String descrName,
                    java.lang.String type,
                    MDParameters settings)
             throws MDWriterException
Creates and initializes a new MDFileWriter object that stores MDSets in the named text file. Use this constructor when the MDSet has one component only.

Parameters:
descrName - output file name
type - class name of the descriptor
settings - parameter setting
Throws:
MDWriterException - in case of any failures

MDFileWriter

public MDFileWriter(java.lang.String descrName,
                    java.lang.String type,
                    java.lang.String settings)
             throws MDWriterException
Creates and initializes a new MDFileWriter object that stores MDSets in the named text file. Use this constructor when the MDSet has one component only.

Parameters:
descrName - output file name
type - class name of the descriptor
settings - parameter setting
Throws:
MDWriterException - in case of any failures

MDFileWriter

public MDFileWriter(java.lang.String SDfileName,
                    int nComponents)
Creates and initializes a new MDFileWriter object that stores MDSets in the named SDfile. Descriptors generated are also stored as readable strings in custom SDf tags. Components have to be specified by calling setComponent().

Parameters:
SDfileName - the name of the output SDFile
nComponents - number of components of the MDSet

MDFileWriter

public MDFileWriter(java.lang.String SDfileName,
                    java.lang.String[] descrNames,
                    java.lang.String[] types,
                    MDParameters[] settings)
Creates and initializes a new MDFileWriter object that stores MDSets in the named SDfile. Descriptors generated are also stored as readable strings in custom SDf tags. All components of the descriptor set is specified by type and parameter settings.

Parameters:
SDfileName - the name of the output SDFile
descrNames - output file names
types - class names of components
settings - parameter setting of component

MDFileWriter

public MDFileWriter(java.lang.String SDfileName,
                    java.lang.String[] descrNames,
                    java.lang.String[] types,
                    java.lang.String[] settings)
Creates and initializes a new MDFileWriter object that stores MDSets in the named SDfile. Descriptors generated are also stored as readable strings in custom SDf tags. All components of the descriptor set is specified by type and parameter settings.

Parameters:
SDfileName - the name of the output SDFile
descrNames - output file names
types - class names of components
settings - parameter settings strings
Method Detail

setDecimalOutputFormat

public void setDecimalOutputFormat(boolean decimalOutputFormat)
Sets decimal output format. In this format all descriptor cells are printed and separated by a comma.

Parameters:
decimalOutputFormat - indicates if decimal format is written

setBinaryOutputFormat

public void setBinaryOutputFormat(boolean binaryOutputFormat)
Sets binary output format. In this format all descriptor cells are printed as 0 and 1 if this makes sense (i.e for binary fingerprints only).

Parameters:
binaryOutputFormat - indicates if binary format is written
Since:
JChem 2.3

setComponent

public void setComponent(int index,
                         java.lang.String descrName,
                         java.lang.String type,
                         MDParameters settings)
Sets an individual MDSet component's type and corresponding parameters. Use this method, when descriptor tytpe have not been specified in the constructor.

Parameters:
index - index of the MDSet component
descrName - output file name
type - class name of the descriptor
settings - parameter setting

setComponent

public void setComponent(int index,
                         java.lang.String descrName,
                         java.lang.String type,
                         java.lang.String settings)
Sets an individual MDSet component's type and corresponding parameters. Use this method, when descriptor tytpe have not been specified in the constructor.

Parameters:
index - index of the MDSet component
descrName - output file name
type - class name of the descriptor
settings - parameters string

setPrintId

public void setPrintId(boolean printId)
Sets whether unique internal ID-s of structures have to be printed into the output table.

Parameters:
printId - unique id-s are printed or not

getMDParameters

public MDParameters getMDParameters(int id)
Gets the actual parameter settings of the specified component.

Specified by:
getMDParameters in class MDWriter
Parameters:
id - component index
Returns:
parameter settings
Since:
JChem 2.1

getMDSet

public MDSet getMDSet()
Gets the last molecular descriptor set generated and put into the output file.

Returns:
the most recent MDSet
Since:
JChem 2.3

put

public void put(MDSet ds)
         throws MDWriterException
Writes the given MDSet object into the output files as readable text.

Parameters:
ds - MDSet to be printed
Throws:
MDWriterException - inherited, never thrown

put

public void put(Molecule mol,
                int id)
         throws MDWriterException
Generates the MDSet object from the given molecular structure and writes result. The descriptors are either written into the descriptor output file (as readable text) or into an SDfile as tags. these two modes of operation depend on how the MDFileWriter object was created.

Specified by:
put in class MDWriter
Parameters:
mol - generate MDSet for this structure
id - the id of the descriptors in the output
Throws:
MDWriterException - inherited, never thrown

put

public void put(Molecule mol,
                java.lang.String naturalId)
         throws MDWriterException
Generates the MDSet for the given Molecule and writes the descriptors into the output with the given identifier. Note, that the mol parameter is not final, because descriptors generated are stored in this object (as properties).

Parameters:
mol - the Molecule object to be written
naturalId - unique identifier of the molecule as given on input
Throws:
MDWriterException - all exceptions (mainly io) are reinterpreted
Since:
JChem 2.0.1

close

public void close()
           throws MDWriterException
Closes the stream, after that no more operations are permitted.

Specified by:
close in class MDWriter
Throws:
MDWriterException