def movemap(pose, PDB_out=False): """ Demonstrates the syntax necessary for basic usage of the MoveMap object performs these changes with a demonstrative backbone minimization using <pose> and writes structures to PDB files if <PDB_out> is True """ ######### # MoveMap # a MoveMap encodes what data is allowed to change in a Pose, referred to as # its degrees of freedom # a MoveMap is separate from a Pose and is usually required by a Mover so # that the correct degrees of freedom are manipulated, in this way, # MoveMap and Pose objects often work in parallel # several MoveMap's can correspond to the same Pose # a MoveMap stores information on a per-residue basis about the # backbone ({phi, psi, omega}) and chi ({chi_i}) torsion angle sets # the MoveMap can only set these sets of torsions to True or False, it # cannot set freedom for the individual angles (such as phi free and psi # fixed) # the MoveMap has no upper-limit on its residue information, it defaults to # all residues (up to residue 99999999) backbone and chi False # you can view the MoveMap per-residue torsion settings by using the # MoveMap.show( Pose.total_residue() ) method (the input argument is the # highest residue to output, it does not support viewing a range) pose_move_map = MoveMap() # change all backbone torsion angles pose_move_map.set_bb(True) # change all chi angle torsion angles (False by default) pose_move_map.set_chi(False) # change a single backbone torsion angles #pose_move_map.set_bb(1, True) # example syntax # change a single residue's chi torsion angles #pose_move_map.set_chi(1, True) # example syntax pose_move_map.show(pose.total_residue()) # perform gradient based minimization on the "median" residues, this # method (MinMover) determines the gradient of an input pose using a # ScoreFunction for evaluation and a MoveMap to define the degrees of # freedom # create a standard ScoreFunction scorefxn = get_fa_scorefxn( ) # create_score_function_ws_patch('standard', 'score12') # redefine the MoveMap to include the median half of the residues # turn "off" all backbone torsion angles pose_move_map.set_bb(False) # reset to backbone False # turn "on" a range of residue backbone torsion angles pose_move_map.set_bb_true_range(int(pose.total_residue() / 4), int(pose.total_residue() * 3 / 4)) # create the MinMover minmover = protocols.minimization_packing.MinMover() minmover.score_function(scorefxn) minmover.movemap(pose_move_map) # create a copy of the pose test_pose = Pose() test_pose.assign(pose) # apply minimization scorefxn(test_pose) # to prevent verbose output on the next line pymover = PyMOLMover() #### uncomment the line below and "comment-out" the two lines below to #### export the structures into different PyMOL states of the same object #pymover.keep_history = True # enables viewing across states #### comment-out the line below, changing PDBInfo names tells the #### PyMOLMover to produce new objects test_pose.pdb_info().name('original') pymover.apply(test_pose) print('\nPre minimization score:', scorefxn(test_pose)) minmover.apply(test_pose) if PDB_out: test_pose.dump_pdb('minimized.pdb') print('Post minimization score:', scorefxn(test_pose)) #### comment-out the line below test_pose.pdb_info().name('minimized') pymover.apply(test_pose)
print('Refinement ----------------------------------------------') kT = 1.0 n_moves = 10 pose = core.import_pose.pose_from_file("../test/data/test_fragments.pdb") pose_frag = core.import_pose.pose_from_file("../test/data/test_fragments.pdb") print('setting up a move map') movemap = MoveMap() print('setting all backbone movement to true, and residue 10 to false') movemap.set_bb(True) movemap.set_bb(10, False) print('outputting movemap') movemap.show(pose.total_residue()) fragset3mer = core.fragment.ConstantLengthFragSet( 3, "../test/data/test3_fragments") # "aatestA03_05.200_v1_3") fragset9mer = core.fragment.ConstantLengthFragSet( 9, "../test/data/test9_fragments") # "aatestA09_05.200_v1_3") print('mover: ClassicFragmentMover, 3mer') movemap.set_bb(True) mover_3mer = protocols.simple_moves.ClassicFragmentMover(fragset3mer, movemap) mover_3mer.apply(pose_frag) print('Creating standard score function with patch and scoring') scorefxn = get_score_function() scorefxn(pose) print('mover: SmallMover')