org.openscience.cdk.io.iterator
Class IteratingSMILESReader

java.lang.Object
  extended by org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader
      extended by org.openscience.cdk.io.iterator.IteratingSMILESReader
All Implemented Interfaces:
Iterator, IChemObjectIO, IChemObjectReader, IIteratingChemObjectReader

@TestClass(value="org.openscience.cdk.io.iterator.IteratingSMILESReaderTest")
public class IteratingSMILESReader
extends DefaultIteratingChemObjectReader

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.

For parsing each SMILES it still uses the normal SMILESReader.

Author:
Egon Willighagen
See Also:
SMILESReader
Keywords:
file format, SMILES
Created on:
2004-12-16
Belongs to CDK module:
smiles
Source code:
HEAD

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openscience.cdk.io.IChemObjectReader
IChemObjectReader.Mode
 
Constructor Summary
IteratingSMILESReader(InputStream in)
          Constructs a new IteratingSMILESReader that can read Molecule from a given InputStream.
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
 void close()
          Close the reader.
 IResourceFormat getFormat()
          Get the format for this reader.
 boolean hasNext()
          Checks whether there is another molecule to read.
 IChemObject 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, addChemObjectIOListener, getIOSettings, handleError, handleError, handleError, handleError, removeChemObjectIOListener, setErrorHandler, setReaderMode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratingSMILESReader

@TestMethod(value="testSMILESFileWithNames")
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:
DefaultChemObjectBuilder, NoNotificationChemObjectBuilder

IteratingSMILESReader

@TestMethod(value="testSMILESFileWithNames")
public IteratingSMILESReader(InputStream in)
Constructs a new IteratingSMILESReader that can read Molecule from a given InputStream. This method will use @link{DefaultChemObjectBuilder} to build the actual molecules

Parameters:
in - The InputStream to read from

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 Detail

getFormat

@TestMethod(value="testGetFormat")
public IResourceFormat getFormat()
Get the format for this reader.

Returns:
An instance of SMILESFormat

hasNext

@TestMethod(value="testSMILESFileWithNames,testSMILESFileWithSpacesAndTabs,testSMILESTitles,testSMILESFile")
public boolean hasNext()
Checks whether there is another molecule to read.

Returns:
true if there are molecules to read, false otherwise

next

@TestMethod(value="testSMILESFileWithNames,testSMILESFileWithSpacesAndTabs,testSMILESTitles,testSMILESFile")
public IChemObject next()
Get the next molecule from the stream.

Returns:
The next molecule

close

@TestMethod(value="testSMILESFileWithNames,testSMILESFileWithSpacesAndTabs,testClose")
public void close()
           throws IOException
Close the reader.

Throws:
IOException - if there is an error during closing

remove

@TestMethod(value="testRemove")
public void remove()
Description copied from class: DefaultIteratingChemObjectReader
File IO generally does not support removing of entries.

Specified by:
remove in interface Iterator
Overrides:
remove in class DefaultIteratingChemObjectReader

setReader

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


setReader

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