本文整理汇总了Python中rdkit.Chem.AllChem.MolFragmentToSmiles方法的典型用法代码示例。如果您正苦于以下问题:Python AllChem.MolFragmentToSmiles方法的具体用法?Python AllChem.MolFragmentToSmiles怎么用?Python AllChem.MolFragmentToSmiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdkit.Chem.AllChem
的用法示例。
在下文中一共展示了AllChem.MolFragmentToSmiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: computesubgraphsmarts
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import MolFragmentToSmiles [as 别名]
def computesubgraphsmarts(mol, size):
'''Given an rdkit mol, extract all the paths up to length size (if zero,
use default length). Return smarts expressions for these paths.'''
if size <= 0: size = 6 #default to 6 bonds
#find all paths of various sizes
paths = Chem.FindAllSubgraphsOfLengthMToN(mol,1,size)
#paths is a list of lists, each of which is the bond indices for paths of a different length
paths = [path for subpath in paths for path in subpath]
ret = set()
for path in paths:
atoms=set()
for bidx in path:
atoms.add(mol.GetBondWithIdx(bidx).GetBeginAtomIdx())
atoms.add(mol.GetBondWithIdx(bidx).GetEndAtomIdx())
smi = Chem.MolFragmentToSmiles(mol, atoms, canonical=True, allBondsExplicit=True)
ret.add(smi)
return ret
示例2: computepathsmarts
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import MolFragmentToSmiles [as 别名]
def computepathsmarts(mol, size):
if size <= 0: size = 7 # default to 7 atoms
ret = set()
for length in range(2,size+1):
paths = Chem.FindAllPathsOfLengthN(mol, length, useBonds=False)
for path in paths:
smi = Chem.MolFragmentToSmiles(mol, path, canonical=True, allBondsExplicit=True)
ret.add(smi)
return ret
示例3: computecircularsmarts
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import MolFragmentToSmiles [as 别名]
def computecircularsmarts(mol, size):
'''Given an rdkit mol, extract all the circular type descriptors up to
radius size (if zero, use default length). Return smarts expressions for these fragments.'''
if size <= 0: size = 2
ret = set()
for a in mol.GetAtoms():
for r in range(1,size+1):
env = Chem.FindAtomEnvironmentOfRadiusN(mol,r,a.GetIdx())
atoms=set()
for bidx in env:
atoms.add(mol.GetBondWithIdx(bidx).GetBeginAtomIdx())
atoms.add(mol.GetBondWithIdx(bidx).GetEndAtomIdx())
smi = Chem.MolFragmentToSmiles(mol, atoms, canonical=True, allBondsExplicit=True)
ret.add(smi)
return ret
示例4: get_frag_around_tetrahedral_center
# 需要导入模块: from rdkit.Chem import AllChem [as 别名]
# 或者: from rdkit.Chem.AllChem import MolFragmentToSmiles [as 别名]
def get_frag_around_tetrahedral_center(mol, idx):
'''Builds a MolFragment using neighbors of a tetrahedral atom,
where the molecule has already been updated to include isotopes'''
ids_to_include = [idx]
for neighbor in mol.GetAtomWithIdx(idx).GetNeighbors():
ids_to_include.append(neighbor.GetIdx())
symbols = ['[{}{}]'.format(a.GetIsotope(), a.GetSymbol()) if a.GetIsotope() != 0\
else '[#{}]'.format(a.GetAtomicNum()) for a in mol.GetAtoms()]
return Chem.MolFragmentToSmiles(mol, ids_to_include, isomericSmiles=True,
atomSymbols=symbols, allBondsExplicit=True,
allHsExplicit=True)