当前位置: 首页>>代码示例>>Python>>正文


Python Chem.MolToMolBlock方法代码示例

本文整理汇总了Python中rdkit.Chem.MolToMolBlock方法的典型用法代码示例。如果您正苦于以下问题:Python Chem.MolToMolBlock方法的具体用法?Python Chem.MolToMolBlock怎么用?Python Chem.MolToMolBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdkit.Chem的用法示例。


在下文中一共展示了Chem.MolToMolBlock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_sticks

# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import MolToMolBlock [as 别名]
def show_sticks(xyz=None, species=None, project_directory=None):
    """
    Draws the molecule in a "sticks" style according to the supplied xyz coordinates.
    Returns whether successful of not. If successful, saves the image using draw_3d.
    Either ``xyz`` or ``species`` must be specified.

    Args:
        xyz (str, dict, optional): The coordinates to display.
        species (ARCSpecies, optional): xyz coordinates will be taken from the species.
        project_directory (str): ARC's project directory to save a draw_3d image in.

    Returns:
        bool: Whether the show_sticks drawing was successful. ``True`` if it was.
    """
    xyz = check_xyz_species_for_drawing(xyz, species)
    if species is None:
        s_mol, b_mol = molecules_from_xyz(xyz)
        mol = b_mol if b_mol is not None else s_mol
    else:
        mol = species.mol.copy(deep=True)
    try:
        conf, rd_mol = rdkit_conf_from_mol(mol, xyz)
    except (ValueError, AttributeError):
        return False
    if conf is None:
        return False
    mb = Chem.MolToMolBlock(rd_mol)
    p = p3D.view(width=400, height=400)
    p.addModel(mb, 'sdf')
    p.setStyle({'stick': {}})
    # p.setBackgroundColor('0xeeeeee')
    p.zoomTo()
    p.show()
    if project_directory is not None:
        draw_3d(xyz=xyz, species=species, project_directory=project_directory, save_only=True)
    return True 
开发者ID:ReactionMechanismGenerator,项目名称:ARC,代码行数:38,代码来源:plotter.py

示例2: _write_mol

# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import MolToMolBlock [as 别名]
def _write_mol(mol, args):
    if args.outtype in {'smi', 'smiles'} or args.outfile.name.endswith('smi') or args.outfile.name.endswith('smiles'):
        args.outfile.write(Chem.MolToSmiles(mol))
        args.outfile.write('\n')
    elif args.outtype in {'mol', 'sdf'} or args.outfile.name.endswith('mol') or args.outfile.name.endswith('sdf'):
        args.outfile.write(Chem.MolToMolBlock(mol))
    else:
        args.outfile.write(Chem.MolToSmiles(mol))
        args.outfile.write('\n') 
开发者ID:mcs07,项目名称:MolVS,代码行数:11,代码来源:cli.py

示例3: draw_3d

# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import MolToMolBlock [as 别名]
def draw_3d(self, width=300, height=500, style='stick', Hs=True): # pragma: no cover
        r'''Interface for drawing an interactive 3D view of the molecule.
        Requires an HTML5 browser, and the libraries RDKit, pymol3D, and
        IPython. An exception is raised if all three of these libraries are
        not installed.

        Parameters
        ----------
        width : int
            Number of pixels wide for the view
        height : int
            Number of pixels tall for the view
        style : str
            One of 'stick', 'line', 'cross', or 'sphere'
        Hs : bool
            Whether or not to show hydrogen

        Examples
        --------
        >>> Chemical('cubane').draw_3d()
        <IPython.core.display.HTML object>
        '''
        try:
            import py3Dmol
            from IPython.display import display
            if Hs:
                mol = self.rdkitmol_Hs
            else:
                mol = self.rdkitmol
            AllChem.EmbedMultipleConfs(mol)
            mb = Chem.MolToMolBlock(mol)
            p = py3Dmol.view(width=width,height=height)
            p.addModel(mb,'sdf')
            p.setStyle({style:{}})
            p.zoomTo()
            display(p.show())
        except:
            return 'py3Dmol, RDKit, and IPython are required for this feature.' 
开发者ID:CalebBell,项目名称:thermo,代码行数:40,代码来源:chemical.py

示例4: ReconnectDoubleBond

# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import MolToMolBlock [as 别名]
def ReconnectDoubleBond(parentMol, inputFrags):
    parentMolblock = Chem.MolToMolBlock(parentMol)
    fragmentMolblocks = []
    for i in range(len(inputFrags)):
        tempFragStr = Chem.MolToMolBlock(inputFrags[i])
        fragmentMolblocks.append(tempFragStr)

    newFragmentMolBlocks = []
    dbFragList = []
    for i in range(len(inputFrags)):
        tempValue = FindDoubleBonds(inputFrags[i])
        if tempValue >= 0:
            # Find C.2 = C.2 bond
            dbFragList.append(fragmentMolblocks[i])
        else:
            newFragmentMolBlocks.append(fragmentMolblocks[i])

    reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList)
    newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags

    newFragmentMol = []
    for i in range(len(newFragmentMolBlocks)):
        tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i])
        newFragmentMol.append(tempFragMol)

    # return tuple mol-objects
    return tuple(newFragmentMol) 
开发者ID:liutairan,项目名称:eMolFrag,代码行数:29,代码来源:chopRDKit03.py

示例5: ReconnectDoubleBond

# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import MolToMolBlock [as 别名]
def ReconnectDoubleBond(parentMol, inputFrags):
    parentMolblock = Chem.MolToMolBlock(parentMol)
    fragmentMolblocks = []
    for i in range(len(inputFrags)):
        tempFragStr = Chem.MolToMolBlock(inputFrags[i])
        fragmentMolblocks.append(tempFragStr)

    newFragmentMolBlocks = []
    dbFragList = []
    for i in range(len(inputFrags)):
        tempValue = FindDoubleBonds(inputFrags[i])
        if tempValue >= 0:
            # Find C.2 = C.2 bond
            dbFragList.append(fragmentMolblocks[i])
        else:
            newFragmentMolBlocks.append(fragmentMolblocks[i])
    
    reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList)
    
    newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags
    
    newFragmentMol = []
    for i in range(len(newFragmentMolBlocks)):
        tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i],sanitize=False)
        newFragmentMol.append(tempFragMol)

    # return tuple mol-objects
    return tuple(newFragmentMol) 
开发者ID:liutairan,项目名称:eMolFrag,代码行数:30,代码来源:newFrag02.py

示例6: ReconnectDoubleBond

# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import MolToMolBlock [as 别名]
def ReconnectDoubleBond(parentMol, inputFrags):
    parentMolblock = Chem.MolToMolBlock(parentMol,kekulize=False)
    fragmentMolblocks = []
    for i in range(len(inputFrags)):
        tempFragStr = Chem.MolToMolBlock(inputFrags[i],kekulize=False)
        fragmentMolblocks.append(tempFragStr)

    newFragmentMolBlocks = []
    dbFragList = []
    for i in range(len(inputFrags)):
        tempValue = FindDoubleBonds(inputFrags[i])
        if tempValue >= 0:
            # Find C.2 = C.2 bond
            dbFragList.append(fragmentMolblocks[i])
        else:
            newFragmentMolBlocks.append(fragmentMolblocks[i])

    reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList)
    newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags

    newFragmentMol = []
    for i in range(len(newFragmentMolBlocks)):
        tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i], sanitize=False)
        newFragmentMol.append(tempFragMol)
    #print('test')
    # return tuple mol-objects
    return tuple(newFragmentMol) 
开发者ID:liutairan,项目名称:eMolFrag,代码行数:29,代码来源:chopRDKit03.py


注:本文中的rdkit.Chem.MolToMolBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。