本文整理匯總了Python中rdkit.Chem.AllChem.MolFromSmarts方法的典型用法代碼示例。如果您正苦於以下問題:Python AllChem.MolFromSmarts方法的具體用法?Python AllChem.MolFromSmarts怎麽用?Python AllChem.MolFromSmarts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rdkit.Chem.AllChem
的用法示例。
在下文中一共展示了AllChem.MolFromSmarts方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: loadsmarts
# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import MolFromSmarts [as 別名]
def loadsmarts(fname):
ret = []
with open(fname) as f:
for line in f:
if line.startswith('#') or len(line.strip()) == 0:
continue
tokens = line.split()
mol = Chem.MolFromSmarts(tokens[0])
ret.append(mol)
return ret
示例2: getDihedralMatches
# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import MolFromSmarts [as 別名]
def getDihedralMatches(mol):
'''return list of atom indices of dihedrals'''
#this is rdkit's "strict" pattern
pattern = r"*~[!$(*#*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])([CH3])[CH3])&!$([CD3](=[N,O,S])-!@[#7,O,S!D1])&!$([#7,O,S!D1]-!@[CD3]=[N,O,S])&!$([CD3](=[N+])-!@[#7!D1])&!$([#7!D1]-!@[CD3]=[N+])]-!@[!$(*#*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])([CH3])[CH3])]~*"
qmol = Chem.MolFromSmarts(pattern)
matches = mol.GetSubstructMatches(qmol);
#these are all sets of 4 atoms, uniquify by middle two
uniqmatches = []
seen = set()
for (a,b,c,d) in matches:
if (b,c) not in seen:
seen.add((b,c))
uniqmatches.append((a,b,c,d))
return uniqmatches
示例3: get_special_groups
# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import MolFromSmarts [as 別名]
def get_special_groups(mol):
'''Given an RDKit molecule, this function returns a list of tuples, where
each tuple contains the AtomIdx's for a special group of atoms which should
be included in a fragment all together. This should only be done for the
reactants, otherwise the products might end up with mapping mismatches
We draw a distinction between atoms in groups that trigger that whole
group to be included, and "unimportant" atoms in the groups that will not
be included if another atom matches.'''
# Define templates
group_templates = [
(range(3), '[OH0,SH0]=C[O,Cl,I,Br,F]',), # carboxylic acid / halogen
(range(3), '[OH0,SH0]=CN',), # amide/sulfamide
(range(4), 'S(O)(O)[Cl]',), # sulfonyl chloride
(range(3), 'B(O)O',), # boronic acid/ester
((0,), '[Si](C)(C)C'), # trialkyl silane
((0,), '[Si](OC)(OC)(OC)'), # trialkoxy silane, default to methyl
(range(3), '[N;H0;$(N-[#6]);D2]-,=[N;D2]-,=[N;D1]',), # azide
(range(8), 'O=C1N([Br,I,F,Cl])C(=O)CC1',), # NBS brominating agent
(range(11), 'Cc1ccc(S(=O)(=O)O)cc1'), # Tosyl
((7,), 'CC(C)(C)OC(=O)[N]'), # N(boc)
((4,), '[CH3][CH0]([CH3])([CH3])O'), #
(range(2), '[C,N]=[C,N]',), # alkene/imine
(range(2), '[C,N]#[C,N]',), # alkyne/nitrile
((2,), 'C=C-[*]',), # adj to alkene
((2,), 'C#C-[*]',), # adj to alkyne
((2,), 'O=C-[*]',), # adj to carbonyl
((3,), 'O=C([CH3])-[*]'), # adj to methyl ketone
((3,), 'O=C([O,N])-[*]',), # adj to carboxylic acid/amide/ester
(range(4), 'ClS(Cl)=O',), # thionyl chloride
(range(2), '[Mg,Li,Zn,Sn][Br,Cl,I,F]',), # grinard/metal (non-disassociated)
(range(3), 'S(O)(O)',), # SO2 group
(range(2), 'N~N',), # diazo
((1,), '[!#6;R]@[#6;R]',), # adjacency to heteroatom in ring
((2,), '[a!c]:a:a',), # two-steps away from heteroatom in aromatic ring
#((1,), 'c(-,=[*]):c([Cl,I,Br,F])',), # ortho to halogen on ring - too specific?
#((1,), 'c(-,=[*]):c:c([Cl,I,Br,F])',), # meta to halogen on ring - too specific?
((0,), '[B,C](F)(F)F'), # CF3, BF3 should have the F3 included
]
# Stereo-specific ones (where we will need to include neighbors)
# Tetrahedral centers should already be okay...
group_templates += [
((1,2,), '[*]/[CH]=[CH]/[*]'), # trans with two hydrogens
((1,2,), '[*]/[CH]=[CH]\[*]'), # cis with two hydrogens
((1,2,), '[*]/[CH]=[CH0]([*])\[*]'), # trans with one hydrogens
((1,2,), '[*]/[D3;H1]=[!D1]'), # specified on one end, can be N or C
]
# Build list
groups = []
for (add_if_match, template) in group_templates:
matches = mol.GetSubstructMatches(Chem.MolFromSmarts(template), useChirality=True)
for match in matches:
add_if = []
for pattern_idx, atom_idx in enumerate(match):
if pattern_idx in add_if_match:
add_if.append(atom_idx)
groups.append((add_if, match))
return groups
示例4: get_special_groups
# 需要導入模塊: from rdkit.Chem import AllChem [as 別名]
# 或者: from rdkit.Chem.AllChem import MolFromSmarts [as 別名]
def get_special_groups(mol):
'''Given an RDKit molecule, this function returns a list of tuples, where
each tuple contains the AtomIdx's for a special group of atoms which should
be included in a fragment all together. This should only be done for the
reactants, otherwise the products might end up with mapping mismatches
We draw a distinction between atoms in groups that trigger that whole
group to be included, and "unimportant" atoms in the groups that will not
be included if another atom matches.'''
# Define templates, based on Functional_Group_Hierarchy.txt from Greg Laandrum
group_templates = [
(range(3), '[OH0,SH0]=C[O,Cl,I,Br,F]',), # carboxylic acid / halogen
(range(3), '[OH0,SH0]=CN',), # amide/sulfamide
(range(4), 'S(O)(O)[Cl]',), # sulfonyl chloride
(range(3), 'B(O)O',), # boronic acid/ester
((0,), '[Si](C)(C)C'), # trialkyl silane
((0,), '[Si](OC)(OC)(OC)'), # trialkoxy silane, default to methyl
(range(3), '[N;H0;$(N-[#6]);D2]-,=[N;D2]-,=[N;D1]',), # azide
(range(8), 'O=C1N([Br,I,F,Cl])C(=O)CC1',), # NBS brominating agent
(range(11), 'Cc1ccc(S(=O)(=O)O)cc1'), # Tosyl
((7,), 'CC(C)(C)OC(=O)[N]'), # N(boc)
((4,), '[CH3][CH0]([CH3])([CH3])O'), #
(range(2), '[C,N]=[C,N]',), # alkene/imine
(range(2), '[C,N]#[C,N]',), # alkyne/nitrile
((2,), 'C=C-[*]',), # adj to alkene
((2,), 'C#C-[*]',), # adj to alkyne
((2,), 'O=C-[*]',), # adj to carbonyl
((3,), 'O=C([CH3])-[*]'), # adj to methyl ketone
((3,), 'O=C([O,N])-[*]',), # adj to carboxylic acid/amide/ester
(range(4), 'ClS(Cl)=O',), # thionyl chloride
(range(2), '[Mg,Li,Zn,Sn][Br,Cl,I,F]',), # grinard/metal (non-disassociated)
(range(3), 'S(O)(O)',), # SO2 group
(range(2), 'N~N',), # diazo
((1,), '[!#6;R]@[#6;R]',), # adjacency to heteroatom in ring
((2,), '[a!c]:a:a',), # two-steps away from heteroatom in aromatic ring
#((1,), 'c(-,=[*]):c([Cl,I,Br,F])',), # ortho to halogen on ring - too specific?
#((1,), 'c(-,=[*]):c:c([Cl,I,Br,F])',), # meta to halogen on ring - too specific?
((0,), '[B,C](F)(F)F'), # CF3, BF3 should have the F3 included
]
# Stereo-specific ones (where we will need to include neighbors)
# Tetrahedral centers should already be okay...
group_templates += [
((1,2,), '[*]/[CH]=[CH]/[*]'), # trans with two hydrogens
((1,2,), '[*]/[CH]=[CH]\[*]'), # cis with two hydrogens
((1,2,), '[*]/[CH]=[CH0]([*])\[*]'), # trans with one hydrogens
((1,2,), '[*]/[D3;H1]=[!D1]'), # specified on one end, can be N or C
]
# Build list
groups = []
for (add_if_match, template) in group_templates:
matches = mol.GetSubstructMatches(Chem.MolFromSmarts(template), useChirality=True)
for match in matches:
add_if = []
for pattern_idx, atom_idx in enumerate(match):
if pattern_idx in add_if_match:
add_if.append(atom_idx)
groups.append((add_if, match))
return groups