本文整理匯總了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)