Package chemaxon.descriptors
Class MDReader
java.lang.Object
chemaxon.descriptors.MDReader
- Direct Known Subclasses:
MDArrayReader,MDDBReader,MDFileReader
Base class definitions for
Each element read can either get a unique identifier (ID) from the source it comes from, or alternatively an ID can also be generated by the reader.
An
MDSet input streams.
Different descriptors types (as fingerprints, pharmacophore fingerprints)
are handled in the same, a transparent manner. Derived classes may differ
in the source of initial data they handle: standard molecular structure file,
chemical descriptor set file (written by an MDWrite derivative),
or database.
Each element read can either get a unique identifier (ID) from the source it comes from, or alternatively an ID can also be generated by the reader.
An
MDSet object is returned by the reader in each call. This set
can either be re-used or a new instance can be created. This behaviour is
determined by setCloneResult( boolean ).- Since:
- JChem 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanindicates if mdSet is cloned or not innext()protected intstarting value of idprotected booleanGenerates descriptor from molecule if true, direct read otherwise.protected booleangenerate unique identifiersprotected intunique identifier (ID) of the current element readprotected Stringname of the tag in the SDfile input which stored the unique structure idprotected Moleculethe molecule last read from the structure tableprotected MDSetthe schema mdSet if descriptors are generated on-the-flynames of tags that have to be taken from the input Molecule -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclose()Closes down the descriptor stream.protected voidcreateMDSetComponent(int i, String type, String settings) Creates and sets the given component of the internalMDSetobject of the given type and specified parameter settings.booleanGets the current value of the cloning policy flag.getMDSet()Gets the molecular descriptor set.Gets the current molecular structure as read from the input file (that is before any transformation were applied).abstract MDSetnext()Reads the next element from the input and stores it in theMDSetobject passed as parameter.voidreset()Initializes theMDSetinput stream.voidsetCloneResult(boolean cloneResult) Sets the cloning policy of thenext()method.voidsetFirstId(int firstId) Sets the ID of the firstMDSet.voidsetGenerateId(boolean generateId) Sets whether ID-s are generated or not.voidsetIdTagName(String tagName) Sets the name of the ID tag in the SDfile.voidsetTakeTag(int cdSetComponent, String tagName) Sets the tag name of aMDSetcomponent.
-
Field Details
-
id
protected int idunique identifier (ID) of the current element read -
firstId
protected int firstIdstarting value of id -
generateId
protected boolean generateIdgenerate unique identifiers -
generateDescriptor
protected boolean generateDescriptorGenerates descriptor from molecule if true, direct read otherwise. -
lastReadMolecule
the molecule last read from the structure table -
mdSet
the schema mdSet if descriptors are generated on-the-fly -
cloneResult
protected boolean cloneResultindicates if mdSet is cloned or not innext() -
takeTags
names of tags that have to be taken from the input Molecule -
idTagName
name of the tag in the SDfile input which stored the unique structure id
-
-
Constructor Details
-
MDReader
Creates a molecular structure file or database table reader. The reader generates descriptors from the molecule read according to theMDSetparameter passed.- Parameters:
mdSet- a sampleMDSetobject that defines what should be read from the input source
-
MDReader
protected MDReader()Creates an new, empty object.
-
-
Method Details
-
setGenerateId
public void setGenerateId(boolean generateId) Sets whether ID-s are generated or not. Generated ID-s are positive integers.- Parameters:
generateId- ID-s are generated if true, otherwise ID-s are read from the input source
-
setTakeTag
Sets the tag name of aMDSetcomponent. If the name is not null, the value of the tag is taken from an SDfile input, otherwise, or in the case when the tag named does not exists in the input file, the desciptor of the specified component is generated.- Parameters:
cdSetComponent- index of a component of theMDSettagName- name of the tag to take the value of the descriptor from
-
setIdTagName
Sets the name of the ID tag in the SDfile. Unique indentifier is read from that tag if exists, otherwise the value of the identifier is undefined.- Parameters:
tagName- name of the ID tag
-
setFirstId
public void setFirstId(int firstId) Sets the ID of the firstMDSet. If not set, ID numeration starts from 1.- Parameters:
firstId- value of the of the ID of the firstMDSet
-
setCloneResult
public void setCloneResult(boolean cloneResult) Sets the cloning policy of thenext()method. If set to true returnedMDSetobjects are new ones, otherswise always the same object is reused and returned (typically, this is passed in the constructor of the class derived fromMDReader). By default, cloning policy is set to true. This is the safer option, though it might result in slower operation.- Parameters:
cloneResult- indicates cloning behaviour
-
getCloneResult
public boolean getCloneResult()Gets the current value of the cloning policy flag.- Returns:
- indicator of cloning policy
-
getMDSet
Gets the molecular descriptor set. This method is provided in order to allow the used intervene into descriptor generation (for instance by overriding parameter settings).- Returns:
- the
MDSetobject
-
reset
Initializes theMDSetinput stream. If the stream is not empty, the subsequent call tonext( MDSet cds )returns the first element.- Throws:
MDReaderException- when failed to reset the reader
-
next
Reads the next element from the input and stores it in theMDSetobject passed as parameter. This method should be called by thenext( )method of the derived class as the first statement. It clones the internalMDSetinstance if needed and increments the id (if id-s are generated).- Returns:
- the
MDSetto be filled in with the next descriptor - Throws:
MDReaderException- when failed reading the next descriptor set
-
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).- Returns:
- always null, see subclasses for meaningful implementation
- Throws:
MDReaderException- when failed reading the next descriptor set
-
close
Closes down the descriptor stream. After this, no more operation is permitted on the stream.- Throws:
MDReaderException- when failed to close the input stream
-
createMDSetComponent
protected void createMDSetComponent(int i, String type, String settings) throws MDParametersException Creates and sets the given component of the internalMDSetobject of the given type and specified parameter settings.- Parameters:
i- index of the componenttype- class name of the componentsettings- parameter settings- Throws:
MDParametersException
-