Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
loops_kic.py
Go to the documentation of this file.
1 # (c) Copyright Rosetta Commons Member Institutions.
2 # (c) This file is part of the Rosetta software suite and is made available under license.
3 # (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
4 # (c) For more information, see http://www.rosettacommons.org. Questions about this can be
5 # (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
6 from rosetta import *
7 from sys import exit
8 from random import randrange
9 import math
10 
11 # Demonstrates loop remodeling with kinematic closure (KIC).
12 # Centroid stage is coded explicitly in PyRosetta, and will
13 # display in PyMOL if PyMOLPyRosettaServer.py in running in
14 # Pymol. All-atom refine stage is called through LoopMover_Refine_KIC
15 # and will not display in PyMOL for efficiency, but will output
16 # loop rms and energy to command line terminal.
17 
18 MAX_KIC_BUILD_ATTEMPTS = 10000
19 
20 args = [ "app",
21  "-database minirosetta_database", \
22  "-loops:fast" ] # reduce the number of cycles for testing purposes
23 init( *args )
24 
25 p = Pose()
26 pose_from_pdb( p, "2cpl_min.pdb" )
27 
28 starting_p = Pose()
29 starting_p.assign( p )
30 
31 scorefxn_low = create_score_function( 'cen_std' )
32 scorefxn_high = create_score_function_ws_patch( 'standard', 'score12' )
33 
34 pymol = rosetta.PyMOL_Mover() # If Pymol server is running, centroid stage will display
35 
36 loop_begin = 145
37 loop_end = 155
38 loop_cut = 150
39 my_loop = Loop( loop_begin, loop_end, loop_cut )
40 my_loops = Loops()
41 my_loops.add_loop( my_loop )
42 print my_loop
43 
44 set_single_loop_fold_tree( p, my_loop )
45 
46 movemap = MoveMap()
47 movemap.set_bb_true_range(loop_begin, loop_end )
48 movemap.set_chi( True )
49 
50 print p.fold_tree()
51 
52 print "setting up movers"
53 # use the KinematicMover explicitly in centroid stage
54 kic_mover = KinematicMover()
55 
56 #centroid/fullatom conversion movers
57 to_centroid = protocols.simple_moves.SwitchResidueTypeSetMover( 'centroid' )
58 to_fullatom = protocols.simple_moves.SwitchResidueTypeSetMover( 'fa_standard' )
59 recover_sidechains = protocols.simple_moves.ReturnSidechainMover( starting_p )
60 
61 #set up sidechain packer movers
62 task_pack = TaskFactory.create_packer_task( starting_p )
63 task_pack.restrict_to_repacking()
64 task_pack.or_include_current( True )
65 pack = protocols.simple_moves.PackRotamersMover( scorefxn_high, task_pack )
66 
67 #convert to centroid mode
68 to_centroid.apply( p )
69 
70 #set up centroid stage MoveMap
71 mm = MoveMap()
72 movemap.set_bb( True )
73 
74 # set up centroid stage line minimizer
75 tol = 0.001
76 min_type = "linmin"
77 linmin_mover = protocols.simple_moves.MinMover( mm, scorefxn_low, min_type, tol, True )
78 
79 # save starting pose
80 starting_p_centroid = Pose()
81 starting_p_centroid.assign( p )
82 
83 print "building random loop conformation with ideal bond lengths, bond angles,"
84 print "and omega angles using KIC",
85 success = False
86 kic_mover.set_idealize_loop_first( True )
87 kic_mover.set_pivots( loop_begin, loop_cut, loop_end )
88 pymol.apply( p )
89 for i in range( MAX_KIC_BUILD_ATTEMPTS ):
90  print "\n attempt %d..." %i,
91  kic_mover.apply( p )
92  pymol.apply( p )
93  if kic_mover.last_move_succeeded():
94  success = True
95  kic_mover.set_idealize_loop_first( False )
96  print "succeeded."
97  break
98 if not success:
99  print "Could not complete initial KIC loop building in %d attempts. Exiting" \
100  %MAX_KIC_BUILD_ATTEMPTS
101  exit()
102 scorefxn_low( p )
103 linmin_mover.apply( p )
104 
105 print "centroid stage loop KIC remodeling"
106 outer_cycles = 10
107 inner_cycles = 30
108 init_temp = 2.0
109 final_temp = 1.0
110 gamma = math.pow( ( final_temp/init_temp ),( 1.0/( outer_cycles*inner_cycles ) ) )
111 kT = init_temp
112 mc = MonteCarlo( p, scorefxn_low, kT )
113 
114 for i in range( 1,outer_cycles+1 ):
115  mc.recover_low( p )
116  scorefxn_low( p )
117  for j in range( 1, inner_cycles+1 ):
118  kT = kT * gamma
119  mc.set_temperature( kT )
120  kic_start = randrange( loop_begin, loop_end - 1 )
121  kic_end = randrange( kic_start+2, loop_end+1 )
122  middle_offset = ( kic_end - kic_start ) / 2
123  kic_middle = kic_start + middle_offset
124  kic_mover.set_pivots( kic_start, kic_middle, kic_end )
125  kic_mover.set_temperature( kT )
126  kic_mover.apply( p )
127  linmin_mover.apply( p )
128  mc.boltzmann( p )
129  pymol.apply( p )
130  rms = loop_rmsd( p, starting_p, my_loops )
131  print "centroid stage loop rmsd to starting loop: %f" %rms
132 mc.recover_low( p )
133 
134 print "high-res KIC refinement"
135 to_fullatom.apply( p )
136 recover_sidechains.apply( p )
137 pack.apply( p )
138 
139 loop_refine = LoopMover_Refine_KIC( my_loops )
140 loop_refine.apply( p ) # won't show in Pymol for efficiency
141 pymol.apply( p ) # just show refined model
142 
143 print "outputting decoy test_kic.pdb"
144 p.dump_pdb( "test_kic.pdb" )
tuple scorefxn_low
Definition: loops_kic.py:31
BooleanOptionKey const exit("options:exit")
Definition: OptionKeys.hh:51
void init()
set global 'init_was_called' to true
Definition: init.cc:26