3import java.io.BufferedReader;
5import java.io.FileInputStream;
6import java.io.FileNotFoundException;
7import java.io.FileReader;
8import java.io.IOException;
9import java.util.Iterator;
12import org.openscience.cdk.DefaultChemObjectBuilder;
13import org.openscience.cdk.exception.CDKException;
14import org.openscience.cdk.interfaces.IAtomContainer;
15import org.openscience.cdk.io.FormatFactory;
16import org.openscience.cdk.io.formats.IChemFormat;
17import org.openscience.cdk.io.formats.MDLV2000Format;
18import org.openscience.cdk.io.formats.MDLV3000Format;
19import org.openscience.cdk.io.iterator.DefaultIteratingChemObjectReader;
20import org.openscience.cdk.io.iterator.IteratingSDFReader;
21import org.openscience.cdk.io.iterator.IteratingSMILESReader;
52 private DefaultIteratingChemObjectReader<IAtomContainer>
fileIterator;
71 throws FileNotFoundException, IOException, CDKException
73 FormatFactory factory =
new FormatFactory();
76 BufferedReader headReader =
new BufferedReader(
new FileReader(input));
77 IChemFormat chemFormat = factory.guessFormat(headReader);
80 if (chemFormat instanceof MDLV2000Format
81 || chemFormat instanceof MDLV3000Format)
83 FileInputStream fis =
new FileInputStream(input);
85 DefaultChemObjectBuilder.getInstance());
89 FileInputStream fis =
new FileInputStream(input);
91 DefaultChemObjectBuilder.getInstance());
128 public void close() throws IOException
Utility methods for input/output.
static List< IAtomContainer > readAllAtomContainers(File file)
Returns a single collection with all atom containers found in a file of any format.
An iterator that take IAtomContainers from a file, possibly using an available iterating reader,...
DefaultIteratingChemObjectReader< IAtomContainer > fileIterator
Reference to the memory-efficient iterator, or null if we have had to pre-load all containers.
Iterator< IAtomContainer > listIterator
Reference to the iterator over pre-loaded containers or null if we use the memory-efficient iterator ...
Class<?> getIteratorType()
IteratingAtomContainerReader(File input)
Constructs an iterator over the containers that can be found in the given file.
List< IAtomContainer > results
The containers loaded in memory, or null if we use an Iterator.
void close()
Close the memory-efficient iterator if any is open.
boolean usingIteratingReader
Flag indicating whether we are using a memory-efficient iterator (true of id we have had to pre-load ...