Package org.openscience.cdk.io.iterator
Class IteratingSMILESReader
- java.lang.Object
-
- org.openscience.cdk.io.ChemObjectIO
-
- org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader<IAtomContainer>
-
- org.openscience.cdk.io.iterator.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 propertyBAD_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:
SMILESReader
- Source code:
- main
- Belongs to CDK module:
- smiles
- Keywords:
- file format, SMILES
- Created on:
- 2004-12-16
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openscience.cdk.io.IChemObjectReader
IChemObjectReader.Mode
-
-
Field Summary
Fields Modifier and Type Field Description static String
BAD_SMILES_INPUT
Store the problem input as a property.-
Fields inherited from class org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader
errorHandler, mode
-
-
Constructor Summary
Constructors Constructor Description IteratingSMILESReader(InputStream in, IChemObjectBuilder builder)
Constructs a new IteratingSMILESReader that can read Molecule from a given InputStream and IChemObjectBuilder.IteratingSMILESReader(Reader in, IChemObjectBuilder builder)
Constructs a new IteratingSMILESReader that can read Molecule from a given Reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the reader.IResourceFormat
getFormat()
Get the format for this reader.boolean
hasNext()
Checks whether there is another molecule to read.IAtomContainer
next()
Get the next molecule from the stream.void
remove()
File IO generally does not support removing of entries.void
setReader(InputStream reader)
Sets the InputStream from which this ChemObjectReader should read the contents.void
setReader(Reader reader)
Sets the Reader from which this ChemObjectReader should read the contents.-
Methods inherited from class org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader
accepts, handleError, handleError, handleError, handleError, setErrorHandler, setReaderMode
-
Methods inherited from class org.openscience.cdk.io.ChemObjectIO
addChemObjectIOListener, addSetting, addSettings, fireIOSettingQuestion, getIOSettings, getListeners, getSetting, getSetting, getSettings, hasSetting, removeChemObjectIOListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, 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
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
BAD_SMILES_INPUT
public static final String BAD_SMILES_INPUT
Store the problem input as a property.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 frombuilder
- The builder to use- See Also:
DefaultChemObjectBuilder
,SilentChemObjectBuilder
-
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 streambuilder
- The builder
-
-
Method Detail
-
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 interfaceIterator<IAtomContainer>
- Overrides:
remove
in classDefaultIteratingChemObjectReader<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.
-
-