Exemple #1
0
 def calculates(self, cell):
     if self.__isLocalSearch:
         newcell = self.__LocalSearch.initLocalSearch(cell)
     else:
         newcell = Gene()
         newcell.copyGene(cell)  #copy.deepcopy(cell)
     auxLigand = copy.deepcopy(self.__ligand)
     if self.__isKB:
         for i in range(len(auxLigand.branch)):
             torAngle = auxLigand.rotateBranchKB(i, newcell.rotateBonds[i])
             auxLigand.rotateAtomsBranch(i, torAngle)
     else:
         for i in range(len(auxLigand.branch)):
             auxLigand.rotateAtomsBranch(i, newcell.rotateBonds[i])
     auxLigand.translateToPoint([
         self.__centerSpace[0] + newcell.x,
         self.__centerSpace[1] + newcell.y,
         self.__centerSpace[2] + newcell.z
     ])
     sphVect = spherePoint(1, newcell.sph_theta, newcell.sph_phi)
     auxLigand.rotateByVector(sphVect, newcell.theta)
     auxLigand.writePDBQT(self.__temporalDir + "ligand.pdbqt")
     newcell.score = calculateFreeEnergy()
     self.__numberScoring += 1
     return newcell  #copy.deepcopy(newcell)
Exemple #2
0
 def getNeighbor(self, cell):
     newCell = Gene()
     newCell.copyGene(cell)
     if self.__typeLS == 0:
         newCell = self.mutationBlock(newCell)
     elif self.__typeLS == 1:
         alpha = self.__tempIterative
         newCell = self.mutationReduce(newCell, alpha)
     elif self.__typeLS == 2:
         newCell = self.mutationRot(newCell)
     newCell = self.calculates(newCell)
     return newCell
Exemple #3
0
 def initLocalSearch(self, cell):
     #print "Init Local Search..."
     self.__tempIterative = 1.0
     T = self.__temp
     oldCell = Gene()
     oldCell.copyGene(cell)
     while T > self.__tempMin:
         j = 1
         while j <= self.__numIteration:
             newCell = self.getNeighbor(oldCell)
             criteria = self.accptance(oldCell, newCell, T)
             if criteria > random.random():
                 oldCell.copyGene(newCell)
             j += 1
         T *= self.__tempAlpha
         self.__tempIterative *= self.__alphaIt
     return oldCell
	def getNeighbor(self, cell):
		newCell = Gene()
		newCell.copyGene(cell)
		if self.__typeLS == 0:
			newCell = self.mutationBlock(newCell)
		elif self.__typeLS == 1:
			alpha = self.__tempIterative
			newCell = self.mutationReduce(newCell, alpha)
		elif self.__typeLS == 2:
			newCell = self.mutationRot(newCell)
		elif self.__typeLS == 3:
			localOpt = random.randint(1,3)
			if localOpt == 1:
				newCell = self.mutationBlock(newCell)
				self.__normalLSCount+=1
			elif localOpt == 2:
				alpha = self.__tempIterative
				newCell = self.mutationReduce(newCell, alpha)
				self.__redLSCount+=1
			elif localOpt == 3:
				newCell = self.mutationRot(newCell)
				self.__rotLSCount+=1
		elif self.__typeLS == 4:
			localOpt = random.uniform(0,1)
			if localOpt <= 0.1:
				newCell == self.mutationBlock(newCell)
				self.__normalLSCount+=1
			elif localOpt <= 0.35:
				alpha = self.__tempIterative
				newCell = self.mutationReduce(newCell, alpha)
				self.__redLSCount+=1
			elif localOpt > 0.35:
				newCell == self.mutationRot(newCell)
				self.__rotLSCount+=1
		newCell = self.calculates(newCell)
		return newCell