rdkit.Chem.ShowMols

Package rdkit :: Package Chem :: Module ShowMols |
[hide private]
[frames] | no frames]

# Source Code for Module rdkit.Chem.ShowMols

     1  # $Id$
     2  #
     3  # Copyright (C) 2004-2006 Rational Discovery LLC
     4  #
     5  #   @@ All Rights Reserved @@
     6  #  This file is part of the RDKit.
     7  #  The contents are covered by the terms of the BSD license
     8  #  which is included in the file license.txt, found at the root
     9  #  of the RDKit source tree.
    10  #
    11  from rdkit import RDConfig
    12
    13  # change this to use another viewer:
    14  if RDConfig.molViewer in ('WEBLAB', 'DSVIEWER'):
    15    from rdkit.Chem.DSViewer import *
    16  elif RDConfig.molViewer == 'PYMOL':
    17    from rdkit.Chem.PyMol import *
    18  else:
    19    raise ValueError('invalid RD_MOLVIEWER specified')
    20
    21  if __name__ == '__main__':
    22    import AllChem
    23    import sys
    24    if len(sys.argv) < 2:
    25      smi = 'c1cccc2c1cccc2CC(=O)N'
    26    else:
    27      smi = sys.argv[1]
    28
    29    m = Chem.MolFromSmiles(smi)
    30    m = Chem.AddHs(m)
    31    AllChem.EmbedMolecule(m)
    32    v = MolViewer()
    33    v.ShowMol(m, 'raw')
    34    AllChem.UFFOptimizeMolecule(m)
    35    v.ShowMol(m, 'opt', showOnly=0, highlightFeatures=[(0, ), (2, ), (3, 4)])
    36