本文整理汇总了Python中rdkit.Chem.FragmentOnBonds方法的典型用法代码示例。如果您正苦于以下问题:Python Chem.FragmentOnBonds方法的具体用法?Python Chem.FragmentOnBonds怎么用?Python Chem.FragmentOnBonds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdkit.Chem
的用法示例。
在下文中一共展示了Chem.FragmentOnBonds方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cut
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import FragmentOnBonds [as 别名]
def cut(mol):
if not mol.HasSubstructMatch(Chem.MolFromSmarts('[*]-;!@[*]')):
return None
bis = random.choice(mol.GetSubstructMatches(Chem.MolFromSmarts('[*]-;!@[*]'))) # single bond not in ring
bs = [mol.GetBondBetweenAtoms(bis[0], bis[1]).GetIdx()]
fragments_mol = Chem.FragmentOnBonds(mol, bs, addDummies=True, dummyLabels=[(1, 1)])
try:
return Chem.GetMolFrags(fragments_mol, asMols=True, sanitizeFrags=True)
except ValueError:
return None
return None
示例2: spf
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import FragmentOnBonds [as 别名]
def spf(mol, split_id):
bonds = mol.GetBonds()
for i in range(len(bonds)):
if okToBreak(bonds[i]):
mol = Chem.FragmentOnBonds(mol, [i], addDummies=True, dummyLabels=[(0, 0)])
# Dummy atoms are always added last
n_at = mol.GetNumAtoms()
mol.GetAtomWithIdx(n_at-1).SetAtomicNum(split_id)
mol.GetAtomWithIdx(n_at-2).SetAtomicNum(split_id)
return Chem.rdmolops.GetMolFrags(mol, asMols=True)
# If the molecule could not been split, return original molecule
return [mol]
# Build up a chain of fragments from a molecule.
# This is required so that a given list of fragments can be rebuilt into the same
# molecule as was given when splitting the molecule
示例3: spf
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import FragmentOnBonds [as 别名]
def spf(mol, split_id):
bonds = mol.GetBonds()
for i in range(len(bonds)):
if okToBreak(bonds[i]):
mol = Chem.FragmentOnBonds(mol, [i], addDummies=True, dummyLabels=[(0, 0)])
# Dummy atoms are always added last
n_at = mol.GetNumAtoms()
mol.GetAtomWithIdx(n_at-1).SetAtomicNum(split_id)
mol.GetAtomWithIdx(n_at-2).SetAtomicNum(split_id)
return Chem.rdmolops.GetMolFrags(mol, asMols=True)
# If the molecule could not been split, return original molecule
return [mol]
# Build up a chain of fragments from a molecule.
# This is required so that a given list of fragments can be rebuilt into the same
# molecule as was given when splitting the molecule
示例4: cut_ring
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import FragmentOnBonds [as 别名]
def cut_ring(mol):
for i in range(10):
if random.random() < 0.5:
if not mol.HasSubstructMatch(Chem.MolFromSmarts('[R]@[R]@[R]@[R]')):
return None
bis = random.choice(mol.GetSubstructMatches(Chem.MolFromSmarts('[R]@[R]@[R]@[R]')))
bis = ((bis[0], bis[1]), (bis[2], bis[3]),)
else:
if not mol.HasSubstructMatch(Chem.MolFromSmarts('[R]@[R;!D2]@[R]')):
return None
bis = random.choice(mol.GetSubstructMatches(Chem.MolFromSmarts('[R]@[R;!D2]@[R]')))
bis = ((bis[0], bis[1]), (bis[1], bis[2]),)
bs = [mol.GetBondBetweenAtoms(x, y).GetIdx() for x, y in bis]
fragments_mol = Chem.FragmentOnBonds(mol, bs, addDummies=True, dummyLabels=[(1, 1), (1, 1)])
try:
fragments = Chem.GetMolFrags(fragments_mol, asMols=True, sanitizeFrags=True)
if len(fragments) == 2:
return fragments
except ValueError:
return None
return None
示例5: cut
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import FragmentOnBonds [as 别名]
def cut(mol):
if not mol.HasSubstructMatch(Chem.MolFromSmarts('[*]-;!@[*]')):
return None
bis = random.choice(mol.GetSubstructMatches(Chem.MolFromSmarts('[*]-;!@[*]'))) #single bond not in ring
#print bis,bis[0],bis[1]
bs = [mol.GetBondBetweenAtoms(bis[0],bis[1]).GetIdx()]
fragments_mol = Chem.FragmentOnBonds(mol,bs,addDummies=True,dummyLabels=[(1, 1)])
try:
fragments = Chem.GetMolFrags(fragments_mol,asMols=True)
return fragments
except:
return None
示例6: cut_ring
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import FragmentOnBonds [as 别名]
def cut_ring(mol):
for i in range(10):
if random.random() < 0.5:
if not mol.HasSubstructMatch(Chem.MolFromSmarts('[R]@[R]@[R]@[R]')):
return None
bis = random.choice(mol.GetSubstructMatches(Chem.MolFromSmarts('[R]@[R]@[R]@[R]')))
bis = ((bis[0],bis[1]),(bis[2],bis[3]),)
else:
if not mol.HasSubstructMatch(Chem.MolFromSmarts('[R]@[R;!D2]@[R]')):
return None
bis = random.choice(mol.GetSubstructMatches(Chem.MolFromSmarts('[R]@[R;!D2]@[R]')))
bis = ((bis[0],bis[1]),(bis[1],bis[2]),)
#print bis
bs = [mol.GetBondBetweenAtoms(x,y).GetIdx() for x,y in bis]
fragments_mol = Chem.FragmentOnBonds(mol,bs,addDummies=True,dummyLabels=[(1, 1),(1,1)])
try:
fragments = Chem.GetMolFrags(fragments_mol,asMols=True)
except:
return None
if len(fragments) == 2:
return fragments
return None
示例7: enumerate
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import FragmentOnBonds [as 别名]
def enumerate(self, mol, cuts):
"""
Enumerates all possible combination of slicings of a molecule given a number of cuts.
:param mol: A mol object with the molecule to slice.
:param cuts: The number of cuts to perform.
:return : A list with all the possible (scaffold, decorations) pairs as SlicedMol objects.
"""
matches = self._get_matches(mol)
sliced_mols = set()
for atom_pairs_to_cut in itertools.combinations(matches, cuts):
to_cut_bonds = list(sorted(mol.GetBondBetweenAtoms(aidx, oaidx).GetIdx()
for aidx, oaidx in atom_pairs_to_cut))
attachment_point_idxs = [(i, i) for i in range(len(to_cut_bonds))]
cut_mol = rkc.FragmentOnBonds(mol, bondIndices=to_cut_bonds, dummyLabels=attachment_point_idxs)
for atom in cut_mol.GetAtoms():
if atom.GetSymbol() == ATTACHMENT_POINT_TOKEN:
num = atom.GetIsotope()
atom.SetIsotope(0)
atom.SetProp("molAtomMapNumber", str(num))
cut_mol.UpdatePropertyCache()
fragments = rkc.GetMolFrags(cut_mol, asMols=True, sanitizeFrags=True)
# detect whether there is one fragment with as many attachment points as cuts (scaffold)
# the rest are decorations
if cuts == 1:
sliced_mols.add(SlicedMol(fragments[0], [fragments[1]]))
sliced_mols.add(SlicedMol(fragments[1], [fragments[0]]))
else:
scaffold = None
decorations = []
for frag in fragments:
num_att = len([atom for atom in frag.GetAtoms() if atom.GetSymbol() == ATTACHMENT_POINT_TOKEN])
if num_att == cuts and not scaffold:
scaffold = frag
else:
decorations.append(frag)
if scaffold:
sliced_mols.add(SlicedMol(scaffold, decorations))
return list(filter(self._filter, sliced_mols))