You are here

Structure not changing after pose.set_phi

1 post / 0 new
Structure not changing after pose.set_phi
#1

Hi, I am trying to implement the Generalized Simulated Annealing routine (Tsalis et al, 1996) and apply it on folding processes.

To do so, I code the mover w.r.t. dihedral angles (each step phi and psi sufer a small, guided perturbation). I am using the pose.set_phi and .set_psi methods to modify pose coordinates. 

The problem:

When I do apply the Mover, it wont modify the pose at all. I alread tried several approaches to overload the Mover class, but none of them work. The last atempt will be down here. I also tried modifying the "Basic folding" example to move with all phi and psi at once, but it didn't worked as well. It, strangely, only works if, at each step, I change only phi and psi of one residue (in the same fashion as the basic folding example).

The code:

    
class GSAMover(pyrosetta.rosetta.protocols.moves.Mover):
    """
    GSA Mover:
    """
    def __init__(self, **kwargs):
        pyrosetta.rosetta.protocols.moves.Mover.__init__(self)
        
        # . . . Just poping parameters from kwargs
        
    def fetch_dihedrals(self, pose):
        ''' Get protein's dihedral angles '''
        seqLen = len(pose.sequence())
        dih = np.empty((seqLen,2))
        for i in range(seqLen):
            dih[i,] = np.asarray([pose.phi(i+1),pose.psi(i+1)])
        return dih
    
    def modify_type1(self, pose):
        dihs = self.fetch_dihedrals(pose)
        # x + g(r)
        dihs = np.add(dihs, np.degrees(self.g(self.r_i)))
        for i,dih in enumerate(dihs[1:]):
            pose.set_phi(i+2,dih[0])
            pose.set_psi(i+2,dih[1])
        return pose
    
    def apply(self, pose):
        """Applies move to pose."""
        
        self.best_pose = Pose()
        self.previous_pose = Pose()
        #pose = pose.get()
        for self.epoch in range(self.max_iter):
            if self.epoch == 0:
                self.best_pose.assign(pose)
                self.previous_pose.assign(pose)
            self.pose_zero = Pose()
            self.pose_zero.assign(pose)

            self.pose_modified = Pose()
            self.pose_modified.assign(self.modifyPose(pose))
            
            pose.assign(self.decisionCriteria(self.pose_modified,
                                              self.pose_zero))

            if self.verbose:
                print('** Runing iteration: {}'.format(self.epoch))
                
            if self.score(pose) < self.score(self.best_pose):
                self.best_pose.assign(pose)

            self.log['temperature'].append(self.tqt)
            self.log['g'].append(self.g(self.r_i))
            self.previous_pose.assign(pose)

 

Are there any other steps/methods required for me to move the pose?

Thank you for your attention.

Category: 
Post Situation: 
Thu, 2020-11-05 09:34
publicclass