Package chemaxon.descriptors
Class MDFileReader
java.lang.Object
chemaxon.descriptors.MDReader
chemaxon.descriptors.MDFileReader
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
-
Field Summary
Fields inherited from class chemaxon.descriptors.MDReader
cloneResult, firstId, generateDescriptor, generateId, id, idTagName, lastReadMolecule, mdSet, takeTags -
Constructor Summary
ConstructorsConstructorDescriptionMDFileReader(InputStream inputFile, MDSet mdSet) Creates and intializes a file reader that reads a molecular structure file.MDFileReader(String inputFileName) Creates and initialises aMDSetfile reader for reading one singleMolecularDescriptor.MDFileReader(String[] inputFileNames) Creates and initialises anMDSetfile reader for reading multipleMolecularDescriptorcomponents.MDFileReader(String inputFileName, MDSet mdSet) Creates and intializes a file reader that reads a molecular structure file. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the reader.Gets the current molecular structure as read from the input file (that is before any transformation were applied).next()Reads the nextMDSetobject from the input source.voidreset()Resets the stream.voidsetKeepOriginalMolecule(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
-
Constructor Details
-
MDFileReader
Creates and initialises aMDSetfile reader for reading one singleMolecularDescriptor. This works for descriptor files written byMDFileWriter.- Parameters:
inputFileName- name of the descriptor input file- Throws:
MDReaderException- if the record couldn't be read.
-
MDFileReader
Creates and initialises anMDSetfile reader for reading multipleMolecularDescriptorcomponents.- Parameters:
inputFileNames- input file names- Throws:
MDReaderException- if the record couldn't be read.
-
MDFileReader
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, anMDSettemplate 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 filemdSet- sample Molecular Descriptor Set- Throws:
MDReaderException- if the record couldn't be read.
-
MDFileReader
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, anMDSettemplate 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 filemdSet- sample Molecular Descriptor Set- Throws:
MDReaderException- if the record couldn't be read.
-
-
Method Details
-
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 ofMolecularDescriptortransforms the original structure. The opriginal molecule can be retrieved bygetMolecule(). 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
Gets the current molecular structure as read from the input file (that is before any transformation were applied). Not allMDReadersubclasses can implement this method in a meaningful way, therefore it is not an abstract method (just for the sake of ease).- Overrides:
getMoleculein classMDReader- Returns:
- always null, see subclasses for meaningful implementation
- Throws:
MDReaderException- when failed reading the next descriptor set
-
reset
Resets the stream. The first call ofnext( MDSet cds )afterreset()reads the first line of the input stream.- Overrides:
resetin classMDReader- Throws:
MDReaderException- when failed to reset the reader
-
next
Reads the nextMDSetobject from the input source. The returned object is either reused or always a new instance is created depending onsetCloneResult()settings.- Specified by:
nextin classMDReader- Returns:
- the descriptors read from the input source
- Throws:
MDReaderException- when file is corrupt
-
close
Closes the reader. No more operation is allowed on the reader after it has been closed.- Specified by:
closein classMDReader- Throws:
MDReaderException- i/o errors are reinterpreted
-