Class IteratingSMILESReader

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

public class IteratingSMILESReader extends DefaultIteratingChemObjectReader<IAtomContainer>
Iterating SMILES file reader. It allows to iterate over all molecules in the SMILES file, without being read into memory all. Suitable for very large SMILES files. These SMILES files are expected to have one molecule on each line. If a line could not be parsed and empty molecule is returned and the property BAD_SMILES_INPUT is set to the attempted input. The error is also logged.

For parsing each SMILES it still uses the normal SMILESReader.

Author:
Egon Willighagen <egonw@sci.kun.nl>
See Also:
Source code:
main
Belongs to CDK module:
smiles
Keywords:
file format, SMILES
Created on:
2004-12-16
  • Field Details

    • BAD_SMILES_INPUT

      public static final String BAD_SMILES_INPUT
      Store the problem input as a property.
      See Also:
  • Constructor Details

    • IteratingSMILESReader

      public IteratingSMILESReader(Reader in, IChemObjectBuilder builder)
      Constructs a new IteratingSMILESReader that can read Molecule from a given Reader.
      Parameters:
      in - The Reader to read from
      builder - The builder to use
      See Also:
    • IteratingSMILESReader

      public IteratingSMILESReader(InputStream in, IChemObjectBuilder builder)
      Constructs a new IteratingSMILESReader that can read Molecule from a given InputStream and IChemObjectBuilder.
      Parameters:
      in - The input stream
      builder - The builder
  • Method Details

    • getFormat

      public IResourceFormat getFormat()
      Get the format for this reader.
      Returns:
      An instance of SMILESFormat
    • hasNext

      public boolean hasNext()
      Checks whether there is another molecule to read.
      Returns:
      true if there are molecules to read, false otherwise
    • next

      public IAtomContainer next()
      Get the next molecule from the stream.
      Returns:
      The next molecule
    • close

      public void close() throws IOException
      Close the reader.
      Throws:
      IOException - if there is an error during closing
    • remove

      public void remove()
      Description copied from class: DefaultIteratingChemObjectReader
      File IO generally does not support removing of entries.
      Specified by:
      remove in interface Iterator<IAtomContainer>
      Overrides:
      remove in class DefaultIteratingChemObjectReader<IAtomContainer>
    • setReader

      public void setReader(Reader reader)
      Description copied from interface: IChemObjectReader
      Sets the Reader from which this ChemObjectReader should read the contents.
    • setReader

      public void setReader(InputStream reader)
      Description copied from interface: IChemObjectReader
      Sets the InputStream from which this ChemObjectReader should read the contents.