3.3 Molecular File Formats

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 }

Listing:3.4 Setting oemolstream formats explicitly

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.


Table 3.1: File formats supported by OEChem
File Format Description Read? Write?
OEFormat::OEB New Style OEBinary Yes Yes
OEFormat::CAN Canonical SMILES Yes Yes
OEFormat::FASTA FASTA protein sequence Yes Yes
OEFormat::ISM Isomeric SMILES Yes Yes
OEFormat::MDL MDL Mol File Yes Yes
OEFormat::MF Molecular Formula (Hill order) No Yes
OEFormat::MOL2 Tripos Sybyl mol2 file Yes Yes
OEFormat::MOL2H Sybyl mol2 with explicit hydrogens Yes Yes
OEFormat::MOPAC MOPAC file format(s) Yes Yes
OEFormat::BIN Old Style OpenEye OEBinary Yes No
OEFormat::PDB Protein Databank PDB file Yes Yes
OEFormat::SDF MDL SD File Yes Yes
OEFormat::SMI Absolute SMILES Yes Yes
OEFormat::XYZ XMol XYZ format Yes Yes