Class IteratingSDFReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Iterator<IAtomContainer>, IChemObjectIO, IChemObjectReader, IIteratingChemObjectReader<IAtomContainer>

    public class IteratingSDFReader
    extends DefaultIteratingChemObjectReader<IAtomContainer>
    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");
     IteratingSDFReader reader = new IteratingSDFReader(
       new FileInputStream(sdfFile), DefaultChemObjectBuilder.getInstance()
     );
     while (reader.hasNext()) {
       IAtomContainer molecule = (IAtomContainer)reader.next();
     }
     
    Author:
    Egon Willighagen <egonw@sci.kun.nl>
    See Also:
    MDLV2000Reader, MDLV3000Reader
    Source code:
    main
    Belongs to CDK module:
    io
    Keywords:
    file format, MDL molfile, file format, SDF
    Created on:
    2003-10-19
    • Constructor Detail

      • IteratingSDFReader

        public IteratingSDFReader​(Reader in,
                                  IChemObjectBuilder builder)
        Constructs a new IteratingMDLReader that can read Molecule from a given Reader.
        Parameters:
        in - The Reader to read from
        builder - The builder
      • IteratingSDFReader

        public IteratingSDFReader​(InputStream in,
                                  IChemObjectBuilder builder)
        Constructs a new IteratingMDLReader that can read Molecule from a given InputStream.
        Parameters:
        in - The InputStream to read from
        builder - The builder
      • IteratingSDFReader

        public IteratingSDFReader​(InputStream in,
                                  IChemObjectBuilder builder,
                                  boolean skip)
        Constructs a new IteratingMDLReader that can read Molecule from a given a InputStream. This constructor allows specification of whether the reader will skip 'null' molecules. If skip is set to false and a broken/corrupted molecule is read the iterating reader will stop at the broken molecule. However if skip is set to true then the reader will keep trying to read more molecules until the end of the file is reached.
        Parameters:
        in - the InputStream to read from
        builder - builder to use
        skip - whether to skip null molecules
      • IteratingSDFReader

        public IteratingSDFReader​(Reader in,
                                  IChemObjectBuilder builder,
                                  boolean skip)
        Constructs a new IteratingMDLReader that can read Molecule from a given a Reader. This constructor allows specification of whether the reader will skip 'null' molecules. If skip is set to false and a broken/corrupted molecule is read the iterating reader will stop at the broken molecule. However if skip is set to true then the reader will keep trying to read more molecules until the end of the file is reached.
        Parameters:
        in - the Reader to read from
        builder - builder to use
        skip - whether to skip null molecules