Example #1
0
    def check_arom(self, resRings, ligRings, centerMol, resRingCenter,
                   ligRingCenter, aromDist):
        '''
        Checks for an interaction between the set of rings of a residue and a
        ligand. Uses temporary center atoms to make the distance comparisons
        '''

        # Loop over the residue rings
        for resRing in resRings:
            # For each ring, define its center using a temp atom
            centerMol.SetCoords(resRingCenter, resRing[0])

            # Loop over the ligand's rings
            for ligRing in ligRings:
                # Get the center of the ligand ring
                centerMol.SetCoords(ligRingCenter, ligRing[0])

                # Get the distance
                dist = oechem.OEGetDistance(centerMol, resRingCenter,
                                            centerMol, ligRingCenter)

                # If under cutoff, return 1
                if dist <= aromDist:
                    return "1"

        # If no aromatic interaction was found, return 0
        return "0"
Example #2
0
    def check_inter(self, molA, molB, patternA, patternB, distCutoff):
        '''
        Function looping over the atoms of a residue and the ligand
        Depending on the pattern arguments, it will check for a type of
        interaction, and return 1 as soon as it found it, otherwise return 0
        '''

        # Look for pattern in residue
        try:
            for matchA in patternA.Match(molA):
                for atomA in matchA.GetTargetAtoms():

                    # Look for pattern in ligand
                    for matchB in patternB.Match(molB):
                        for atomB in matchB.GetTargetAtoms():

                            # Check distance between those atoms
                            dist = oechem.OEGetDistance(
                                molA, atomA, molB, atomB)

                            if dist <= distCutoff:
                                return "1"
        except SystemError:
            pass

        # Interaction not found between this residue and the ligand
        return "0"
Example #3
0
    def _calc_properties(mol: oechem.OEMol) -> danceprops.DanceProperties:
        """
        Calculates properties of the given molecule and returns a
        DanceProperties object holding them.

        Based on Victoria Lim's am1wib.py - see
        https://github.com/vtlim/misc/blob/master/oechem/am1wib.py
        """
        props = danceprops.DanceProperties()

        for conf in mol.GetConfs():
            charged_copy = oechem.OEMol(conf)
            results = oequacpac.OEAM1Results()
            if not AM1.CalcAM1(results, charged_copy):
                logging.debug(
                    f"failed to assign partial charges to {mol.GetTitle()}")
                return props
            DanceGenerator._add_charge_props(mol, charged_copy, results)

            # Sum bond orders, bond lengths, and bond angles
            for atom in charged_copy.GetAtoms(oechem.OEIsInvertibleNitrogen()):
                nbors = list(atom.GetAtoms())  # (neighbors)
                ang1 = math.degrees(
                    oechem.OEGetAngle(charged_copy, nbors[0], atom, nbors[1]))
                ang2 = math.degrees(
                    oechem.OEGetAngle(charged_copy, nbors[1], atom, nbors[2]))
                ang3 = math.degrees(
                    oechem.OEGetAngle(charged_copy, nbors[2], atom, nbors[0]))
                props.tri_n_bond_angle = ang1 + ang2 + ang3

                for nbor in nbors:
                    bond_order = results.GetBondOrder(atom.GetIdx(),
                                                      nbor.GetIdx())
                    bond_length = oechem.OEGetDistance(charged_copy, atom,
                                                       nbor)
                    element = nbor.GetAtomicNum()

                    props.tri_n_bonds.append(
                        danceprops.DanceTriNBond(bond_order, bond_length,
                                                 element))
                    props.tri_n_bond_order += bond_order
                    props.tri_n_bond_length += bond_length

                break  # terminate after one trivalent nitrogen
            break  # terminate after one conformation

        return props
Example #4
0
    def check_hbond(self, molA, molB, patternA, patternB, distCutoff,
                    angleCutUp, angleCutLow):
        '''
        Function checking hbond interaction between a residue and the ligand
        Checks for angle between:
            donor electronegative atom - donor proton - acceptor
        '''

        # Look for pattern in residue
        try:
            for matchA in patternA.Match(molA):
                for atomA in matchA.GetTargetAtoms():
                    if str(atomA).split()[1] == 'H':
                        protonA = atomA

                        # Look for pattern in ligand
                        for matchB in patternB.Match(molB):
                            for acceptorB in matchB.GetTargetAtoms():

                                # Check distance between those atoms
                                dist = oechem.OEGetDistance(
                                    molA, protonA, molB, acceptorB)

                                # if the distance meets the cutoff, check angle
                                if dist <= distCutoff:
                                    #print dist, protonA, acceptorB, \
                                    #      molA.GetTitle(), molB.GetTitle()
                                    # Get the electronegative atom linked to
                                    # the proton
                                    for donorA in protonA.GetAtoms():
                                        pass
                                    #print donorA
                                    # Check angle: donorA, protonA, acceptorB
                                    angle = oechem.OEGetAngle(
                                        molA, donorA, molA, protonA, molB,
                                        acceptorB)
                                    #print angle, angleCutUp, angleCutLow
                                    # Compare angle to cutoffs
                                    if angle <= angleCutUp and \
                                            angle >= angleCutLow:
                                        return "1"
        except SystemError:
            pass

        # Interaction not found between this residue and the ligand
        return "0"
Example #5
0
    def check_catPi(self, mol, catPattern, rings, centerMol, ringCenter,
                    catPiDist, catPiAngleUp, catPiAngleLow):
        '''
        Check for the cation-Pi interactions, loops over the rings of one
        molecule, and loops over the cations of the other
        '''

        # Loop over the rings
        for ring in rings:
            # Get the center of that ring
            centerMol.SetCoords(ringCenter, ring[0])

            # Loop over the cations of this 'molecule'
            for catMatch in catPattern.Match(mol):
                for cation in catMatch.GetTargetAtoms():

                    # Check distance between center of ring and cation
                    dist = oechem.OEGetDistance(centerMol, ringCenter, mol,
                                                cation)

                    #print cation, mol.GetTitle(), dist
                    # Check for distance threshold
                    if dist <= catPiDist:

                        # Calculate the vector between the ring's
                        # center and the cation (residue)
                        ringCenterCoords = centerMol.GetCoords(ringCenter)
                        cationCoords = mol.GetCoords(cation)
                        vecRingCation = self.defineVector(
                            ringCenterCoords, cationCoords)

                        # check the angle between the ring's normal,
                        # and the vector between the ring's center
                        # and the cation
                        angle = self.vectorAngle(vecRingCation, ring[2])

                        if angle <= catPiAngleUp or angle >= catPiAngleLow:
                            return "1"

        # If the interaction was not found, return 0
        return "0"