chemaxon.descriptors
Class MDFileReader

java.lang.Object
  extended by chemaxon.descriptors.MDReader
      extended by chemaxon.descriptors.MDFileReader

public class MDFileReader
extends MDReader

Reads MDSet objects from a text file. The input text file can either be a molecular structure file (for example SDfile, MOL file etc.) or it can be a molecular descriptor file written by MDFileWriter. In both cases an MDSet object created by the client of this class is build and returned by the reader methods. The two kinds of operation requires two different ways to create the MDFileReader object, see appropriate constructors.

Since:
JChem 2.0
Author:
Miklos Vargyas

Field Summary
 
Fields inherited from class chemaxon.descriptors.MDReader
cloneResult, firstId, generateDescriptor, generateId, id, idTagName, lastReadMolecule, mdSet, takeTags
 
Constructor Summary
MDFileReader(java.io.InputStream inputFile, MDSet mdSet)
          Creates and intializes a file reader that reads a molecular structure file.
MDFileReader(java.lang.String inputFileName)
          Creates and initialises a MDSet file reader for reading one single MolecularDescriptor.
MDFileReader(java.lang.String[] inputFileNames)
          Creates and initialises an MDSet file reader for reading multiple MolecularDescriptor components.
MDFileReader(java.lang.String inputFileName, MDSet mdSet)
          Creates and intializes a file reader that reads a molecular structure file.
 
Method Summary
 void close()
          Closes the reader.
 Molecule getMolecule()
          Gets the current molecular structure as read from the input file (that is before any transformation were applied).
 MDSet next()
          Reads the next MDSet object from the input source.
 void reset()
          Resets the stream.
 void setKeepOriginalMolecule(boolean keep)
          Sets if original molecule, as read from the input file, has to be saved or not.
 
Methods inherited from class chemaxon.descriptors.MDReader
createMDSetComponent, getCloneResult, getMDSet, setCloneResult, setFirstId, setGenerateId, setIdTagName, setTakeTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MDFileReader

public MDFileReader(java.lang.String inputFileName)
             throws chemaxon.descriptors.MDReaderException
Creates and initialises a MDSet file reader for reading one single MolecularDescriptor. This works for descriptor files written by MDFileWriter.

Parameters:
inputFileName - name of the descriptor input file
Throws:
chemaxon.descriptors.MDReaderException

MDFileReader

public MDFileReader(java.lang.String[] inputFileNames)
             throws chemaxon.descriptors.MDReaderException
Creates and initialises an MDSet file reader for reading multiple MolecularDescriptor components.

Parameters:
inputFileNames - input file names
Throws:
chemaxon.descriptors.MDReaderException

MDFileReader

public MDFileReader(java.lang.String inputFileName,
                    MDSet mdSet)
             throws chemaxon.descriptors.MDReaderException
Creates and intializes a file reader that reads a molecular structure file. Since the molecular structure file does not carry any information about the descriptors to be generated for molecules retrieved, an MDSet template has to be provided in this constructor. This has to be properly initialized (apparently, by default constructors) as this specifies what kind of descriptors are read from the molecule file.

Parameters:
inputFileName - name of the input molecular structure file
mdSet - sample Molecular Descriptor Set
Throws:
chemaxon.descriptors.MDReaderException

MDFileReader

public MDFileReader(java.io.InputStream inputFile,
                    MDSet mdSet)
             throws chemaxon.descriptors.MDReaderException
Creates and intializes a file reader that reads a molecular structure file. Since the molecular structure file does not carry any information about the descriptors to be generated for molecules retrieved, an MDSet template has to be provided in this constructor. This has to be properly initialized (apparently, by default constructors) as this specifies what kind of descriptors are read from the molecule file.

Parameters:
inputFile - input molecular structure file
mdSet - sample Molecular Descriptor Set
Throws:
chemaxon.descriptors.MDReaderException
Method Detail

setKeepOriginalMolecule

public void setKeepOriginalMolecule(boolean keep)
Sets if original molecule, as read from the input file, has to be saved or not. Saving the original is useful in the case when the original molecule has to be used in other parts of the application (for instance a typical need is to write back the molecule into an SDfile). The generation of MolecularDescriptor transforms the original structure. The opriginal molecule can be retrieved by getMolecule(). This method is applicable only if the input file is a molecular structure file.

Parameters:
keep - indicates if the original structure has to be preserved or not

getMolecule

public Molecule getMolecule()
                     throws chemaxon.descriptors.MDReaderException
Gets the current molecular structure as read from the input file (that is before any transformation were applied). Not all MDReader subclasses can implement this method in a meaningful way, therefore it is not an abstract method (just for the sake of ease).

Overrides:
getMolecule in class MDReader
Returns:
always null, see subclasses for meaningful implementation
Throws:
chemaxon.descriptors.MDReaderException

reset

public void reset()
           throws chemaxon.descriptors.MDReaderException
Resets the stream. The first call of next( MDSet cds ) after reset() reads the first line of the input stream.

Overrides:
reset in class MDReader
Throws:
chemaxon.descriptors.MDReaderException - when failed to reset the reader

next

public MDSet next()
           throws chemaxon.descriptors.MDReaderException
Reads the next MDSet object from the input source. The returned object is either reused or always a new instance is created depending on setCloneResult() settings.

Specified by:
next in class MDReader
Returns:
the descriptors read from the input source
Throws:
chemaxon.descriptors.MDReaderException - when file is corrupt

close

public void close()
           throws chemaxon.descriptors.MDReaderException
Closes the reader. No more operation is allowed on the reader after it has been closed.

Specified by:
close in class MDReader
Throws:
chemaxon.descriptors.MDReaderException - i/o errors are reinterpreted