Python-Ref > Cheminformatics > OpenBabel > Chirality perception
 
 

<-^^->
Klíčová slova
Moduly
Knihovní funkce

Chirality perception

Sometimes we need to find out if a molecule is chiral and which atoms are chiral centers. Openbabel allows us to do this, however we need to be aware of some limitations. If we give openbabel a molecule which has an asymmetric carbon atom, but has no stereochemistry given on input and not atomic coordinates, it will tell us that the molecule is not chiral. Only after we add hydrogens to the molecule, does openbabel perceive the molecule as chiral.
Expand/Shrink
Zdroj: (babel9-1.py)
  1   import pybel
  2   
  3   # the first molecule is chiral, but chirality is not specified
  4   # the second one has absolute configuration specified
  5   for smiles in ["CCC(O)C","CC[C@@H](O)C"]:
  6     mol = pybel.readstring( "smi", smiles)
  7     print smiles, mol.OBMol.IsChiral()
  8     mol.addh()
  9     print smiles, mol.OBMol.IsChiral()
stdout:
CCC(O)C False
CCC(O)C True
CC[C@@H](O)C True
CC[C@@H](O)C True
Doba běhu: 133.6 ms
The following code shows how to query chirality on atomic level.
Expand/Shrink
Zdroj: (babel9-2.py)
  1   import pybel
  2   
  3   for smiles in ["CCC(O)C","CC[C@@H](O)C"]:
  4     mol = pybel.readstring( "smi", smiles)
  5     mol.addh()
  6     print smiles, mol.OBMol.IsChiral()
  7     for a in mol.atoms:
  8       if a.atomicnum != 1: # exclude hydrogens
  9         print a.idx, a.OBAtom.IsChiral()
stdout:
CCC(O)C True
1 False
2 False
3 True
4 False
5 False
CC[C@@H](O)C True
1 False
2 False
3 True
5 False
6 False
Doba běhu: 140.9 ms
The following shows an example of stereochemistry perception on molecules with complete 3D structure.
Expand/Shrink
 
  -MOLDEN-
Molden generated mol file
 15 14  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    1.4500 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.3671    0.0000   -0.4833 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.5134   -0.8892   -0.3630 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6600    1.1431   -0.4667 O   0  0  0  0  0  0  0  0  0  0  0  0
   -1.5528    1.1431   -0.1510 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.0267    0.0000    1.8130 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5134   -0.8892    1.8130 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5134    0.8892    1.8130 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.3671    0.0000   -1.9333 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.8804    0.8892   -0.1203 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.8804   -0.8892   -0.1203 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.3938    0.0000   -2.2963 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.8537   -0.8892   -2.2963 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.8537    0.8892   -2.2963 H   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  1  3  1  0  0  0  0
  1  4  1  0  0  0  0
  1  5  1  0  0  0  0
  2  7  1  0  0  0  0
  2  8  1  0  0  0  0
  2  9  1  0  0  0  0
  3 10  1  0  0  0  0
  3 11  1  0  0  0  0
  3 12  1  0  0  0  0
  5  6  1  0  0  0  0
 10 13  1  0  0  0  0
 10 14  1  0  0  0  0
 10 15  1  0  0  0  0
M  END
Zdroj: (babel9-3.py)
  1   import pybel
  2   
  3   for mol in pybel.readfile( "mol", "butanol-2_3D.mol"):
  4     print mol.OBMol.IsChiral()
  5     for a in mol.atoms:
  6       if a.atomicnum != 1: # exclude hydrogens
  7         print a.idx, a.heavyvalence, a.OBAtom.IsChiral()
stdout:
True
1 3 True
2 1 False
3 2 False
5 1 False
10 1 False
Doba běhu: 144.4 ms