Esempio n. 1
0
    def set_metal_contacts(self, radius):
        """ For the metals given, sets the contacts of this atom that
        are within a "radius" distance from that metal
        """
        contacts = []

        # If a metal in "all_metals" is a direct neighbor of this residue,
        # then it's definitely a contact, regardless of radius, and doesn't
        # need to be considered further
        metals_temp = self.all_metals
        metals = []
        this_residue_label = self.residue_1_letter + str(self.number)
        for metal_potential in metals_temp:
            if this_residue_label in metal_potential.nearby_residues:
                contacts.append(metal_potential)
            else:
                metals.append(metal_potential)

        for metal in metals:
            metal_coords = [float(x) for x in metal.location.split(",")]
            distance = chimera.distance(
                self.atom.xformCoord(),
                chimera.Point(metal_coords[0], metal_coords[1],
                              metal_coords[2]),
            )
            if distance - ionicRadiusDict.get(metal.type, None) <= radius:
                contacts.append(metal)
        self.metal_contacts = contacts
def accGeneric(donor, donorHyds, acceptor, r2, minAngle):
	if base.verbose:
		print "generic acceptor"
	dp = donor.xformCoord()
	ap = acceptor.xformCoord()
	if donor.element.name == "S":
		r2 = sulphurCompensate(r2)
	if base.verbose:
		print "distance: %g, cut off: %g" % (distance(dp, ap), sqrt(r2))
	if sqdistance(dp, ap) > r2:
		if base.verbose:
			print "dist criteria failed"
		return 0
	if base.verbose:
		print "dist criteria okay"
	 
	ap = acceptor.xformCoord()
	dp = donor.xformCoord()
	for bonded in acceptor.primaryNeighbors():
		bp = bonded.xformCoord()
		if base.verbose:
			print "angle: %g" % angle(bp, ap, dp)
		ang = angle(bp, ap, dp)
		if ang < minAngle:
			if base.verbose:
				print "angle too sharp (%g < %g)" % (ang,
								minAngle)
			return 0
	if base.verbose:
		print "angle(s) okay (all > %g)" % minAngle
	return 1
Esempio n. 3
0
def getShortestPoint(ref_point, point_list):

    shortest_point = None
    shortest_dist = None

    for p in point_list:
        dist = chimera.distance(p, ref_point)
        if (not shortest_dist) or dist < shortest_dist:
            shortest_point = p
            shortest_dist = dist

    return shortest_point
def testPhiPsi(dp, donorHyds, ap, bp, phiPlane, r2, phi, theta):
	if base.verbose:
		print "distance: %g, cut off: %g" % (distance(dp, ap), sqrt(r2))
	if sqdistance(dp, ap) > r2:
		if base.verbose:
			print "dist criteria failed"
		return 0
	if base.verbose:
		print "dist criteria OK"

	if not testPhi(dp, ap, bp, phiPlane, phi):
		return 0

	return testTheta(dp, donorHyds, ap, theta)
Esempio n. 5
0
def _lenAngle(new, n1, n2, tmplMap, bondCache, angleCache):
    from chimera import distance, angle
    bondKey = (n1, new)
    angleKey = (n2, n1, new)
    try:
        bl = bondCache[bondKey]
        ang = angleCache[angleKey]
    except KeyError:
        n2pos = tmplMap[n2].coord()
        n1pos = tmplMap[n1].coord()
        newpos = tmplMap[new].coord()
        bondCache[bondKey] = bl = distance(newpos, n1pos)
        angleCache[angleKey] = ang = angle(newpos, n1pos, n2pos)
    return bl, ang
def test_include_dummies(element,
                         file,
                         charge,
                         geom,
                         dummies_xyz,
                         Model=Model):
    # Right Values
    ANGLE = {
        'tetrahedral': [
            60,
        ],
        'square planar': [90, 45],
        'square pyramid': [90, 45],
        'octahedron': [90, 60, 45],
    }
    # Create metal instance
    metal, metal_class = create_metal_class(element=element,
                                            charge=charge,
                                            geom=geom,
                                            file=file)
    # Initialize variables
    metal_class.dummies_xyz = dummies_xyz
    Model.geometry = geom
    # Func to test
    Model.include_dummies(metal_class)
    # Selecting the included atoms
    number_of_dummies = len(dummies_xyz)
    atoms_to_select = ','.join(
        ['D' + str(i) for i in range(1, number_of_dummies + 1)])
    rc("sel ::" + str(metal.residue.type) + '@' + atoms_to_select)
    dummies = chimera.selection.currentAtoms()

    # Eval Angles between them depending geometry
    for i in range(0, number_of_dummies - 2):
        angle = chimera.angle(dummies[i].labelCoord(),
                              dummies[i + 1].labelCoord(),
                              dummies[i + 2].labelCoord())
        assert (int(round(angle)) in ANGLE[geom])
    # Eval Bonds between Dummy&Metal center
    for i in range(0, number_of_dummies):
        bond = chimera.distance(dummies[i].labelCoord(), metal.labelCoord())
        assert (abs(bond - 0.9) < 0.001)
Esempio n. 7
0
def linearPos(bondee, bonded, bondLen, toward=None, away=None):
    newBonded = []
    curBonded = bonded[:]
    if len(bonded) == 0:
        if away:
            # need 90 angle, rather than directly away
            # (since otherwise second added position will then be
            # directly towards)
            ninety = rightAngle(away - bondee)
            away = bondee + ninety
        pos = singlePos(bondee, bondLen, toward, away)
        newBonded.append(pos)
        curBonded.append(pos)

    if len(curBonded) == 1:
        bondedDist = distance(bondee, curBonded[0])
        bondVec = bondee - curBonded[0]
        bondVec.length = bondLen
        newBonded.append(bondee + bondVec)
    return newBonded
Esempio n. 8
0
def linearPos(bondee, bonded, bondLen, toward=None, away=None):
	newBonded = []
	curBonded = bonded[:]
	if len(bonded) == 0:
		if away:
			# need 90 angle, rather than directly away
			# (since otherwise second added position will then be
			# directly towards)
			ninety = rightAngle(away - bondee)
			away = bondee + ninety
		pos = singlePos(bondee, bondLen, toward, away)
		newBonded.append(pos)
		curBonded.append(pos)
	
	if len(curBonded) == 1:
		bondedDist = distance(bondee, curBonded[0])
		bondVec = bondee - curBonded[0]
		bondVec.length = bondLen
		newBonded.append(bondee + bondVec)
	return newBonded
def accThetaTau(donor, donorHyds, acceptor, upsilonPartner, r2,
						upsilonLow, upsilonHigh, theta):
	if base.verbose:
		print "accThetaTau"
	dp = donor.xformCoord()
	ap = acceptor.xformCoord()

	if donor.element.name == "S":
		r2 = sulphurCompensate(r2)
	if base.verbose:
		print "distance: %g, cut off: %g" % (distance(dp, ap), sqrt(r2))
	if sqdistance(dp, ap) > r2:
		if base.verbose:
			print "dist criteria failed"
		return 0
	if base.verbose:
		print "dist criteria okay"
	
	if upsilonPartner:
		upPos = upsilonPartner.xformCoord()
	else:
		# upsilon measured from "lone pair" (bisector of attached
		# atoms)
		bondedPos = []
		for bonded in acceptor.primaryNeighbors():
			bondedPos.append(bonded.xformCoord())
		lonePairs = bondPositions(ap, tetrahedral, 1.0, bondedPos)
		bisectors = []
		for lp in lonePairs:
			bisectors.append(ap - (lp - ap))
		upPos = bisectors[0]
		for bs in bisectors[1:]:
			if base.verbose:
				print "Testing 'extra' lone pair"
			if testThetaTau(dp, donorHyds, ap, bs,
						upsilonLow, upsilonHigh, theta):
				return 1
	return testThetaTau(dp, donorHyds, ap, upPos,
						upsilonLow, upsilonHigh, theta)
Esempio n. 10
0
    def set_metal_contacts(self, radius):
        """ Set contacts between this residue and metals at a given radius
        """
        contacts = []

        for metal in self.all_metals:
            for atom in self.atoms:
                # Set the coordinates of this metal in a way that Point()
                # can accept
                metal_coords = [float(x) for x in metal.location.split(",")]
                # Get the distance between this atom and this metal
                distance = chimera.distance(
                    atom.xformCoord(),
                    chimera.Point(metal_coords[0], metal_coords[1],
                                  metal_coords[2]),
                )
                # If we're within the distance expected, add this metal
                # to the list and move to the next
                if distance - ionicRadiusDict.get(metal.type, None) <= radius:
                    contacts.append(metal)
                    break

        self.metal_contacts = contacts
            string = str(residue) + " " + str(
                aaDict[type]) + " " + str(name) + '.' + altLoc
        string = re.sub(r" ARG ", ":", string)
        string = re.sub(r" LYS ", ":", string)
        string = re.sub(r" PRO ", ":", string)
        string = re.sub(r" THR ", ":", string)
        string = re.sub(r" TRP ", ":", string)

        # For rlbcoor data.
        resTypeChain = str(residue) + " A"
        resTypeChain = re.sub(r"#0 ", "", resTypeChain)
        resTypeChainIndex[string] = str(resTypeChain)
        xformCoordIndex[string] = str(a1.xformCoord())
        counter2 = 0
        for a2 in atoms:
            distance = chimera.distance(a1.xformCoord(), a2.xformCoord())
            distMatrix[counter2][counter1] = str(distance)
            counter2 = counter2 + 1
        counter1 = counter1 + 1

### EXAMPLES OF WRITING VARIABLES TO OUTPUT FILES.
# PRINT OUT ALL RESULTS.
    f_distMatrix.write("\t")
    for a1 in atomsList:
        atom1 = str(a1)
        f_distMatrix.write(atom1)
        f_distMatrix.write("\t")
    f_distMatrix.write("\n")

    for a1 in atomsList:
        atom1 = str(a1)
Esempio n. 12
0
 def distance_regular(self, other_atom):
     """ Gets the distance between this and a regular atom
     """
     return chimera.distance(self.atom.xformCoord(),
                             other_atom.xformCoord())
Esempio n. 13
0
 def distance(self, other_atom):
     """ Gets the distance between this and another extendedAtom
     """
     return chimera.distance(self.atom.xformCoord(),
                             other_atom.atom.xformCoord())