Python-Ref > Cheminformatics > OpenBabel > Protonization
 
 

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

Protonization

Most chemical drawings exclude most or all hydrogen atoms. However for some types of calculations, such as generation of 3D coordinates, hydrogen atoms are essential. On the other hand, hydrogens on all atoms may complicate other problems, such as 2D picture generation, so we sometimes need to remove them.
Both pybel and openbabel include methods for automatic addition and removal of hydrogens based on typical valencies of elements.
Expand/Shrink
Zdroj: (babel10-1.py)
  1   import pybel
  2   import openbabel
  3   
  4   mol = pybel.readstring( "smi", "C1CCCCC1C(=O)O")
  5   print "Atoms read from SMILES:", len( mol.atoms)
  6   mol.addh()
  7   print "Atoms after hydrogen addition:", len( mol.atoms)
  8   mol.removeh()
  9   print "Atoms after hydrogen removal:", len( mol.atoms)
stdout:
Atoms read from SMILES: 9
Atoms after hydrogen addition: 21
Atoms after hydrogen removal: 9
Doba běhu: 144.9 ms
Expand/Shrink
Zdroj: (babel10-2.py)
  1   import pybel
  2   
  3   mol = pybel.readstring( "smi", "C1CC(N)CCC1C(=O)O")
  4   print "Atoms read from SMILES:", len( mol.atoms)
  5   mol.OBMol.AddHydrogens()
  6   print "Atoms after hydrogen addition:", len( mol.atoms)
  7   mol.OBMol.DeleteHydrogens()
  8   print "Atoms after hydrogen removal:", len( mol.atoms)
stdout:
Atoms read from SMILES: 10
Atoms after hydrogen addition: 23
Atoms after hydrogen removal: 10
Doba běhu: 141.2 ms
Using openbabel we have the additional possibility to specify that we want to add/remove hydrogens to specific atoms or that we want to adjust for a certain value of pH, which influences protonation of polar groups.
Expand/Shrink
Zdroj: (babel10-3.py)
  1   import pybel
  2   
  3   mol = pybel.readstring( "smi", "C1CC(N)CCC1C(=O)O")
  4   print "Atoms read from SMILES:", len( mol.atoms)
  5   
  6   # argument are (bool polaronly, bool correctForPH, double pH)
  7   mol.OBMol.AddHydrogens( False, True, 1)
  8   print "After hydrogen addition (pH=1):", len( mol.atoms)
  9   
 10   mol = pybel.readstring( "smi", "C1CC(N)CCC1C(=O)O")
 11   mol.OBMol.AddHydrogens( False, True, 7)
 12   print "After hydrogen addition (pH=7):", len( mol.atoms)
 13   
 14   mol = pybel.readstring( "smi", "C1CC(N)CCC1C(=O)O")
 15   mol.OBMol.AddHydrogens( False, True, 14)
 16   print "After hydrogen addition (pH=14):", len( mol.atoms)
stdout:
Atoms read from SMILES: 10
After hydrogen addition (pH=1): 24
After hydrogen addition (pH=7): 23
After hydrogen addition (pH=14): 22
Doba běhu: 145.7 ms
Expand/Shrink
Zdroj: (babel10-4.py)
  1   import pybel
  2   
  3   mol = pybel.readstring( "smi", "C1CC(N)CCC1C(=O)O")
  4   print "Atoms read from SMILES:", len( mol.atoms)
  5   
  6   mol.OBMol.AddPolarHydrogens()
  7   print "After polar hydrogen addition:", len( mol.atoms)
  8   
  9   mol.OBMol.AddHydrogens()
 10   print "After complete hydrogen addition:", len( mol.atoms)
 11   
 12   mol.OBMol.DeleteNonPolarHydrogens()
 13   print "After removal of non-polar hydrogens:", len( mol.atoms)
stdout:
Atoms read from SMILES: 10
After polar hydrogen addition: 13
After complete hydrogen addition: 23
After removal of non-polar hydrogens: 13
Doba běhu: 139.6 ms