oemolistream

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:

ClearCSVHeader

GetFlavor

SetFormat

GetBinaryIOHandler

GetFormat

close

GetCSVHeader

Getgz

open

GetFileName

SetFlavor

Constructors

oemolistream()

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.

Warning

Only in C++ can an oemolistream object own an existing oeistream object.

See also

To associate a file or a stream with an oemolistream after it has been created, see the oemolstreambase::open method.

operator bool

operator bool() const

operator OEPlatform::oeistream &

operator OEPlatform::oeistream &() const

GetConfTest

OEConfTestBase &GetConfTest() const

GetMCMolBases

OESystem::OEIterBase<OEChem::OEMCMolBase> *GetMCMolBases(bool single=false)

GetMolBases

OESystem::OEIterBase<OEChem::OEMolBase> *GetMolBases()

GetReadFailureCt

unsigned GetReadFailureCt() const

IncrementReadFailureCt

void IncrementReadFailureCt()

ResetReadFailureCt

void ResetReadFailureCt()

SetConfTest

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).

SetFlavor

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 in the 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 call the OESetDefaultFlavors function to set the flavors for all of the formats to their default state.

SetFormat

bool SetFormat(unsigned int format)

Sets the file format associated with the oemolistream object. The set of valid formats are defined in the 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.

Note

The file format property is also set automatically by oemolstreambase::open based upon the file extension of the specified filename.

SetTracer

bool SetTracer(OESystem::OETracerBase *tracer, bool owntracer)

Registers the tracer, tracer, to report the current progress of the oemolistream object on reading molecules. The second optional argument is used to indicate whether the oemolistream now owns the given OETracerBase object and is therefore responsible for closing and destroying it when it itself is closed and/or destroyed.

Warning

Only in C++ can an oemolistream object own an existing OETracerBase object.

See also

Setgz

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.

close

void close()

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.

eof

bool eof() const

getbyte

int getbyte()

getline

bool getline(char *buffer, oesize_t max)

openstring

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.

Note

Prior to calling oemolistream::openstring it is necessary to specify the format and whether or not the format is compressed with gzip. These can be set with the oemolistream::SetFormat and oemolistream::Setgz methods respectively.

peekbyte

int peekbyte()

read

bool read(unsigned char *buffer, oesize_t len)

rewind

void rewind()

seek

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.

size

oefpos_t size()

Returns the size of the input stream if applicable to the current stream. The return type is a portable file-system pointer type.

skip

bool skip(oefpos_t len)

skipbyte

bool skipbyte()

skipline

bool skipline()

tell

oefpos_t tell()

Returns the current position of the next read. This function accounts for molecular caching.

Note

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.