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