本文整理汇总了Python中rdkit.Chem.RenumberAtoms方法的典型用法代码示例。如果您正苦于以下问题:Python Chem.RenumberAtoms方法的具体用法?Python Chem.RenumberAtoms怎么用?Python Chem.RenumberAtoms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdkit.Chem
的用法示例。
在下文中一共展示了Chem.RenumberAtoms方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: randomize_smiles
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import RenumberAtoms [as 别名]
def randomize_smiles(mol, random_type="restricted"):
"""
Returns a random SMILES given a SMILES of a molecule.
:param mol: A Mol object
:param random_type: The type (unrestricted, restricted) of randomization performed.
:return : A random SMILES string of the same molecule or None if the molecule is invalid.
"""
if not mol:
return None
if random_type == "unrestricted":
return rkc.MolToSmiles(mol, canonical=False, doRandom=True, isomericSmiles=False)
if random_type == "restricted":
new_atom_order = list(range(mol.GetNumAtoms()))
random.shuffle(new_atom_order)
random_mol = rkc.RenumberAtoms(mol, newOrder=new_atom_order)
return rkc.MolToSmiles(random_mol, canonical=False, isomericSmiles=False)
raise ValueError("Type '{}' is not valid".format(random_type))
示例2: randomize_smile
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import RenumberAtoms [as 别名]
def randomize_smile(sml):
"""Function that randomizes a SMILES sequnce. This was adapted from the
implemetation of E. Bjerrum 2017, SMILES Enumeration as Data Augmentation
for Neural Network Modeling of Molecules.
Args:
sml: SMILES sequnce to randomize.
Return:
randomized SMILES sequnce or
nan if SMILES is not interpretable.
"""
try:
m = Chem.MolFromSmiles(sml)
ans = list(range(m.GetNumAtoms()))
np.random.shuffle(ans)
nm = Chem.RenumberAtoms(m, ans)
return Chem.MolToSmiles(nm, canonical=False)
except:
return float('nan')
示例3: randomize_smiles
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import RenumberAtoms [as 别名]
def randomize_smiles(self, smiles):
"""Perform a randomization of a SMILES string
must be RDKit sanitizable"""
m = Chem.MolFromSmiles(smiles)
ans = list(range(m.GetNumAtoms()))
np.random.shuffle(ans)
nm = Chem.RenumberAtoms(m, ans)
return Chem.MolToSmiles(nm, canonical=self.canonical,
isomericSmiles=self.isomericSmiles)
示例4: randomize_mol
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import RenumberAtoms [as 别名]
def randomize_mol(self, mol):
"""Performs a randomization of the atom order of an RDKit molecule"""
ans = list(range(mol.GetNumAtoms()))
np.random.shuffle(ans)
return Chem.RenumberAtoms(mol,ans)
示例5: to_smiles
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import RenumberAtoms [as 别名]
def to_smiles(mol, variant="canonical"):
"""
Converts a Mol object into a canonical SMILES string.
:param mol: Mol object.
:return: A SMILES string.
"""
if mol:
if variant.startswith("random"):
new_atom_order = list(range(mol.GetNumAtoms()))
random.shuffle(new_atom_order)
random_mol = rkc.RenumberAtoms(mol, newOrder=new_atom_order)
return rkc.MolToSmiles(random_mol, canonical=False, isomericSmiles=False)
else:
return rkc.MolToSmiles(mol, isomericSmiles=False, canonical=True)
示例6: randomize_smiles
# 需要导入模块: from rdkit import Chem [as 别名]
# 或者: from rdkit.Chem import RenumberAtoms [as 别名]
def randomize_smiles(self, smiles):
"""Perform a randomization of a SMILES string
must be RDKit sanitizable"""
m = Chem.MolFromSmiles(smiles)
ans = list(range(m.GetNumAtoms()))
np.random.shuffle(ans)
nm = Chem.RenumberAtoms(m,ans)
return Chem.MolToSmiles(nm, canonical=self.canonical, isomericSmiles=self.isomericSmiles)