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
Modifier and TypeFieldDescriptionprotected boolean
indicates if mdSet is cloned or not innext()
protected int
starting value of idprotected boolean
Generates descriptor from molecule if true, direct read otherwise.protected boolean
generate unique identifiersprotected int
unique identifier (ID) of the current element readprotected String
name of the tag in the SDfile input which stored the unique structure idprotected Molecule
the molecule last read from the structure tableprotected MDSet
the schema mdSet if descriptors are generated on-the-flynames of tags that have to be taken from the input Molecule -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
Closes down the descriptor stream.protected void
createMDSetComponent
(int i, String type, String settings) Creates and sets the given component of the internalMDSet
object of the given type and specified parameter settings.boolean
Gets 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 MDSet
next()
Reads the next element from the input and stores it in theMDSet
object passed as parameter.void
reset()
Initializes theMDSet
input stream.void
setCloneResult
(boolean cloneResult) Sets the cloning policy of thenext()
method.void
setFirstId
(int firstId) Sets the ID of the firstMDSet
.void
setGenerateId
(boolean generateId) Sets whether ID-s are generated or not.void
setIdTagName
(String tagName) Sets the name of the ID tag in the SDfile.void
setTakeTag
(int cdSetComponent, String tagName) Sets the tag name of aMDSet
component.
-
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 theMDSet
parameter passed.- Parameters:
mdSet
- a sampleMDSet
object 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 aMDSet
component. 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 theMDSet
tagName
- 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 returnedMDSet
objects 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
MDSet
object
-
reset
Initializes theMDSet
input 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 theMDSet
object passed as parameter. This method should be called by thenext( )
method of the derived class as the first statement. It clones the internalMDSet
instance if needed and increments the id (if id-s are generated).- Returns:
- the
MDSet
to 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 allMDReader
subclasses 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 internalMDSet
object of the given type and specified parameter settings.- Parameters:
i
- index of the componenttype
- class name of the componentsettings
- parameter settings- Throws:
MDParametersException
-