当前位置: 首页>>代码示例>>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;未经允许,请勿转载。