Toolkit Tutorial: Programming Exercises


  1. Introduction
  2. Building Programs
  3. SMILES - Molecule
  4. SMILES - Reaction
  5. SMARTS - Pattern
  6. SMIRKS - Transform
  7. EXTRA CREDIT - Contrib Index

  1. Introduction
  2. In these exercises. you will explore freely available source code ("Contrib"). You will also write and compile some toolkit code that uses a...
      ... SMILES molecule.
      ... SMILES reaction.
      ... SMARTS pattern.
      ... SMIRKS transform.

  3. Compiling Source Code
  4. The main progran syntax should look something like this:

      #include "dt_smiles.h"
      #include "dt_smarts.h"
      
      int main() {
      
        /* toolkit code */
      
        return 0;
      }
      

    Place the portions of source code from the tutorial into the main syntax and compile and run the executable. Compare you output to the results shown in the SMARTS - Pattern and SMIRKS - Transform sections. To compile source code, use the following command:

      $ cc -o <filename> <filename>.c -I$DY_ROOT/include -L$DY_ROOT/lib -ldt_smarts -ldt_smiles
      

    Let's explore the "Contrib" code and write some new toolkit code that demonstrate the concepts discussed in this tutorial.

  5. SMILES - Molecule
  6. In the $DY_ROOT/contrib/src/c/smiles directory, browse the makefile and source code, especially for:

      cansmi
      showmf
      rings
      

    In the $DY_ROOT/contrib/src/c/smiles directory, browse the makefile and the source code.

    Exercise: Write a program to read SMILES in, write canonical SMILES out, and count the number of atoms, bonds, and cycles.

  7. SMILES - Reaction
  8. Exercise: Write a program to read SMILES in and determine if the input is a molecule or a reaction. Then, for molecules, stream the molecule for atoms and write their symbols. For reactions, stream the reaction for molecules and write their reaction role and canonical SMILES out.

  9. SMARTS - Pattern
  10. In the $DY_ROOT/contrib/src/c/smarts directory, browse the makefile and source code, especially for:

      smartsmatch
      

    Exercise: Write a program to read SMARTS in and perform a match against a target molecule or reaction. Stream the pathset for paths and stream the paths for atoms and write their unique identifiers.

  11. SMIRKS - Transform
  12. In the $DY_ROOT/contrib/src/c/transform directory, browse the makefile and the source code, especially for:

      tranfilter
      

    Exercise: Write a program to read SMIRKS in and perform a transformation on a sequence of molecules. Loop over the resulting sequence and write canonical SMILES out.

  13. EXTRA CREDIT - Contrib Index
  14. Create an HTML index of "Contrib" software by doing the following:

      $ cd $DY_ROOT/contrib
      $ make_index -html > index.html
      

    Open the above "index.html" file with a browser. There is a lot of "Contrib" software. Familarize yourself with the breadth of software. Try to locate "Contrib" code that does the following:

    • Identify ring systems in input structures.
    • Align 2D layout based on a SMARTS query.
    • Calculate polar surface area.

Next Section: Advanced Programming


Michael A. Kappler
Last modified: Wed Jun 2 14:13:36 MDT 2004