33.3 Programming Layers: The Deep and Twisted Path

In designing OEChem, we strove to provide a library which puts powerful algorithms in the hands of novice users without hand-cuffing the expert. For this reason, OEChem can at the same time seem trivial and overwhelming. There are often several ways to carry out certain tasks in OEChem each with its subtle advantages, which can benefit an experienced user. There are very few algorithms we have shied away from including in OEChem, and many of the methods are new, unique and powerful. This gives OEChem a very rich interface, yet to gain this efficiency and power OEChem may force you to think about problems in ways your are not accustomed to doing. We hope that you benefit from the experience. If you find that you cannot or it is difficult to carry out a task with OEChem, please contact us.

OEChem has several layers of interfaces to most of its functionality. There are "high-level" interfaces, which provide the user with an enormous amount of power with minimal code. This level is exemplified by the second code listing in the chapter "Reading and Writing Molecules" (see below). In this example, the functionality of the "babel" file-format conversion program is re-implemented in about 10 lines of code. While this is trivial to write and understand (maybe after you've finished the manual), it should not belie the fact that OEChem is carrying out an enormous amount of work under the surface.

A perhaps "mid-level" interface in OEChem is the generic data interface. Once you are familiar with OEChem's molecules, you may find that none of them are specifically tailored to your task. Rather than having to delve deeply into the molecule API and derive your own molecule for the task, you can simply extend the API of molecules at run-time to suite your needs. While this functionality is perhaps not for the first-day user, it certainly doesn't require a stout heart.

Finally, for advanced programmers, OEChem provides access to nearly all of the detailed control of our functions. OEChem molecules have a simple API which can be used to derived your own molecules. The free-function heavy API discussed above then lets you have access to much of OEChem's power without having to implement an enormous molecule API yourself. Similarly, many of the functions that are wrapped in high level functions (like the molecule readers and writers) are also available directly to the user at the low level. For instance, while you many use oemolostreams to write molecules to output, you can also use the OEWriteMDLFile functions for more direct access.

If you ever have difficulty implementing the functionality you desire with the OEChem interface you already know, look deeper. It will often be the case that a lower level function will allow you the control you are seeking.