MUG '98 - Weininger - clogp4 - example4

Example of object property use in clogp4 toolkit

dt_clogp4() returns all results as molecular properties. Basic results are returned in the molecular properties "cp4ver" (dt_String-valued version), "cp4err" (dt_Integer-valued error level) and "cp4val" (dt_Real-valued result). These are obtained in the normal toolkit manner, e.g.:

dt_String  version;
dt_Integer errlev, lenver, request = 0;
dt_Real    value;
...
errlev = dt_clogp4(fdb, mol, request);
...
value   = dt_real   (         mol, 6, "cp4val");
errlev  = dt_integer(         mol, 6, "cp4err");
version = dt_string (&lenver, mol, 6, "cp4ver");
...
printf("clogp4, ver %.*s: result %.3f, error level %d\n",
        lenver, version, value, errlev);

This interface is not much cleaner (representation-independent) than a conventional toolkit interface would be (e.g., separate dt_clogp_value(), dt_clogp_errlev(), dt_clogp_version() functions).

So what's the big deal?

The answer is that the same set of base functions may be used for communication of more sophisticated information. Furthermore, such communication can be done in a perfectly compatible manner. For instance, CLOGP3 writes a number of ASCII tables when given the appropriate request, e.g.,

+----------+------+----------------------------------------+----------+-------+
|  Class   | Type |    Log(P) Contribution Description     |  Comment | Value |
+----------+------+----------------------------------------+----------+-------+
|FRAGMENT  | # 1  |    Phosphonate                         |MEASURED  | -2.670|
|FRAGMENT  | # 2  |    Carbonyl                            |MEASURED  | -1.840|
|ISOLATING |CARBON|  4 Aliphatic isolating carbon(s)       |          |  0.780|
|EXFRAGMENT|HYDROG| 11 Hydrogen(s) on isolating carbons    |          |  2.497|
|EXFRAGMENT|BONDS |  4 chain and  0 alicyclic (net)        |          | -0.480|
|FRAGBRANCH|FRAG 1|  3 net bonds (out of  4) count.        |          | -0.570|
|PROXIMITY |Y-C-Y |  Frags  1 and  2: -.32 (-2.670+ -1.840)|          |  1.443|
+----------+------+----------------------------------------+----------+-------+
|RESULT    | v355 |All fragments measured                  |CLOGP355  | -0.840|
+----------+------+----------------------------------------+----------+-------+
CLOGP3 writes this ASCII (e.g., to a LUN): it's built right into the program. This sort of "lowest common denominator" output has a few things going for it (for one, it has worked for 15 years). Outside of U.S. government software, however, it's about the only program which does so.

Using object properties to detach computation from output, clogp4 "output" can be easily used to deliver simple modern tables (e.g., for HTML):

...
errlev = dt_clogp4(fdb, mol, CP4_REQ_TABLE2);
...
/*** Write Table 2 as an HTML table. ***/

if (NULL_OB != (table = dt_handle(mol, 7, "cp4tab2"))) {
  printf("<TABLE BORDER>\n");

  /*** Write title ("title" property of table) if available. ***/

  str = dt_string(&lens, table, 5, "title");
  if (str && lens) printf("<CAPTION>%.*s<CAPTION>\n", lens, str);

  /*** Table is a sequence of rows; rows are a sequence of cells. ***/

  while (row = 0; NULL_OB != (tabline = dt_next(table)); row++) {
    printf("<TR>\n");
    while (NULL_OB != (tabcell = dt_next(tabline))) {
      str = dt_stringvalue(lens, tabcell);
      if (NULL == str || 0 == lens) { str = " "; lens = 6; }
      printf("<%s>%.*s\n", (row ? "TD" : "TH"), lens, str);
    }
  }
  printf("</TABLE>\n");
}

Alternatively, utility functions can be used to write tables which are customized for lineprinter, PostScript, tab-delimited format, HTML, etc. For instance, sosos2htmltab() produces:

Table 2. clogp4 contribution summary
ClassTypeLog(P) Contribution DescriptionCommentValue
Fragment# 1PhosphonateMEASURED-2.670
Fragment# 2CarbonylMEASURED-1.840
Isolatingcarbon4 Aliphatic isolating carbon(s) 0.780
Exfragmenthydrogen11 Hydrogen(s) on isolating carbons 2.497
Exfragmentbonds4 chain and 0 alicyclic (net) -0.480
Fragbranchfragment 13 net bonds (out of 4) count.  -0.570
ProximityY-C-YFrags 1 and 2: -.32 (-2.670+ -1.840) 1.443
RESULT v355 All fragments measured CLOGP355 -0.840

So far we've just been doing what CLOGP3 already does, albeit in a more object-oriented manner. The real power of using object properties is that we can add functionality to computations without adding complexity to the computational API. For example, clogp4 optionally provides atomic contributions to computed hydrophobicity (aside: this is not the same idea as atomic hydrophobicity). Instead of inventing a new API call which returns the atomic values in a canonically ordered array (or some such scheme), atomic values are simply returned as the "cp4val" property of atoms. Here's an example of how they might be used:

...
errlev = dt_clogp4(fdb, mol, CP4_REQ_ATOMS);
...
printf("clogp4 results:\n");
version = dt_string (&lenver, mol, 6, "cp4ver");
printf("  clogp4 version ... %.*s\n", lenver, version);
printf("  error level ...... %.3f\n", dt_integer(mol, 6, "cp4err"));
printf("  molecular value ..  %d\n",  dt_real(mol, 6, "cp4val"));
printf("  atomic values:\n");
atoms = dt_stream(mol, TYP_ATOM);
while (i = 0; NULL_OB != (atom = dt_next(atoms)); i++)
  printf("  atom %3d: value %.3f\n", i+1, dt_real(atom, 6, "cp4val"));
dt_dealloc(atoms);
Such results might be usefully displayed as a coloring of a depiction. The point is that the way such data is used is of no concern to a property oriented clogp4 algorithm.

Table 2. clogp4 contribution summary
Class Type Log(P) Contribution Description Comment Value
Fragment # 1 ether measured -0.610
Fragment # 2 thiadiaza-2-one approximate -0.430
Fragment # 3 thiophosporothioate approximate 0.300
Isolating carbon 4 aliphatic isolating carbon(s)   0.780
Isolating carbon 1 aromatic isolating carbon(s)   0.130
Exfragment hydrogen 11 hydrogen(s) on isolating carbons   2.497
Exfragment bonds 4 chain and 0 alicyclic (net)   -0.480
Fragbranch fragment 3 3 net bonds (out of 4) count   -0.270
Proximity Y-C-Y fragments 2 and 3: -.32 (-0.430+ 0.300)   0.042
Electronic sigma-rho 1 potential interaction(s); 1.00 used within ring 0.450
Result v4.01 benzyl approximation used clogp401 2.409
LogPstar logpstar97 EPA-600/2-81-011   2.420
Residual v4.01 observed - calculated   +0.011


Daylight Chemical Information Systems, Inc.
info@daylight.com