本文整理汇总了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
示例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')
示例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.'
示例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)
示例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)
示例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)