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


Python Chem.RenumberAtoms方法代碼示例

本文整理匯總了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)) 
開發者ID:undeadpixel,項目名稱:reinvent-randomized,代碼行數:20,代碼來源:chem.py

示例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') 
開發者ID:jrwnter,項目名稱:cddd,代碼行數:20,代碼來源:preprocessing.py

示例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) 
開發者ID:Mariewelt,項目名稱:OpenChem,代碼行數:11,代碼來源:smiles_enumerator.py

示例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) 
開發者ID:pcko1,項目名稱:Deep-Drug-Coder,代碼行數:7,代碼來源:vectorizers.py

示例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) 
開發者ID:undeadpixel,項目名稱:reinvent-scaffold-decorator,代碼行數:16,代碼來源:chem.py

示例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) 
開發者ID:EBjerrum,項目名稱:SMILES-enumeration,代碼行數:10,代碼來源:SmilesEnumerator.py


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