Programming ExercisesTable of Contents
2. Building Programs 3. SMILES - Molecule 4. SMILES - Reaction 5. SMARTS - Pattern 6. SMIRKS - Transform 7. EXTRA CREDIT - Contrib Index 1. Introduction
2. Compiling Source CodeThe 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. 3. SMILES - MoleculeIn 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.
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.
5. SMARTS - PatternIn 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. 6. SMIRKS - TransformIn 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. 7. EXTRA CREDIT - Contrib IndexCreate 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:
Align 2D layout based on a SMARTS query. Calculate polar surface area. |