Daylight Summer School 2002, June 5-7, Santa Fe, NM

Daylight Worksheet - Compiling cansmi.c --WITH HINTS

One good way to start learning Daylight Toolkit programming is to work from a simple existing program. If programming in C or Fortran, learning to compile and link, probably with a Makefile, is an essential skill. cansmi.c is a good first program because it links only to the SMILES Toolkit, and performs a simple yet useful function, to canonicalize SMILES.

  1. Before compiling cansmi.c, the following must have been done first by the Daylight administrator (user "thor"):

    % cd $DY_ROOT/contrib/src
    % make

    This creates the Daylight-user library and also installs the correct machine-dependent include file at $DY_ROOT/contrib/src/makefile_include.

    Note: In this course, if you are using a Daylight distribution on a shared server, this has already been done and is unnecessary.

  2. You should be logged in as user "mug". Create a self-named sub-directory, and if you wish, additional sub-directories to organize your work.

    % cd
    % pwd
    /home/mug
    % mkdir jane_doe
    % cd jane_doe
    % mkdir toolkit
    % cd toolkit

  3. Copy cansmi.c and its associated makefile to this directory:

    % cp $DY_ROOT/contrib/src/c/smiles/cansmi.c .
    % cp $DY_ROOT/contrib/src/c/smiles/makefile .

  4. Now compile cansmi.c:

    % make cansmi

  5. Test cansmi by entering the command and then a few SMILES:

    % cansmi
    OCC
    CCO
    etc.


Modifying cansmi.c

You have created a "development environment" in which cansmi.c can be modified and recompiled. Or, a new program could be created and compiled by modifying the makefile, which we will try in a subsequent exercise.

  1. Let's modify cansmi.c and recompile.

  2. Use the function dt_count() to determine the number of atoms and bonds in each molecule. With each SMILES, print these numbers.

    You could try adding...

      {
        int atomcount, bondcount;
        acount = dt_count(mol, TYP_ATOM);
        bcount = dt_count(mol, TYP_BOND);
        fprintf(stderr, "atomcount = %d; bondcount = %d...\n", acount, bcount);
      }
    

  3. Recompile as before and test.

Daylight Chemical Information Systems Inc.
support@daylight.com