當前位置: 首頁>>代碼示例>>Python>>正文


Python AllChem.MolFragmentToSmiles方法代碼示例

本文整理匯總了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 
開發者ID:dkoes,項目名稱:qsar-tools,代碼行數:19,代碼來源:createsmartsdescriptors.py

示例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 
開發者ID:dkoes,項目名稱:qsar-tools,代碼行數:11,代碼來源:createsmartsdescriptors.py

示例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 
開發者ID:dkoes,項目名稱:qsar-tools,代碼行數:17,代碼來源:createsmartsdescriptors.py

示例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) 
開發者ID:Hanjun-Dai,項目名稱:GLN,代碼行數:13,代碼來源:template_extractor.py


注:本文中的rdkit.Chem.AllChem.MolFragmentToSmiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。