class oemolistream : public oemolstreambase
The oemolistream class provides a stream-like abstraction for reading molecules from files, strings or standard input. The oemolistream maintains the format and flavor of molecular reading for the stream. It also manages the conversion between multi-conformer molecules and single conformer molecules in cases where the molecule read into is not compatible with the file format (in the sense of a multi-conformer file format being read into a single-conformer molecule, or a single-conformer file format being read into a multi-conformer molecule). The oemolistream is capable of uncompressing gzip files while reading.
The following methods are publicly inherited from oemolstreambase:
Default constructor. Creates a new oemolistream object that is connected to the standard input.
oemolistream(const char *fname) oemolistream(const std::string &fname)
Creates a new oemolistream object and opens the file specified by the given name (‘fname’).
oemolistream(OEPlatform::oeistream *, bool owned=true)
Creates a new oemolistream object from an existing oeistream object. The second optional argument is used to indicate whether the new oemolistream now owns the given oeistream and is therefore responsible for closing and destroying it when it itself is closed and/or destroyed.
operator bool() const
operator OEPlatform::oeistream &() const
OEConfTestBase &GetConfTest() const
GetOEMols() -> <generator of OEMol objects>
Returns a generator over all the molecules in the file or stream. Each molecule will be an OEMol object.
OESystem::OEIterBase<OEChem::OEMCMolBase> *GetMCMolBases(bool single=false)
unsigned GetReadFailureCt() const
bool HasNextMol() const
void PushNextMol(OEMolBase *mol, oefpos_t pos=0)
bool SetConfTest(const OEConfTestBase &)
Sets the functor class which is used to compare incoming graphs to determine whether they should be placed as conformers of a multi-conformer molecule or be returned individually as single molecules. The default conformer test never places separate graphs into a multi-conformer molecule (OEDefaultConfTest).
bool SetFlavor(unsigned int format, unsigned int flavor)
Sets the file flavor for a given format associated with the oemolistream object. The set of valid formats are defined int the OEFormat namespace. The set of valid bitmasks flavors are defined in the OEIFlavor namespace. The current flavor can be queried using the oemolstreambase.GetFlavor method. Each format has its own specific flavor which must be set separately. The oemolistream constructors set the flavors for all of the formats to their default state.
bool SetFormat(unsigned int format)
Sets the file format associated with the oemolistream object. The set of valid formats are defined in the OEFormat namespace. By default, when reading from standard input, the associated file format is OEFormat_SMI. The file format property of an oemolistream may be retrieved using the oemolstreambase.GetFormat method.
The file format property is also set automatically by oemolstreambase.open based upon the file extension of the specified filename.
bool SetTracer(OESystem::OETracerBase *tracer, bool owntracer)
bool Setgz(bool gz, OEPlatform::oeistream *sptr=0, bool owned=false)
Specifies that the contents of the oemolistream object are to be treated as compressed by GNU gzip compressed. The decompression takes place on-the-fly. Usually the ‘gz’ property of a oemolistream object is determined implicitly from the file extension used to open the stream for reading. The current ‘gz’ property of the oemolistream object can be retrieved using the oemolstreambase.Getgz method.
Closes the oemolistream object. This method may be safely called multiple times. However oemolistream.close method is called from within the oemolistream destructor and therefore it is not necessary to call this explicitly under most circumstances.
bool eof() const
bool getline(char *buffer, oesize_t max)
bool openstring(const std::string &str) bool openstring(const unsigned char *buffer, oesize_t len)
Allows the oemolistream to read from a buffer in memory, instead of from a file or standard input.
Internally, the oemolistream.openstring method make a copy of the specified file contents, allowing the oemolistream to continue to function independently of whether the original buffer is later modified or deallocated.
bool read(unsigned char *buffer, oesize_t len)
void seek(oefpos_t pos)
Moves the position of the next valid read to the position indicated. This function takes account of gzip streams and molecule caching.
Returns the size of the input stream if applicable to the current stream. The return type is a portable file-system pointer type.
bool skip(oefpos_t len)
Returns the current position of the next read. This function accounts for molecular caching.
If you are reading an .oeb file that was written as multi-conformer molecules and is being read with single conformer molecules, all of the conformers are read into cache at once, and the pointer will point to the beginning of a multi-conformer molecule rather than to a conformer inside a molecule.