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 oemolstreams to
convert MDL SD files into Tripos MOL2 files using oemolstream
iterators.
1 #include "openeye.h"
2 #include "oechem.h"
3
4 using namespace OEChem;
5 using namespace OESystem;
6
7 int main()
8 {
9 OEIter<OEMolBase> mol;
10 oemolistream ims;
11 oemolostream oms;
12
13 ims.SetFormat(OEFormat::SDF);
14 oms.SetFormat(OEFormat::MOL2);
15 for (mol=ims.GetMolBases(); mol; ++mol)
16 oms << mol;
17 return 0;
18 }
The file formats supported by OEChem are listed in Table 3.1.
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.
|