chapter 7

Computer Representations Of Molecular Structures

There are many ways to represent molecular structures. A drawing is perhaps the most common and useful. It is easy to store drawings of molecules in a computer, but a stored drawing does not constitute a useful computer representation. What is needed is a computer representation that allows structures to be stored and searched in chemically useful and meaningful ways. This is sometimes accomplished by storing a connection table containing atom and bond information. Additionally, 2- or 3-dimensional coordinates are often stored. These data can be stored in files or data structures in some computer language. This chapter introduces ways of representing molecular structures that take advantage of the relational model of data in a RDBMS. [view wordle] [hide wordle]

Insert Into structures (cansmi) Values cansmiles('CC(O)C');
Select smiles, smiles_to_molfile(smiles) from atable;
Create Domain smiles As Text Check (valid(Value));
Create Table atable (id Integer, smi smiles, mw Numeric);
Create Table atable ( id Integer, smi Text Check(valid(smi)) );
Create Domain cansmiles As Text Check (cansmiles(Value)=Value);
Create Table ctable (id Integer, cansmi cansmiles, formula Text);
Create Table ctable (id Integer, cansmi Text Check (cansmi=cansmiles(cansmi)), formula Text);
Create Function canonicalize() Returns Trigger As $EOSQL$
    cansmi Text;
    cansmi = cansmiles(NEW.cansmi);
    If cansmi != NEW.cansmi Then
      NEW.cansmi = cansmi;
    End If;
    Return NEW;
$EOSQL$ Language plpgsql;
Create Trigger canonicalize Before Insert Or Update On ctable
 For Each Row Execute Procedure canonicalize();