@PublicAPI public abstract class MDReader extends java.lang.Object
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.
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 )
.Modifier and Type | Field and Description |
---|---|
protected boolean |
cloneResult
indicates if mdSet is cloned or not in
next() |
protected int |
firstId
starting value of id
|
protected boolean |
generateDescriptor
Generates descriptor from molecule if true, direct read otherwise.
|
protected boolean |
generateId
generate unique identifiers
|
protected int |
id
unique identifier (ID) of the current element read
|
protected java.lang.String |
idTagName
name of the tag in the SDfile input which stored the unique structure id
|
protected Molecule |
lastReadMolecule
the molecule last read from the structure table
|
protected MDSet |
mdSet
the schema mdSet if descriptors are generated on-the-fly
|
protected java.util.List<java.lang.String> |
takeTags
names of tags that have to be taken from the input Molecule
|
Modifier | Constructor and Description |
---|---|
protected |
MDReader()
Creates an new, empty object.
|
protected |
MDReader(MDSet mdSet)
Creates a molecular structure file or database table reader.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes down the descriptor stream.
|
protected void |
createMDSetComponent(int i,
java.lang.String type,
java.lang.String settings)
Creates and sets the given component of the internal
MDSet
object of the given type and specified parameter settings. |
boolean |
getCloneResult()
Gets the current value of the cloning policy flag.
|
MDSet |
getMDSet()
Gets the molecular descriptor set.
|
Molecule |
getMolecule()
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 the
MDSet object passed as parameter. |
void |
reset()
Initializes the
MDSet input stream. |
void |
setCloneResult(boolean cloneResult)
Sets the cloning policy of the
next() method. |
void |
setFirstId(int firstId)
Sets the ID of the first
MDSet . |
void |
setGenerateId(boolean generateId)
Sets whether ID-s are generated or not.
|
void |
setIdTagName(java.lang.String tagName)
Sets the name of the ID tag in the SDfile.
|
void |
setTakeTag(int cdSetComponent,
java.lang.String tagName)
Sets the tag name of a
MDSet component. |
protected int id
protected int firstId
protected boolean generateId
protected boolean generateDescriptor
protected Molecule lastReadMolecule
protected MDSet mdSet
protected boolean cloneResult
next()
protected java.util.List<java.lang.String> takeTags
protected java.lang.String idTagName
protected MDReader(MDSet mdSet)
MDSet
parameter passed.mdSet
- a sample MDSet
object that defines what
should be read from the input sourceprotected MDReader()
public void setGenerateId(boolean generateId)
generateId
- ID-s are generated if true, otherwise ID-s are read
from the input sourcepublic void setTakeTag(int cdSetComponent, java.lang.String tagName)
MDSet
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.cdSetComponent
- index of a component of the MDSet
tagName
- name of the tag to take the value of the
descriptor frompublic void setIdTagName(java.lang.String tagName)
tagName
- name of the ID tagpublic void setFirstId(int firstId)
MDSet
. If not set, ID numeration
starts from 1.firstId
- value of the of the ID of the first MDSet
public void setCloneResult(boolean cloneResult)
next()
method. If set to true
returned MDSet
objects are new ones, otherswise always the
same object is reused and returned (typically, this is passed in the
constructor of the class derived from MDReader
).
By default, cloning policy is set to true. This is the safer option,
though it might result in slower operation.cloneResult
- indicates cloning behaviourpublic boolean getCloneResult()
public MDSet getMDSet()
MDSet
objectpublic void reset() throws MDReaderException
MDSet
input stream. If the stream
is not empty, the subsequent call to next( MDSet cds )
returns the first element.MDReaderException
- when failed to reset the readerpublic abstract MDSet next() throws MDReaderException
MDSet
object passed as parameter.
This method should be called by the next( )
method of the derived class as the first statement. It clones the
internal MDSet
instance if needed and increments the
id (if id-s are generated).MDSet
to be filled in with the next descriptorMDReaderException
- when failed reading the next descriptor setpublic Molecule getMolecule() throws MDReaderException
MDReader
subclasses can implement this method in a meaningful way, therefore it is
not an abstract method (just for the sake of ease).MDReaderException
- when failed reading the next descriptor setpublic abstract void close() throws MDReaderException
MDReaderException
- when failed to close the input streamprotected void createMDSetComponent(int i, java.lang.String type, java.lang.String settings) throws MDParametersException
MDSet
object of the given type and specified parameter settings.i
- index of the componenttype
- class name of the componentsettings
- parameter settingsMDParametersException