/***************************************************************************** * chiralify.c * * "It seems that I write a version of this program about once a year to * support somebody's 3-D database project, so here's a simple program to * do it. It uses the du_chiralify() function in libdu. * * See help at end of this file. * * Dave Weininger, DCIS, 6 Mar 1997 *****************************************************************************/ #include #include #include "dt_smiles.h" #define TRUE 1 #define FALSE 0 #define MX_SMILES 1000 /*============================================================================ * sayerrors() -- dump errors in message queue to stderr */ static void sayerrors(void) { dt_Handle sob, sos = dt_errors(DX_ERR_ERROR); dt_String str; dt_Integer lens; while (NULL_OB != (sob = dt_next(sos))) { str = dt_stringvalue(&lens, sob); if (str) fprintf(stderr, "%.*s\n", lens, str); dt_dealloc(sob); } dt_dealloc(sos); dt_errorclear(); } /*============================================================================ * main.c -- test du_chiralify(), get SMILES, show chiral isomers */ main(int ac, char *av[]) { dt_Handle mol, sos, sob; char *str, smi[MX_SMILES]; int lens, n; /*** Get SMILES from user. ***/ if (1 < ac) { fprintf(stderr, "%s -- exhaustive isomeric SMILES generation\n" "This program demonstrates the function du_chiralify().\n" "Enter a SMILES, see unspecified chiralities enumerated.\n" "No program options or arguments are used.\n" "Contributed by Dave Weininger, Daylight CIS, Mar 1997\n", *av); exit(1); } /*** Get SMILES from user. ***/ while (fgets(smi,1000,stdin)) { smi[strlen(smi)-1]='\0'; if (NULL_OB != (mol = dt_smilin(strlen(smi), smi))) { /*** Get sequence of SMILES of chiral isomers. ***/ sos = du_chiralify(mol); /*** Print isomers as numbered sequence of strings. ***/ if (NULL_OB == sos) { printf("No (additional) chiral isomers detected.\n"); } else { dt_reset(sos); for (n = 0; NULL_OB != (sob = dt_next(sos)); n++) { str = dt_stringvalue(&lens, sob); printf("%3d %.*s\n", n + 1, lens, str); dt_dealloc(sob); } dt_dealloc(sos); } } /*** Show error queue each time through. ***/ sayerrors(); } printf("\n%s exits.\n", *av); } /***************************************************************************** * chiralify EXAMPLES: * * Enter SMILES: CCO not chiral * No (additional) chiral isomers detected. * * Enter SMILES: CC(O)CC simple chirality * 1 CC[C@@H](C)O * 2 CC[C@H](C)O * * Enter SMILES: CC(O)(N)CC other simple chirality * 1 CC[C@@](C)(N)O * 2 CC[C@](C)(N)O * * Enter SMILES: CC=CC cis-trans * 1 C/C=C/C * 2 C/C=C\C * * Enter SMILES: C/C=C/[C@H](O)C fully-specified as trans,S * No (additional) chiral isomers detected. * * Enter SMILES: C/C=C/C(O)C fix trans DB, enumerate Th chirality * 1 C/C=C/[C@@H](C)O * 2 C/C=C/[C@H](C)O * * Enter SMILES: CC=C[C@H](O)C fix S-Th, enumerate DB orientations * 1 C/C=C/[C@@H](C)O * 2 C/C=C\[C@@H](C)O * * Enter SMILES: CC[C@H](CC)CC(O)C specified Th not chiral, * unspecified one * is * 1 CCC(CC)C[C@@H](C)O * 2 CCC(CC)C[C@H](C)O * * Enter SMILES: CC(O)C(O)CC two asymmetric Th centers * 1 CC[C@@H](O)[C@@H](C)O * 2 CC[C@@H](O)[C@H](C)O * 3 CC[C@H](O)[C@@H](C)O * 4 CC[C@H](O)[C@H](C)O * * Enter SMILES: CC(O)C(O)C simple meso compound * 1 C[C@@H](O)[C@@H](C)O * 2 C[C@@H](O)[C@H](C)O * 3 C[C@H](O)[C@H](C)O * * Enter SMILES: CC(O)C(O)C(O)C(O)C(O)C semi-symmetrical meso (22 of * 32 dist * inct) * 1 C[C@@H](O)[C@@H](O)C(O)[C@@H](O)[C@H](C)O * 2 C[C@@H](O)[C@@H](O)C(O)[C@H](O)[C@@H](C)O * 3 C[C@@H](O)[C@@H](O)C(O)[C@H](O)[C@H](C)O * 4 C[C@@H](O)[C@@H](O)[C@@H](O)[C@@H](O)[C@H](C)O * 5 C[C@@H](O)[C@@H](O)[C@@H](O)[C@H](O)[C@H](C)O * 6 C[C@@H](O)[C@@H](O)[C@H](O)[C@@H](O)[C@H](C)O * 7 C[C@@H](O)[C@@H](O)[C@H](O)[C@H](O)[C@H](C)O * 8 C[C@@H](O)[C@H](O)C(O)[C@@H](O)[C@@H](C)O * 9 C[C@@H](O)[C@H](O)C(O)[C@@H](O)[C@H](C)O * 10 C[C@@H](O)[C@H](O)C(O)[C@H](O)[C@@H](C)O * 11 C[C@@H](O)[C@H](O)C(O)[C@H](O)[C@H](C)O * 12 C[C@@H](O)[C@H](O)[C@@H](O)[C@@H](O)[C@H](C)O * 13 C[C@@H](O)[C@H](O)[C@@H](O)[C@H](O)[C@@H](C)O * 14 C[C@@H](O)[C@H](O)[C@@H](O)[C@H](O)[C@H](C)O * 15 C[C@@H](O)[C@H](O)[C@H](O)[C@@H](O)[C@H](C)O * 16 C[C@@H](O)[C@H](O)[C@H](O)[C@H](O)[C@@H](C)O * 17 C[C@@H](O)[C@H](O)[C@H](O)[C@H](O)[C@H](C)O * 18 C[C@H](O)[C@@H](O)C(O)[C@H](O)[C@H](C)O * 19 C[C@H](O)[C@H](O)C(O)[C@@H](O)[C@H](C)O * 20 C[C@H](O)[C@H](O)C(O)[C@H](O)[C@H](C)O * 21 C[C@H](O)[C@H](O)[C@@H](O)[C@H](O)[C@H](C)O * 22 C[C@H](O)[C@H](O)[C@H](O)[C@H](O)[C@H](C)O * * Enter SMILES: CC(O)C=CC(O)C two Th centers, one double bond, two * meso pa * irs * 1 C[C@@H](O)/C=C/[C@@H](C)O * 2 C[C@@H](O)/C=C/[C@H](C)O * 3 C[C@@H](O)/C=C\[C@@H](C)O * 4 C[C@@H](O)/C=C\[C@H](C)O * 5 C[C@H](O)/C=C/[C@H](C)O * 6 C[C@H](O)/C=C\[C@H](C)O * * Enter SMILES: CC(O)/C=C/C(O)C same as above but with double bond * fixed t * rans * 1 C[C@@H](O)/C=C/[C@@H](C)O * 2 C[C@@H](O)/C=C/[C@H](C)O * 3 C[C@H](O)/C=C/[C@H](C)O * * Enter SMILES: CC=C[C@H](O)C=CC partial specification illustrates * problem * 1 C/C=C/C(O)/C=C/C * 2 C/C=C/C(O)/C=C\C * 3 C/C=C/C(O)\C=C/C * 4 C/C=C\C(O)/C=C\C * *****************************************************************************/