2.2. Examples

Once the database is created, you can use many chemical functions. Here is a (very) short overview of the possibilities. The dataset used for this example can be freely obtained from the Chemical Structures Project.

2.2.1. Calculate the Molecular Weight

The computation of the molecular weight of a molecule is performed by the MOLWEIGHT() function. In the following example, the molecular weight of the amino acid glycine is calculated.

mysql> SELECT MOLWEIGHT(`3D_structures`.`molfile`)
    -> FROM `compounds`,`3D_structures`
    -> WHERE `compounds`.`name`='glycine'
    -> AND `compounds`.`id`=`3D_structures`.`compound_id`;
        -> 75.066600

2.2.2. Search a Substructure

The MATCH_SUBSTRUCT() function permits to find a substructure. In this example, we are looking for compounds containing a phenol group:

mysql> SELECT `compounds`.`name` 
    -> FROM `compounds`,`bin_structures`
    -> WHERE `compounds`.`id`=`bin_structures`.`compound_id`
    -> AND MATCH_SUBSTRUCT('[OH]c1ccccc1',`obserialized`);
    -> LIMIT 10;
+-----------------------------+
| name                        |
+-----------------------------+
| 2,3,4,5,6-Pentachlorophenol |
| 2,3-Dimethylphenol          |
| 2,4,6-Trichlorophenol       |
| 2,4-Dimethylphenol          |
| 2,5-Dimethylphenol          |
| 2,6-Dimethylphenol          |
| 2-Bromophenol               |
| 2-Chloro-5-methylphenol     |
| 2-Chlorophenol              |
| 2-Hydroxybenzaldehyde       |
+-----------------------------+
10 rows in set (0.02 sec)