Ejemplo n.º 1
0
    def __init__(
        self,
        pose:
        object = None,  # pyrosetta.rosetta.core.pose.Pose, Pose of starting structure
        score:
        object = None,  # pyrosetta.ScoreFunction, # scorefunction from pyrosetta
        seq_mover:
        object = None,  # pyrosetta.rosetta.protocols.moves.SequenceMover, # sequence of moves between MC evaluations
        n_steps: int = 1000000,
        kT: float = 1,
        output: bool = True,
        out_freq: int = 500,
    ):

        super().__init__()

        # initialize input values
        self.pose = pose
        self._score = score
        self.seq_mover = seq_mover
        self._kT = kT
        self.n_steps = n_steps
        self._output = output
        self._out_freq = out_freq

        if self._output is False:
            self._out_freq = n_steps

        # Build MC Object
        self.mc = pyrosetta.MonteCarlo(self.pose, self._score, self._kT)
        self.mc_trial = pyrosetta.TrialMover(self.seq_mover, self.mc)

        if self._output:
            self.pymol = pyrosetta.PyMOLMover()
            print("Initial Energy :", self.get_energy())
Ejemplo n.º 2
0
 def build_trial_mc_alg(self, mover):
     """
     Write any sequence mover (stored in 'folding_protocols') to a trial object for
     MC simulations. Depends on MC mover, so change any mc parameters (kT, pose, etc.)
     before running this.
     mover: mover object to be added to TrialMover object
     """
     self.trial_mc = pyrosetta.TrialMover(mover, self.mc)
Ejemplo n.º 3
0
    def monte_carlo_fixed(self, pose, mover, score_function, temperature,
                          trajectory, fixed_moves):
        """Performs Metropolis Monte Carlo (MMC) search with a specified
        move, a fixed number of times in different trajectories. Each
        trajectory is created by performing moves from the initial
        conformation passed in the argument.

        Args:
            pose: A pyrosetta Pose object containing initial
                conformation.
            mover: A pyrosetta Mover object derermining the moves in MMC
                search.
            score_function: A pyrosetta ScoreFunction object for scoring
                each move.
            temperature: An int/float defining the temperature of MMC
                search.
            trajectory: A positive int indicating the number of
                trajectories.
            fixed_moves: A positive int indicating the number of moves
                in each trajectory.

        Returns:
            A list containing the population generated by the MMC
            search.
        """
        population = []

        # Perform MMC on all trajectories
        for i in range(trajectory):
            new_pose = pr.Pose()
            new_pose.assign(pose)
            mc = pr.MonteCarlo(new_pose, score_function, temperature)
            trial_mover = pr.TrialMover(mover, mc)

            # Perform MMC for a fixed number of moves
            for j in range(fixed_moves):
                trial_mover.apply(new_pose)
                pose_ca_rmsd = pr.rosetta.core.scoring.CA_rmsd(
                    self.native_pose, new_pose)
                if pose_ca_rmsd < self.last_op_min_ca_rmsd:
                    self.last_op_min_ca_rmsd = pose_ca_rmsd
                    self.last_op_min_ca_rmsd_pose.assign(new_pose)

            population.append(new_pose)

        # Bookkeeping
        self.last_op_energy_evals = (fixed_moves * trajectory)
        self.total_energy_evals += (fixed_moves * trajectory)
        if self.last_op_min_ca_rmsd < self.min_ca_rmsd:
            self.min_ca_rmsd = self.last_op_min_ca_rmsd
            self.min_ca_rmsd_pose.assign(self.last_op_min_ca_rmsd_pose)

        return population
Ejemplo n.º 4
0
    def __init__(self,
                 sequence,
                 BBB_angle=120,
                 BBBB_dihe=180,
                 file_name='outputs/traj.pdb',
                 energy_graph_output=False):
        """
        folding object used for easily implementing different
        movers into a single folding algorithm.

        Arguments
        ---------

        sequence : str
            Sequence of CG residues
        BBB_angle : float
            Desired angle of all B-B-B angles. Generalizes to all backbone models (not working)
        BBBB_angle : float
            Desired dihedral of all B-B-B-B torsion angles. Generalizes to all backbone models (not working)


        """
        # Build CG model and set desired initial angles
        self.pose = pyrosetta.pose_from_sequence(sequence, auto_termini=False)
        self.energy_graph_output = energy_graph_output
        # self.pose = self.set_BBB_angles(self.pose, BBB_angle)
        # self.pose = self.set_BBBB_dihe(self.pose, BBBB_dihe)
        # PyMOL mover, if wanting to visualize
        self.pymol = pyrosetta.PyMOLMover()
        self.pymol.apply(self.pose)

        # randomizer = CG_movers.randomizeBackBone(self.pose)
        # randomizer.apply(self.pose)

        self.pymol.apply(self.pose)
        # Building PDBTrajWriter object, used for writing multiple structures
        # to a single file
        self.PDB_writer = pyrosetta.rosetta.protocols.canonical_sampling.PDBTrajectoryRecorder(
        )
        # self.PDB_writer.apply(self.pose) # write initial structure
        self.PDB_writer.file_name('outputs/traj.pdb')
        self.PDB_writer.stride(100)

        # Define scorefunction terms
        self.scorefxn = pyrosetta.ScoreFunction()
        self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_rep, 1)
        self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_atr, 1)
        self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_intra_atr,
                                 1)
        self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_intra_rep,
                                 1)
        self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_twist, 1)
        self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_bend, 1)
        # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_inter_rep, 1) # segfaults beware!
        # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_inter_atr, 1)
        # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_intra_rep, 1)
        # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_intra_atr, 1)

        # Build standard CG 1-1 movers
        self.small = CG_movers.CGSmallMover(self.pose)
        # self.shear = CG_movers.CGShearMover(self.pose)
        self.small_angle = CG_movers.CGSmallAngleMover(self.pose)

        # Build minimization movers
        self.mini = pyrosetta.rosetta.protocols.minimization_packing.MinMover()
        self.mini.min_type('lbfgs_armijo_nonmonotone')
        self.movemap = pyrosetta.MoveMap()
        self.mini.score_function(self.scorefxn)
        # for atom in self.small_angle.bb_atoms:
        #      self.movemap.set(pyrosetta.rosetta.core.id.DOF_ID(atom , pyrosetta.rosetta.core.id.THETA), True)
        self.movemap.set_bb_true_range(1, self.pose.size())
        self.mini.movemap(self.movemap)

        # Build MC object + Trial Mover (empty for now)
        self.mc = pyrosetta.MonteCarlo(self.pose, self.scorefxn, 1)
        self.trial_mc = pyrosetta.TrialMover()

        # Building variable to store various folding algorithms
        self.folding_protocols = {}

        # Adding a default mover
        self.build_fold_alg('default')
        self.add_folding_move('default', pyrosetta.RepeatMover(self.small, 10))
        # self.add_folding_move('default', pyrosetta.RepeatMover(self.shear, 10))
        self.add_folding_move('default', pyrosetta.RepeatMover(self.mini, 10))
Ejemplo n.º 5
0
 def kT(self, kT):
     self._kT = kT
     self.mc.set_temperature(self.kT)
     self.mc_trial = pyrosetta.TrialMover(self.seq_mover, self.mc)