本文整理汇总了Python中rdkit.Chem.AllChem.EmbedMultipleConfs方法的典型用法代码示例。如果您正苦于以下问题:Python AllChem.EmbedMultipleConfs方法的具体用法?Python AllChem.EmbedMultipleConfs怎么用?Python AllChem.EmbedMultipleConfs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdkit.Chem.AllChem
的用法示例。
在下文中一共展示了AllChem.EmbedMultipleConfs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_iso_smiles
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import EmbedMultipleConfs [as 别名]
def make_iso_smiles(mol):
'''enumerate chiral centers and return list of smiles'''
#for some reason rdkit can't detect chiral centers without a structure
Chem.EmbedMultipleConfs(mol)
Chem.rdmolops.AssignAtomChiralTagsFromStructure(mol)
chirals = [] # chiral atoms
Chem.rdmolops.AssignStereochemistry(mol) #make sure this is done
for a in mol.GetAtoms():
if a.GetChiralTag() == Chem.rdchem.CHI_TETRAHEDRAL_CCW or a.GetChiralTag() == Chem.rdchem.CHI_TETRAHEDRAL_CW:
chirals.append(a)
cmask = itertools.product(*[[0,1]]*len(chirals))
if len(chirals) == 0:
return [Chem.MolToSmiles(mol)]
else:
ret = []
for m in cmask:
for i in xrange(len(chirals)):
if m[i]:
chirals[i].SetChiralTag(Chem.rdchem.CHI_TETRAHEDRAL_CCW)
else:
chirals[i].SetChiralTag(Chem.rdchem.CHI_TETRAHEDRAL_CW)
ret.append(Chem.MolToSmiles(mol,True))
return ret
示例2: embed_molecule
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import EmbedMultipleConfs [as 别名]
def embed_molecule(self, mol):
"""
Generate conformers, possibly with pruning.
Parameters
----------
mol : RDKit Mol
Molecule.
"""
from rdkit import Chem
from rdkit.Chem import AllChem
mol = Chem.AddHs(mol) # add hydrogens
n_confs = self.max_conformers * self.pool_multiplier
AllChem.EmbedMultipleConfs(mol, numConfs=n_confs, pruneRmsThresh=-1.)
return mol
示例3: get_structure
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import EmbedMultipleConfs [as 别名]
def get_structure(mol,n_confs):
mol = Chem.AddHs(mol)
new_mol = Chem.Mol(mol)
AllChem.EmbedMultipleConfs(mol,numConfs=n_confs,useExpTorsionAnglePrefs=True,useBasicKnowledge=True)
energies = AllChem.MMFFOptimizeMoleculeConfs(mol,maxIters=2000, nonBondedThresh=100.0)
energies_list = [e[1] for e in energies]
min_e_index = energies_list.index(min(energies_list))
new_mol.AddConformer(mol.GetConformer(min_e_index))
return new_mol
示例4: draw_3d
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import EmbedMultipleConfs [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.'
示例5: embed_molecule
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import EmbedMultipleConfs [as 别名]
def embed_molecule(self, mol):
"""Generate conformers, possibly with pruning.
Parameters
----------
mol : RDKit Mol
Molecule.
"""
logging.debug("Adding hydrogens for %s" % mol.GetProp("_Name"))
mol = Chem.AddHs(mol) # add hydrogens
logging.debug("Hydrogens added to %s" % mol.GetProp("_Name"))
logging.debug("Sanitizing mol for %s" % mol.GetProp("_Name"))
Chem.SanitizeMol(mol)
logging.debug("Mol sanitized for %s" % mol.GetProp("_Name"))
if self.max_conformers == -1 or type(self.max_conformers) is not int:
self.max_conformers = self.get_num_conformers(mol)
n_confs = self.max_conformers * self.pool_multiplier
if self.first_conformers == -1:
self.first_conformers = self.max_conformers
logging.debug(
"Embedding %d conformers for %s" % (n_confs, mol.GetProp("_Name"))
)
AllChem.EmbedMultipleConfs(
mol,
numConfs=n_confs,
maxAttempts=10 * n_confs,
pruneRmsThresh=-1.0,
randomSeed=self.seed,
ignoreSmoothingFailures=True,
)
logging.debug("Conformers embedded for %s" % mol.GetProp("_Name"))
return mol
示例6: optimize_conformer
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import EmbedMultipleConfs [as 别名]
def optimize_conformer(idx, m, prop, algo="MMFF"):
print("Calculating {}: {} ...".format(idx, Chem.MolToSmiles(m)))
mol = Chem.AddHs(m)
if algo == "ETKDG":
# Landrum et al. DOI: 10.1021/acs.jcim.5b00654
k = AllChem.EmbedMolecule(mol, AllChem.ETKDG())
if k != 0:
return None, None
elif algo == "UFF":
# Universal Force Field
AllChem.EmbedMultipleConfs(mol, 50, pruneRmsThresh=0.5)
try:
arr = AllChem.UFFOptimizeMoleculeConfs(mol, maxIters=2000)
except ValueError:
return None, None
if not arr:
return None, None
else:
arr = AllChem.UFFOptimizeMoleculeConfs(mol, maxIters=20000)
idx = np.argmin(arr, axis=0)[1]
conf = mol.GetConformers()[idx]
mol.RemoveAllConformers()
mol.AddConformer(conf)
elif algo == "MMFF":
# Merck Molecular Force Field
AllChem.EmbedMultipleConfs(mol, 50, pruneRmsThresh=0.5)
try:
arr = AllChem.MMFFOptimizeMoleculeConfs(mol, maxIters=2000)
except ValueError:
return None, None
if not arr:
return None, None
else:
arr = AllChem.MMFFOptimizeMoleculeConfs(mol, maxIters=20000)
idx = np.argmin(arr, axis=0)[1]
conf = mol.GetConformers()[idx]
mol.RemoveAllConformers()
mol.AddConformer(conf)
mol = Chem.RemoveHs(mol)
return mol, prop
示例7: diverse_conformers_generator
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import EmbedMultipleConfs [as 别名]
def diverse_conformers_generator(mol, n_conf=10, method='etkdg', seed=None,
rmsd=0.5):
"""Produce diverse conformers using current conformer as starting point.
Each conformer is a copy of original molecule object.
.. versionadded:: 0.6
Parameters
----------
mol : oddt.toolkit.Molecule object
Molecule for which generating conformers
n_conf : int (default=10)
Targer number of conformers
method : string (default='etkdg')
Method for generating conformers. Supported methods: "etkdg", "etdg",
"kdg", "dg".
seed : None or int (default=None)
Random seed
rmsd : float (default=0.5)
The minimum RMSD that separates conformers to be ratained (otherwise,
they will be pruned).
Returns
-------
mols : list of oddt.toolkit.Molecule objects
Molecules with diverse conformers
"""
mol_clone = mol.clone
if method == 'etkdg':
params = {'useExpTorsionAnglePrefs': True,
'useBasicKnowledge': True}
elif method == 'etdg':
params = {'useExpTorsionAnglePrefs': True,
'useBasicKnowledge': False}
elif method == 'kdg':
params = {'useExpTorsionAnglePrefs': False,
'useBasicKnowledge': True}
elif method == 'dg':
params = {}
else:
raise ValueError('Method %s is not implemented' % method)
params['pruneRmsThresh'] = rmsd
if seed is None:
seed = -1
AllChem.EmbedMultipleConfs(mol_clone.Mol, numConfs=n_conf, randomSeed=seed,
**params)
AllChem.AlignMol(mol_clone.Mol, mol.Mol)
AllChem.AlignMolConformers(mol_clone.Mol)
out = []
mol_clone2 = mol.clone
mol_clone2.Mol.RemoveAllConformers()
for conformer in mol_clone.Mol.GetConformers():
mol_output_clone = mol_clone2.clone
mol_output_clone.Mol.AddConformer(conformer)
out.append(mol_output_clone)
return out