當前位置: 首頁>>代碼示例>>Python>>正文


Python AllChem.Compute2DCoords方法代碼示例

本文整理匯總了Python中rdkit.Chem.AllChem.Compute2DCoords方法的典型用法代碼示例。如果您正苦於以下問題:Python AllChem.Compute2DCoords方法的具體用法?Python AllChem.Compute2DCoords怎麽用?Python AllChem.Compute2DCoords使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rdkit.Chem.AllChem的用法示例。


在下文中一共展示了AllChem.Compute2DCoords方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MolToQPixmap

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def MolToQPixmap(mol, size=(300, 300), kekulize=True, wedgeBonds=True, fitImage=False, options=None,
                 **kwargs):
    """ Generates a drawing of a molecule on a Qt QPixmap
      """
    if not mol:
        raise ValueError('Null molecule provided')
    from rdkit.Chem.Draw.qtCanvas import Canvas
    canvas = Canvas(size)
    if options is None:
        options = DrawingOptions()
    options.bgColor = None
    if fitImage:
        options.dotsPerAngstrom = int(min(size) / 10)
    options.wedgeDashedBonds = wedgeBonds
    if kekulize:
        from rdkit import Chem
        mol = Chem.Mol(mol.ToBinary())
        Chem.Kekulize(mol)
    if not mol.GetNumConformers():
        from rdkit.Chem import AllChem
        AllChem.Compute2DCoords(mol)
    drawer = MolDrawing(canvas=canvas, drawingOptions=options)
    drawer.AddMol(mol, **kwargs)
    canvas.flush()
    return canvas.pixmap 
開發者ID:blackmints,項目名稱:3DGCN,代碼行數:27,代碼來源:__init__.py

示例2: MolToFile

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def MolToFile(mol, fileName, size=(300, 300), kekulize=True, wedgeBonds=True, imageType=None,
              fitImage=False, options=None, **kwargs):
    """ Generates a drawing of a molecule and writes it to a file
    """
    # original contribution from Uwe Hoffmann
    if not fileName:
        raise ValueError('no fileName provided')
    if not mol:
        raise ValueError('Null molecule provided')

    if imageType is None:
        imageType = os.path.splitext(fileName)[1][1:]

    if options is None:
        options = DrawingOptions()
    useAGG, useCairo, Canvas = _getCanvas()
    if fitImage:
        options.dotsPerAngstrom = int(min(size) / 10)
    options.wedgeDashedBonds = wedgeBonds
    if useCairo or useAGG:
        canvas = Canvas(size=size, imageType=imageType, fileName=fileName)
    else:
        options.radicalSymbol = '.'  # <- the sping canvas doesn't support unicode well
        canvas = Canvas(size=size, name=fileName, imageType=imageType)
    drawer = MolDrawing(canvas=canvas, drawingOptions=options)
    if kekulize:
        from rdkit import Chem
        mol = Chem.Mol(mol.ToBinary())
        Chem.Kekulize(mol)

    if not mol.GetNumConformers():
        from rdkit.Chem import AllChem
        AllChem.Compute2DCoords(mol)

    drawer.AddMol(mol, **kwargs)
    if useCairo or useAGG:
        canvas.flush()
    else:
        canvas.save() 
開發者ID:blackmints,項目名稱:3DGCN,代碼行數:41,代碼來源:__init__.py

示例3: MolToMPL

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def MolToMPL(mol, size=(300, 300), kekulize=True, wedgeBonds=True, imageType=None, fitImage=False,
             options=None, **kwargs):
    """ Generates a drawing of a molecule on a matplotlib canvas
    """
    if not mol:
        raise ValueError('Null molecule provided')
    from experiment.figure.Draw.mplCanvas import Canvas
    canvas = Canvas(size)
    if options is None:
        options = DrawingOptions()
        options.bgColor = None
    if fitImage:
        options.dotsPerAngstrom = int(min(size) / 10)
    options.wedgeDashedBonds = wedgeBonds
    drawer = MolDrawing(canvas=canvas, drawingOptions=options)
    omol = mol
    if kekulize:
        from rdkit import Chem
        mol = Chem.Mol(mol.ToBinary())
        Chem.Kekulize(mol)

    if not mol.GetNumConformers():
        from rdkit.Chem import AllChem
        AllChem.Compute2DCoords(mol)

    drawer.AddMol(mol, **kwargs)
    omol._atomPs = drawer.atomPs[mol]
    for k, v in iteritems(omol._atomPs):
        omol._atomPs[k] = canvas.rescalePt(v)
    canvas._figure.set_size_inches(float(size[0]) / 100, float(size[1]) / 100)
    return canvas._figure 
開發者ID:blackmints,項目名稱:3DGCN,代碼行數:33,代碼來源:__init__.py

示例4: draw_structure

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def draw_structure(smiles_str, image_path, image_size=500):
  """
  Draw structure for the compound with the given SMILES string, in a PNG file
  with the given path.
  """
  mol = Chem.MolFromSmiles(smiles_str)
  if mol is None:
    print(("Unable to read original SMILES for %s" % cmpd_num))
  else:
    _discard = AllChem.Compute2DCoords(mol)
    Draw.MolToFile(mol, image_path, size=(image_size,image_size), fitImage=False) 
開發者ID:ATOMconsortium,項目名稱:AMPL,代碼行數:13,代碼來源:struct_utils.py

示例5: visualize_mol

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def visualize_mol(path, new_mol):
    AllChem.Compute2DCoords(new_mol)
    print(path)
    Draw.MolToFile(new_mol,path) 
開發者ID:microsoft,項目名稱:constrained-graph-variational-autoencoder,代碼行數:6,代碼來源:utils.py

示例6: mols2grid_image

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def mols2grid_image(mols, molsPerRow):
    mols = [e if e is not None else Chem.RWMol() for e in mols]

    for mol in mols:
        AllChem.Compute2DCoords(mol)

    return Draw.MolsToGridImage(mols, molsPerRow=molsPerRow, subImgSize=(150, 150)) 
開發者ID:nicola-decao,項目名稱:MolGAN,代碼行數:9,代碼來源:utils.py

示例7: make2D

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def make2D(self):
        """Generate 2D coordinates for molecule"""
        AllChem.Compute2DCoords(self.Mol)
        self._clear_cache() 
開發者ID:oddt,項目名稱:oddt,代碼行數:6,代碼來源:rdk.py

示例8: load_data_from_smiles

# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import Compute2DCoords [as 別名]
def load_data_from_smiles(x_smiles, labels, add_dummy_node=True, one_hot_formal_charge=False):
    """Load and featurize data from lists of SMILES strings and labels.

    Args:
        x_smiles (list[str]): A list of SMILES strings.
        labels (list[float]): A list of the corresponding labels.
        add_dummy_node (bool): If True, a dummy node will be added to the molecular graph. Defaults to True.
        one_hot_formal_charge (bool): If True, formal charges on atoms are one-hot encoded. Defaults to False.

    Returns:
        A tuple (X, y) in which X is a list of graph descriptors (node features, adjacency matrices, distance matrices),
        and y is a list of the corresponding labels.
    """
    x_all, y_all = [], []

    for smiles, label in zip(x_smiles, labels):
        try:
            mol = MolFromSmiles(smiles)
            try:
                mol = Chem.AddHs(mol)
                AllChem.EmbedMolecule(mol, maxAttempts=5000)
                AllChem.UFFOptimizeMolecule(mol)
                mol = Chem.RemoveHs(mol)
            except:
                AllChem.Compute2DCoords(mol)

            afm, adj, dist = featurize_mol(mol, add_dummy_node, one_hot_formal_charge)
            x_all.append([afm, adj, dist])
            y_all.append([label])
        except ValueError as e:
            logging.warning('the SMILES ({}) can not be converted to a graph.\nREASON: {}'.format(smiles, e))

    return x_all, y_all 
開發者ID:ardigen,項目名稱:MAT,代碼行數:35,代碼來源:data_utils.py


注:本文中的rdkit.Chem.AllChem.Compute2DCoords方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。