def apply( self, pose, steps ): ''' refactor it to take indices - avoid any lookup during the run ''' assert isFragIdxPose( pose ) self.__scorefxn.update_pose( pose ) # make sure the pose in the score function to score with is the current one # for each step, randomly select one pos to optimize for step in range( steps ): pos = random.sample( pose.positions(), 1 )[0] boltzmann = Boltzmann( self._temperature ) ''' After picking a position to optimize, calculate compatibility scores for all the candidate placements at that residue ''' for frag_idx in self.__scorefxn.get_candidate_frags( pos ): score = self.__scorefxn( frag_idx ) # evaluate the score here #print score, frag_idx boltzmann.cal_probability( frag_idx, score ) # the residue is designed for storing scores information in residue for future debugging boltzmann.normalization() #### end of calculating all the candidate_frags at the residue to the selected ones #### # pick one frag, return an Residue object with updated boltzmann which stores probability of all the candidate frags at that residue selected_frag_idx = boltzmann.pick_frag() # return frag_idx pose.update_residue( pos, selected_frag_idx ) # shall update pos and the selected frag_idx self.__scorefxn.update_pose( pose )