How to use the pdb2pqr.pdb2pqr.utilities.distance function in pdb2pqr

To help you get started, we’ve selected a few pdb2pqr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / debump.py View on Github external
closeresidue = closeatom.residue
            if closeresidue == residue:
                continue
            if not isinstance(closeresidue, (aa.Amino, aa.WAT)):
                continue
            if isinstance(residue, aa.CYS):
                if residue.ss_bonded_partner == closeatom:
                    continue

            # Also ignore if this is a donor/acceptor pair
            if atom.is_hydrogen and atom.bonds[0].hdonor and closeatom.hacceptor:
                continue
            if closeatom.is_hydrogen and closeatom.bonds[0].hdonor and atom.hacceptor:
                continue

            dist = util.distance(atom.coords, closeatom.coords)

            if isinstance(closeresidue, aa.WAT):
                if dist < bestwatdist:
                    bestwatdist = dist
                    bestwatatom = closeatom
            else:
                if dist < bestdist:
                    bestdist = dist
                    bestatom = closeatom

        if bestdist > bestwatdist:
            txt = ("Skipped atom during water optimization: %s in %s skipped "
                   "when optimizing %s in %s") % (bestwatatom.name,
                                                  bestwatatom.residue,
                                                  atom.name, residue)
            _LOGGER.warning(txt)
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / hydrogens.py View on Github external
else:
                hname1 = name

        bondatom1 = residue.get_atom(optinstance.map[hname1].bond)
        bondatom2 = residue.get_atom(optinstance.map[hname2].bond)
        longflag = 0

        # If one bond in the group is significantly (0.05 A)
        # longer than the other, use that group only
        for pivotatom in bondatom1.bonds:
            if not pivotatom.is_hydrogen:
                the_pivatom = pivotatom
                break

        dist1 = distance(the_pivatom.coords, bondatom1.coords)
        dist2 = distance(the_pivatom.coords, bondatom2.coords)

        order = [hname1, hname2]

        if dist2 > dist1 and abs(dist1 - dist2) > 0.05:
            longflag = 1
            order = [hname2, hname1]

        elif dist1 > dist2 and abs(dist1 - dist2) > 0.05:
            longflag = 1
            order = [hname1, hname2]

        for hname in order:
            bondatom = residue.get_atom(optinstance.map[hname].bond)

            # First mirror the hydrogen about the same donor
            for dihedral in residue.reference.dihedrals:
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / debump.py View on Github external
continue
            if isinstance(residue, aa.CYS):
                if residue.ss_bonded_partner == closeatom:
                    continue

            # Also ignore if this is a donor/acceptor pair
            pair_ignored = False
            if atom.is_hydrogen and len(atom.bonds) != 0 and atom.bonds[0].hdonor \
               and closeatom.hacceptor:
                continue

            if closeatom.is_hydrogen and len(closeatom.bonds) != 0 and closeatom.bonds[0].hdonor \
                   and atom.hacceptor:
                continue

            dist = util.distance(atom.coords, closeatom.coords)
            other_size = BUMP_HYDROGEN_SIZE if closeatom.is_hydrogen else BUMP_HEAVY_SIZE
            cutoff = atom_size + other_size
            if dist < cutoff:
                bumpscore = bumpscore + 1000.0
                if pair_ignored:
                    _LOGGER.debug('This bump is a donor/acceptor pair.')
        _LOGGER.debug('BUMPSCORE %s', str(bumpscore))
        return bumpscore
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / hydrogens.py View on Github external
# We want to ignore the Hs on the acceptor
        if self.is_carboxylic_hbond(donor, acc):

            # Eliminate the closer hydrogen
            hyds = []
            dist = None
            donorhatom = None
            for hatom in self.hlist:
                if hatom.is_hydrogen:
                    hyds.append(hatom)

            if len(hyds) < 2:
                return 1

            dist = distance(hyds[0].coords, donor.coords)
            dist2 = distance(hyds[1].coords, donor.coords)
            # Eliminate hyds[0]
            if dist < dist2:
                self.hlist.remove(hyds[0])
                self.routines.cells.remove_cell(hyds[0])
                residue.remove_atom(hyds[0].name)
                donorhatom = residue.get_atom(hyds[1].name)
            elif hyds[1] in self.hlist:
                self.hlist.remove(hyds[1])
                self.routines.cells.remove_cell(hyds[1])
                residue.remove_atom(hyds[1].name)
                if residue.has_atom(hyds[0].name):
                    donorhatom = residue.get_atom(hyds[0].name)
                elif len(self.hlist) != 0 and residue.has_atom(self.hlist[0].name):
                    donorhatom = residue.get_atom(self.hlist[0].name)

            # If only one H is left, we're done
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / hydrogens / structures.py View on Github external
addname = "H1"
        else:
            addname = "H2"

        _LOGGER.debug("Finalizing %s by adding %s (%i current O bonds)",
                      residue, addname, len(atom.bonds))

        if len(atom.bonds) == 0:

            newcoords = []

            # Build hydrogen away from closest atom
            closeatom = self.routines.get_closest_atom(atom)
            if closeatom != None:
                vec = util.subtract(atom.coords, closeatom.coords)
                dist = util.distance(atom.coords, closeatom.coords)

                for i in range(3):
                    newcoords.append(vec[i]/dist + atom.coords[i])

            else:
                newcoords = util.add(atom.coords, [1.0, 0.0, 0.0])

            residue.create_atom(addname, newcoords)
            self.routines.cells.add_cell(residue.get_atom(addname))

            self.finalize()

        elif len(atom.bonds) == 1:

            # Initialize variables
            pivot = atom.bonds[0]
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / hydrogens.py View on Github external
continue

            # Check the H(D)-A distance
            dist = distance(donorhatom.coords, acc.coords)
            if dist > DIST_CUTOFF:
                continue

            # Ensure no conflicts if H(A)s if present
            flag = 1
            for acchatom in acc.bonds:
                if not acchatom.is_hydrogen:
                    continue
                flag = 0

                # Check the H(D)-H(A) distance
                hdist = distance(donorhatom.coords, acchatom.coords)
                if hdist < 1.5:
                    continue

                # Check the H(D)-H(A)-A angle
                angle = self.get_hbond_angle(donorhatom, acchatom, acc)
                if angle < 110.0:
                    flag = 1

            if flag == 0:
                continue

            # Check the A-D-H(D) angle
            angle = self.get_hbond_angle(acc, donor, donorhatom)
            if angle <= ANGLE_CUTOFF:
                _LOGGER.debug("Found HBOND! %.4f %.4f", dist, angle)
                return 1
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / hydrogens.py View on Github external
def is_carboxylic_hbond(self, donor, acc):
        """Determine whether this donor acceptor pair is a hydrogen bond"""
        for donorhatom in donor.bonds:
            if not donorhatom.is_hydrogen:
                continue

            # Check the H(D)-A distance
            dist = distance(donorhatom.coords, acc.coords)
            if dist > DIST_CUTOFF:
                continue

            # Check the A-D-H(D) angle
            angle = self.get_hbond_angle(acc, donor, donorhatom)
            if angle <= ANGLE_CUTOFF:
                _LOGGER.debug("Found HBOND! %.4f %.4f", dist, angle)
                return 1

        # If we get here, no bond is formed
        return 0
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / hydrogens.py View on Github external
addname = "H1"
        else:
            addname = "H2"

        _LOGGER.debug("Finalizing %s by adding %s (%i current O bonds)",
                      residue, addname, len(atom.bonds))

        if len(atom.bonds) == 0:

            newcoords = []

            # Build hydrogen away from closest atom
            closeatom = self.routines.get_closest_atom(atom)
            if closeatom != None:
                vec = subtract(atom.coords, closeatom.coords)
                dist = distance(atom.coords, closeatom.coords)

                for i in range(3):
                    newcoords.append(vec[i]/dist + atom.coords[i])

            else:
                newcoords = add(atom.coords, [1.0, 0.0, 0.0])

            residue.create_atom(addname, newcoords)
            self.routines.cells.add_cell(residue.get_atom(addname))

            self.finalize()

        elif len(atom.bonds) == 1:

            # Initialize variables
            pivot = atom.bonds[0]
github Electrostatics / apbs-pdb2pqr / pdb2pqr / pdb2pqr / hydrogens / structures.py View on Github external
if addname == "H1":
                self.finalize()

            residue.fixed = 1

        elif len(atom.bonds) == 2:

            loc1, loc2 = self.get_positions_with_two_bonds(atom)
            residue.create_atom(addname, loc1)
            newatom = residue.get_atom(addname)
            self.routines.cells.add_cell(newatom)

            # Debump residue if necessary by trying the other location
            nearatom = self.routines.get_closest_atom(newatom)
            if nearatom != None:
                dist1 = util.distance(newatom.coords, nearatom.coords)

                # Place at other location
                self.routines.cells.remove_cell(atom)
                newatom.x = loc2[0]
                newatom.y = loc2[1]
                newatom.z = loc2[2]
                self.routines.cells.add_cell(atom)

                nearatom = self.routines.get_closest_atom(newatom)
                if nearatom != None:

                    # If this is worse, switch back
                    if util.distance(newatom.coords, nearatom.coords) < dist1:
                        self.routines.cells.remove_cell(atom)
                        newatom.x = loc1[0]
                        newatom.y = loc1[1]