Example #1
0
    def apply( self, pose, steps, run_tag=None, mer=9 ): # this is silly to put the mer here, as a indicator to name a null_frag_id )
        ''' '''
        assert isinstance( pose, Pose )
        assert pose._initialized

        self._scorefxn.update_pose( pose ) # make sure the pose in the score function to score with is the current one

        for step in range( steps ):
            pos = random.sample( pose._dict.keys(), 1 )[0] 

            boltzmann = Boltzmann( self._temperature )
            candidate_frags = self._scorefxn._density_score_dict[ pos ].keys() # this has included a "null_frag_id" when initialize density_score_dict

            ''' After picking a position to optimize, calculate compatibility scores for all the candidate placements at that residue '''
            for frag_id in candidate_frags:

                container = self._scorefxn.score_evaluator( frag_id )
                boltzmann.probability( container )

            #### end of calculating all the candidate_frags at the residue to the selected ones ####

            # normalize it 
            boltzmann.normalization()

            # pick one frag
            selected_frag_id = boltzmann.pick_frag()
            #print "step %s: frag_id: %s %s got picked!!" %( step, selected_frag_id, boltzmann._norm_dict[ selected_frag_id ] )

            # update pose
            SelectedContainer = self._scorefxn.score_evaluator( selected_frag_id ) # bc this only return scores
            SelectedContainer.update_boltz( boltzmann )

            pose.update_pose_dict_by_rsd( SelectedContainer )
            self._scorefxn.update_pose( pose )