org.openscience.cdk.io
Class MDLReader

java.lang.Object
  extended by org.openscience.cdk.io.ChemObjectIO
      extended by org.openscience.cdk.io.DefaultChemObjectReader
          extended by org.openscience.cdk.io.MDLReader
All Implemented Interfaces:
Closeable, IChemObjectIO, IChemObjectReader, ISimpleChemObjectReader

@TestClass(value="org.openscience.cdk.io.MDLReaderTest")
public class MDLReader
extends DefaultChemObjectReader

Reads a molecule from the original MDL MOL or SDF file [Dalby, A. and Nourse, J. G. and Hounshell, W. D. and Gushurst, A. K. and Grier, D. L. and Leland, B. A. and Laufer, J., Description of Several Chemical Structure File Formats Used by Computer Programs Developed at Molecular Design Limited, Journal of Chemical Information and Computer Sciences, 1992, 32:244-255]. An SD files is read into a IChemSequence of IChemModel's. Each ChemModel will contain one Molecule. If the MDL molfile contains a property block, the MDLV2000Reader should be used.

If all z coordinates are 0.0, then the xy coordinates are taken as 2D, otherwise the coordinates are read as 3D.

The title of the MOL file is read and can be retrieved with:

   molecule.getProperty(CDKConstants.TITLE);
 

Author:
steinbeck, Egon Willighagen
See Also:
MDLV2000Reader
Keywords:
file format, MDL molfile, file format, SDF
Created on:
2000-10-02
Belongs to CDK module:
io
Source code:
cdk-1.4.x

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openscience.cdk.io.IChemObjectReader
IChemObjectReader.Mode
 
Constructor Summary
MDLReader()
           
MDLReader(InputStream in)
          Constructs a new MDLReader that can read Molecule from a given InputStream.
MDLReader(InputStream in, IChemObjectReader.Mode mode)
           
MDLReader(Reader in)
          Constructs a new MDLReader that can read Molecule from a given Reader.
MDLReader(Reader in, IChemObjectReader.Mode mode)
           
 
Method Summary
 boolean accepts(Class classObject)
          Returns whether the given IChemObject can be read or written.
 void close()
          Closes this IChemObjectIO's resources.
 void customizeJob()
           
 IResourceFormat getFormat()
          Returns the IResourceFormat class for this IO class.
<T extends IChemObject>
T
read(T object)
          Takes an object which subclasses IChemObject, e.g.
 void setReader(InputStream input)
          Sets the InputStream from which this ChemObjectReader should read the contents.
 void setReader(Reader input)
          Sets the Reader from which this ChemObjectReader should read the contents.
 
Methods inherited from class org.openscience.cdk.io.DefaultChemObjectReader
handleError, handleError, handleError, handleError, setErrorHandler, setReaderMode
 
Methods inherited from class org.openscience.cdk.io.ChemObjectIO
addChemObjectIOListener, addSetting, addSettings, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openscience.cdk.io.IChemObjectIO
addChemObjectIOListener, addSetting, addSettings, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
 

Constructor Detail

MDLReader

public MDLReader()

MDLReader

public MDLReader(InputStream in)
Constructs a new MDLReader that can read Molecule from a given InputStream.

Parameters:
in - The InputStream to read from

MDLReader

public MDLReader(InputStream in,
                 IChemObjectReader.Mode mode)

MDLReader

public MDLReader(Reader in)
Constructs a new MDLReader that can read Molecule from a given Reader.

Parameters:
in - The Reader to read from

MDLReader

public MDLReader(Reader in,
                 IChemObjectReader.Mode mode)
Method Detail

getFormat

@TestMethod(value="testGetFormat")
public IResourceFormat getFormat()
Description copied from interface: IChemObjectIO
Returns the IResourceFormat class for this IO class.


setReader

@TestMethod(value="testSetReader_Reader")
public void setReader(Reader input)
               throws CDKException
Description copied from interface: IChemObjectReader
Sets the Reader from which this ChemObjectReader should read the contents.

Throws:
CDKException

setReader

@TestMethod(value="testSetReader_InputStream")
public void setReader(InputStream input)
               throws CDKException
Description copied from interface: IChemObjectReader
Sets the InputStream from which this ChemObjectReader should read the contents.

Throws:
CDKException

accepts

@TestMethod(value="testAccepts")
public boolean accepts(Class classObject)
Description copied from interface: IChemObjectIO
Returns whether the given IChemObject can be read or written.

Parameters:
classObject - IChemObject of which is tested if it can be handled.
Returns:
true, if the IChemObject can be handled.

read

public <T extends IChemObject> T read(T object)
                           throws CDKException
Takes an object which subclasses IChemObject, e.g. Molecule, and will read this (from file, database, internet etc). If the specific implementation does not support a specific IChemObject it will throw an Exception.

Parameters:
object - The object that subclasses IChemObject
Returns:
The IChemObject read
Throws:
CDKException

close

@TestMethod(value="testClose")
public void close()
           throws IOException
Description copied from interface: IChemObjectIO
Closes this IChemObjectIO's resources.

Throws:
IOException

customizeJob

public void customizeJob()