def main(argv):
    if len(argv) != 2:
        oechem.OEThrow.Usage("%s <receptor>" % argv[0])

    receptor = oechem.OEGraphMol()
    oedocking.OEReadReceptorFile(receptor, argv[1])

    # @ <SNIPPET-RECEPTOR-PROTEIN-CONSTRAINT-EDITING-1>
    for constraint in oedocking.OEReceptorGetProteinConstraints(receptor):
        print("Atom %i has a constraint" % constraint.GetAtom().GetIdx())
    # @ </SNIPPET-RECEPTOR-PROTEIN-CONSTRAINT-EDITING-1>

    # @ <SNIPPET-RECEPTOR-PROTEIN-CONSTRAINT-EDITING-2>
    for constraint in oedocking.OEReceptorGetProteinConstraints(receptor):
        print("Protein constraint on atom  %d" % constraint.GetAtom().GetIdx())
        print("  Type :  %s" % oedocking.OEProteinConstraintTypeGetName(constraint.GetType()))
        print("  Name :  %s" % constraint.GetName())
    # @ </SNIPPET-RECEPTOR-PROTEIN-CONSTRAINT-EDITING-2>

    for heavyAtom in receptor.GetAtoms(oechem.OENotAtom(oechem.OEIsHydrogen())):
        # @ <SNIPPET-RECEPTOR-PROTEIN-CONSTRAINT-EDITING-3>
        proteinConstraint = oedocking.OEProteinConstraint()
        proteinConstraint.SetAtom(heavyAtom)
        proteinConstraint.SetType(oedocking.OEProteinConstraintType_Contact)
        proteinConstraint.SetName("Example constraint")
        oedocking.OEReceptorSetProteinConstraint(receptor, proteinConstraint)
        # @ </SNIPPET-RECEPTOR-PROTEIN-CONSTRAINT-EDITING-3>
        break

    # @ <SNIPPET-RECEPTOR-PROTEIN-CONSTRAINT-EDITING-4>
    oedocking.OEReceptorClearProteinConstraints(receptor)
Example #2
0
        def noh(ls, dsets):
            """
            This function remove hydrogens from the selection
            """
            data_set = build_set(ls[1], dsets)

            noh_set = set()
            pred = oechem.OEIsHydrogen()

            for idx in data_set:
                atom = system.GetAtom(oechem.OEHasAtomIdx(idx))
                if not pred(atom):
                    noh_set.add(idx)

            return noh_set
Example #3
0
def _OEFixConnectionNH(protein):
    """
    Temporary fix, thanks to Jesper!
    """
    for atom in protein.GetAtoms(
            oechem.OEAndAtom(oespruce.OEIsModeledAtom(),
                             oechem.OEIsNitrogen())):
        if oechem.OEGetPDBAtomIndex(atom) == oechem.OEPDBAtomName_N:
            expected_h_count = 1
            if oechem.OEGetResidueIndex(atom) == oechem.OEResidueIndex_PRO:
                expected_h_count = 0
            if atom.GetTotalHCount() != expected_h_count:
                oechem.OESuppressHydrogens(atom)
                atom.SetImplicitHCount(1)
                oechem.OEAddExplicitHydrogens(protein, atom)
                for nbr in atom.GetAtoms(oechem.OEIsHydrogen()):
                    oechem.OESet3DHydrogenGeom(protein, nbr)
Example #4
0
def has_undesirable_elements(mol):
    '''
    returns True if molecule contains any element other than
    H, C, N, O, F, S, Cl, or P
    @param mol:
    @type mol: OEGraphMol
    @return: bool
    '''
    atomsHC = oechem.OEOrAtom(oechem.OEIsHydrogen(), oechem.OEIsCarbon())
    atomsNO = oechem.OEOrAtom(oechem.OEIsNitrogen(), oechem.OEIsOxygen())
    atomsFS = oechem.OEOrAtom(oechem.OEHasAtomicNum(9), oechem.OEIsSulfur())
    atomsHCNO = oechem.OEOrAtom(atomsHC, atomsNO)
    atomsHCNOFS = oechem.OEOrAtom(atomsHCNO, atomsFS)
    atomsHCNOFSCl = oechem.OEOrAtom(atomsHCNOFS, oechem.OEHasAtomicNum(17))
    atomsHCNOFSClP = oechem.OEOrAtom(atomsHCNOFSCl, oechem.OEIsPhosphorus())

    undesirable_atom = mol.GetAtom(oechem.OENotAtom(atomsHCNOFSClP))
    if undesirable_atom is not None:
        return True

    return False