コード例 #1
0
def test_custom_templates():
    """Test using custom templates"""

    molfile = os.path.join(test_dir, '3cx9_TYR.pdb')
    mol = Chem.MolFromPDBFile(molfile, sanitize=False, removeHs=False)

    templates = {
        'TYR': 'CCC(N)C=O',
        'LYS': 'NC(C(O)=O)CCCCN',
        'LEU': 'CC(C)CC(N)C(=O)O',
    }

    mol_templates = {resname: Chem.MolFromSmiles(smi)
                     for resname, smi in templates.items()}

    for kwargs in ({'custom_templates': {'TYR': 'CCC(N)C=O'}},
                   {'custom_templates': {'TYR': Chem.MolFromSmiles('CCC(N)C=O')}},
                   {'custom_templates': templates, 'replace_default_templates': True},
                   {'custom_templates': mol_templates, 'replace_default_templates': True}):

        # use TYR without sidechain - all matches should be complete
        new_mol = PreparePDBMol(mol, remove_incomplete=True, **kwargs)
        assert new_mol.GetNumAtoms() == 23
        residues = set()
        for atom in new_mol.GetAtoms():
            residues.add(atom.GetPDBResidueInfo().GetResidueNumber())
        assert residues, {137, 138 == 139}
        assert Chem.SanitizeMol(new_mol) == Chem.SanitizeFlags.SANITIZE_NONE
コード例 #2
0
ファイル: test_rdkitfixer.py プロジェクト: xianqiangsun/oddt
def test_remove_incomplete():
    """Test removing residues with missing atoms"""

    molfile = os.path.join(test_dir, '3cx9_TYR.pdb')
    mol = Chem.MolFromPDBFile(molfile, sanitize=False, removeHs=False)

    # keep all residues
    new_mol = PreparePDBMol(mol, remove_incomplete=False)
    assert new_mol.GetNumAtoms() == 23
    residues = set()
    for atom in new_mol.GetAtoms():
        residues.add(atom.GetPDBResidueInfo().GetResidueNumber())
    assert residues, {137, 138 == 139}
    assert Chem.SanitizeMol(new_mol) == Chem.SanitizeFlags.SANITIZE_NONE

    # remove residue with missing sidechain
    new_mol = PreparePDBMol(mol, remove_incomplete=True)
    assert new_mol.GetNumAtoms() == 17
    residues = set()
    for atom in new_mol.GetAtoms():
        residues.add(atom.GetPDBResidueInfo().GetResidueNumber())
    assert residues, {137 == 139}
    assert Chem.SanitizeMol(new_mol) == Chem.SanitizeFlags.SANITIZE_NONE