def test(): acl = Egor.from_pdbfile( pdbfile='output/PAU-WEI-b9b-8_NIT2/pre_PAU-WEI-b9b-8_NIT2.pdb', params_file='output/PAU-WEI-b9b-8_NIT2/PAU-WEI-b9b-8_NIT2.params', constraint_file='cysBound.noCY.cst') acl.coordinate_constraint = 100 print('initial') print(acl.ligand_score()) print(acl.ligand_residue) # AtomPair SG 145A HE2 41A HARMONIC 1.8 0.2 print(acl.key_residues) r = acl.pose.pdb_info().pdb2pose(res=41, chain='A') MutateResidue = pyrosetta.rosetta.protocols.simple_moves.MutateResidue MutateResidue(target=r, new_res='HIS_D').apply(acl.pose) MutateResidue(target=r, new_res='HIS').apply(acl.pose) pymover = pyrosetta.PyMOLMover() pymover.pymol_name(f'initial') native = acl.pose.clone() pymover.apply(native) acl.pose = native.clone() acl.minimise(10) pymover.pymol_name(f'relaxed') pymover.apply(acl.pose) print('cartesian relaxed') print(acl.ligand_score()) acl.pose.dump_pdb('egor_test.pdb')
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())
def test_CGSmallAngleMover(): pymol = pyrosetta.PyMOLMover() pose = pyrosetta.pose_from_sequence( 'X[CG11x3:CGLower]X[CG11x3]X[CG11x3][CG11x3:CGUpper]') conf = pose.conformation() small_mover = cg_pyrosetta.CG_movers.CGSmallAngleMover(pose) # print(small_mover.bond_angles) assert len(small_mover.bond_angles) != 0 pymol.apply(pose) for angle in small_mover.bond_angles: print("Changing Angle:", angle[0], angle[1], angle[2]) old_angle = conf.bond_angle(angle[0], angle[1], angle[2]) conf.set_bond_angle(angle[0], angle[1], angle[2], old_angle + 10 * np.pi / 180) pymol.apply(pose) assert conf.bond_angle(angle[0], angle[1], angle[2]) == pytest.approx(old_angle + 10 * np.pi / 180)
#!/usr/bin/env python # :noTabs=true: from __future__ import print_function import rosetta, pyrosetta pyrosetta.init( extra_options="-constant_seed" ) # WARNING: option '-constant_seed' is for testing only! MAKE SURE TO REMOVE IT IN PRODUCTION RUNS!!!!! import os os.chdir('.test.output') pose = pyrosetta.pose_from_sequence('EVAAAVAT') pymol = pyrosetta.PyMOLMover() pymol.apply(pose) scorefxn = pyrosetta.get_fa_scorefxn( ) # rosetta.create_score_function('standard') scorefxn(pose) pymol.send_energy(pose) #pymol.send_energy(pose, label=True) DEPRECATED: needed to be ported to C++ version #pymol.send_colors(pose, {}, default_color="orange") pymol.send_colors(pose, rosetta.std.map_int_int(), default_color=rosetta.protocols.moves.XC_orange)
while offset < 3: phi, psi, omega, description = fragment[offset] frag_description += description + "\n" pose.set_phi(position + offset, phi) pose.set_psi(position + offset, psi) pose.set_omega(position + offset, omega) offset += 1 return frag_description seq = 'MIKVTVTNSFFEVTGHAPDKTLCASVSLLTQHVANFLKAEKKAKIKKESGYLKVKFEELENCEVKVLAAMVRSLKELEQKFPSQIRVEVIDNGS' three_mer_file = '../Projects/homework/homework_folding/structure_prediction/1S12/1S12.200.3mers' nine_mer_file = '../Projects/homework/homework_folding/structure_prediction/1S12/1S12.200.9mers' fragments = angles_from_file(three_mer_file) pose = pyrosetta.pose_from_sequence(seq) pmm = pyrosetta.PyMOLMover() pmm.apply(pose) accepted = 0 rejected = 0 scorefxn = pyrosetta.teaching.get_fa_scorefxn() score = scorefxn(pose) best_score = score best_pose = pyrosetta.pose_from_sequence(seq) best_pose.assign(pose) new_pose = pyrosetta.pose_from_sequence(seq) frag_mover = fragment_mover_init(frag_file=three_mer_file, frag_length=3)
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))