Exemple #1
0
 def isPointNearAnyHeavyAtom(self, point, tolerance):
   nonZeroRadiiXyz = self.getHeavyAtomXYZ() #cache if necessary
   toleranceSquared = tolerance
   for coord in nonZeroRadiiXyz:
     if geometry.distL2Squared(coord, point) < toleranceSquared:
       return True
   return False
Exemple #2
0
 def getNearbyResidues(self, pointList, nearbyDistance=0.):
   '''returns a new pdb of residues in this pdb near the points given'''
   nearbyDistanceSquared = nearbyDistance ** 2.
   residuesNearPts = []
   for pt in pointList:
     for index,coord in enumerate(self.coords):
       distanceBetweenSquared = geometry.distL2Squared(pt, coord)
       if distanceBetweenSquared < nearbyDistanceSquared:   
         residueNumber = self.resNums[index]
         chain = self.chains[index]
         resChain = str(residueNumber) + str(chain)
         if resChain not in residuesNearPts: #guarantee uniqueness
           residuesNearPts.append(resChain)
   residuesNearPts.sort()
   return self.getListResiduesChains(residuesNearPts)
Exemple #3
0
 def getNearbyAtoms(self, pointList, nearbyDistance=0.):
   '''returns the list of line numbers of atoms '''  
   lines = {}
   if nearbyDistance > 0.: #actually do distance cutoff
     nearbyDistanceSquared = nearbyDistance ** 2.
     for pt in pointList:
       tempSet = set()
       for index,coord in enumerate(self.coords):
         distanceBetween = geometry.distL2Squared(pt, coord)
         if distanceBetween < nearbyDistanceSquared:   
           tempSet.update([self.atomToRaw[index]])
       tempList = list(tempSet)
       tempList.sort()
       lines[tuple(pt)] = tempList
   else: #just find closese atom for each pt
     for pt in pointList:
       bestDist, bestPt = 10000000., False
       for index,coord in enumerate(self.coords):
         distanceBetween = geometry.distL2Squared(pt, coord)
         if distanceBetween < bestDist:   
           bestPt = self.atomToRaw[index]
           bestDist = distanceBetween
       lines[tuple(pt)] = [bestPt] #still needs to be a list
   return lines
Exemple #4
0
 def calcRMSD(self, other, alphas=False):
   '''calculates rmsd of all atoms between self and other, no checking or 
   alignment is done'''
   squaredSum = 0.0
   badData = 0 #keeps track of missing atoms (some NMR models wrong)
   for index, coord in enumerate(self.coords):
     if not alphas or self.atoms[index][0:2] == "CA":
       try: 
         otherCoord = other.coords[index]
         squaredSum += geometry.distL2Squared(coord, otherCoord)    
       except IndexError:
         badData += 1
     else:
       badData += 1 #also keep track of non-carbon alphas when looking for CA
   #print squaredSum, (len(self.coords) - badData)
   squaredSum /= (len(self.coords) - badData)
   return squaredSum**0.5
Exemple #5
0
 def clusterAtoms(self, distanceCutoff=2.0):
   '''breaks into distinct unions of atoms based on distance cutoff'''
   ligandClusters = unionfind2.unionFind()
   cutoffSquared = distanceCutoff ** 2. #faster comparisons
   for index,coord in enumerate(self.coords):
     for index2,coord2 in enumerate(self.coords):
       if index2 > index: #only do comparisons once each
         distBetweenSquared = geometry.distL2Squared(coord, coord2)
         if distBetweenSquared <= cutoffSquared:
           ligandClusters.union(index, index2)
   clusteredLists = ligandClusters.toLists()
   newPdbs = [] #list of pdbData objects to return
   for oneCluster in clusteredLists:
     newPdb = self.copy()
     markedForRemoval = []
     for index in xrange(len(self.coords)):
       if index not in oneCluster:
         markedForRemoval.append(index)
     for index in markedForRemoval:
       newPdb.removeLine(newPdb.atomToRaw[index])
     newPdbs.append(newPdb)
   return newPdbs