In addition to SMILES strings, OEChem is able to read numerous other
molecular file formats, including MDL SD files, Tripos Mol2 files and PDB
files. The format of an input file or stream may be associated with an
oemolistream
using the SetFormat
method, and may be retrieved
with GetFormat
. These take an unsigned integer representing the
file format, which should be one of the constants defined in the
OEFormat
namespace. A value of OEFormat::UNDEFINED
(zero)
means that there is no file format associated with the oemolstream
.
The following example demonstrates how to use oemolstream
s to
convert MDL SD files into Tripos Mol2 files using oemolstream
iterators.
#include "oechem.h" using namespace OEChem; using namespace OESystem; int main() { OEIter<OEMolBase> mol; oemolistream ims; oemolostream oms; ims.SetFormat(OEFormat::SDF); oms.SetFormat(OEFormat::MOL2); for (mol=ims.GetMolBases(); mol; ++mol) oms << mol; return 0; }
The following file formats are supported by OEChem.
The default format for input oemolstreams is OEFormat::SMI
.
In most cases, the SetFormat
method should only be called on an
input oemolstream
before the first connection table is read.