ambit2.core.io
Class MyIteratingMDLReader

Package class diagram package MyIteratingMDLReader
java.lang.Object
  extended by org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader
      extended by ambit2.core.io.MyIteratingMDLReader
All Implemented Interfaces:
java.util.Iterator, org.openscience.cdk.io.IChemObjectIO, org.openscience.cdk.io.iterator.IIteratingChemObjectReader

public class MyIteratingMDLReader
extends org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader

Copied here (with corrections)until Bug 1758372 in CDK is fixed. Iterating MDL SDF reader. It allows to iterate over all molecules in the SD file, without reading them into memory first. Suitable for (very) large SDF files. For parsing the molecules in the SD file, it uses the MDLV2000Reader or MDLV3000Reader reader; it does not work for SDF files with MDL formats prior to the V2000 format.

Example use:

 File sdfFile = new File("../zinc-structures/ZINC_subset3_3D_charged_wH_maxmin1000.sdf");
 MyIteratingMDLReader reader = new MyIteratingMDLReader(
   new FileInputStream(sdfFile), DefaultChemObjectBuilder.getInstance()
 );
 while (reader.hasNext()) {
   IMolecule molecule = (IMolecule)reader.next();
 }
 
cdk.module io

See Also:
MDLV2000Reader, MDLV3000Reader

Constructor Summary
MyIteratingMDLReader(java.io.InputStream in, org.openscience.cdk.interfaces.IChemObjectBuilder builder)
          Contructs a new MyIteratingMDLReader that can read Molecule from a given InputStream.
MyIteratingMDLReader(java.io.Reader in, org.openscience.cdk.interfaces.IChemObjectBuilder builder)
          Contructs a new MyIteratingMDLReader that can read Molecule from a given Reader.
 
Method Summary
 void close()
           
 org.openscience.cdk.io.formats.IResourceFormat getFormat()
           
 boolean hasNext()
          Returns true if another IMolecule can be read.
 java.lang.Object next()
          Returns the next IMolecule.
 void remove()
           
 
Methods inherited from class org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader
accepts, addChemObjectIOListener, fireFrameRead, fireIOSettingQuestion, getIOSettings, removeChemObjectIOListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyIteratingMDLReader

public MyIteratingMDLReader(java.io.Reader in,
                            org.openscience.cdk.interfaces.IChemObjectBuilder builder)
Contructs a new MyIteratingMDLReader that can read Molecule from a given Reader.

Parameters:
in - The Reader to read from

MyIteratingMDLReader

public MyIteratingMDLReader(java.io.InputStream in,
                            org.openscience.cdk.interfaces.IChemObjectBuilder builder)
Contructs a new MyIteratingMDLReader that can read Molecule from a given InputStream.

Parameters:
in - The InputStream to read from
Method Detail

getFormat

public org.openscience.cdk.io.formats.IResourceFormat getFormat()

hasNext

public boolean hasNext()
Returns true if another IMolecule can be read.


next

public java.lang.Object next()
Returns the next IMolecule.


close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

remove

public void remove()
Specified by:
remove in interface java.util.Iterator
Overrides:
remove in class org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader