6 Usage: surface_docking.py @flags
7 flags is a text file containing the arguments (one on each line. see file in demo for example)
8 To see arguments, see surface_docking.py --help
20 import rosetta.core.scoring.solid_surface
21 import rosetta.core.scoring.constraints
22 import rosetta.core.io.raw_data
25 from surf_param
import *
26 from append_data
import *
27 from constraints
import *
31 parser = argparse.ArgumentParser(description=
'Surface Docking Script',fromfile_prefix_chars=
'@')
33 parser.add_argument(
'-s',
'--start', action=
"store", dest=
"s", metavar=
'INPUT_FILE', required=
True, help=
'PDB file INPUT_FILE containing protein and surface')
34 parser.add_argument(
'--database', action=
"store", dest=
"database", metavar=
'DATABASE_FILE', required=
True, help=
'Rosetta database path in PyRosetta')
35 parser.add_argument(
'--f3',
'--frag3', action=
"store", dest=
"f3", metavar=
'FRAG3_FILE', required=
False, default=
'', help=
'Use 3-mer fragment file FRAG3_FILE')
36 parser.add_argument(
'--f9',
'--frag9', action=
"store", dest=
"f9", metavar=
'FRAG9_FILE', required=
False, default=
'', help=
'Use 9-mer fragment file FRAG9_FILE')
37 parser.add_argument(
'-c',
'--constraints', action=
'store_true', required=
False, default=
False, help=
'Use ssNMR constraints')
38 parser.add_argument(
'-d',
'--disulf', action=
"store", dest=
"d", metavar=
'DISULF', required=
False, default=
'', help=
'Use disulfide constraints file DISULF')
39 parser.add_argument(
'--nosmallshear', action=
'store_true', required=
False, default=
False, help=
'Disable small/shear refinements completely (e.g. for rigid-body docking ')
40 parser.add_argument(
'-n',
'--nstruct', action=
"store", dest=
"n", metavar=
'N', required=
True, type=int, help=
'Generate N decoys')
42 args = parser.parse_args([
'@flags'])
46 constraints = args.constraints
47 decoy_num =
int(args.n)
51 nosmallshear_ref = args.nosmallshear
53 if path.startswith(
"$"):
54 newpath = os.path.expandvars(path)
55 elif path.startswith(
"~"):
56 newpath = os.path.expanduser(path)
61 opts = [
'app',
'-database',newpath,
'-ex1',
'-ex2aro',
'-multiple_processes_writing_to_one_directory',\
62 '-mute',
'core',
'-mute',
'protocols',
'-mute',
'basic']
65 Rargs = rosetta.utility.vector1_string()
67 rosetta.core.init(Rargs)
73 print "Input file does not exist."
77 cst =
'ls *.cst > csts'
80 if os.stat(
'csts').st_size == 0:
81 print "Constraint files do not exist."
86 if frag3 ==
"" and frag9 !=
"" or frag3 !=
"" and frag9 ==
"":
87 print "You must have both fragment files or no fragment files."
90 elif frag3 !=
"" and frag9 !=
"":
91 if not exists(frag3)
or not exists(frag9):
92 print "One or more fragment files do not exist."
96 if not exists(disulf_file):
97 print "Disulfide file does not exist."
104 fa_relax.state = state
106 if fa_relax.outer_cycles > 1:
108 rep_inc = (0.44-rep)/(fa_relax.outer_cycles-1)
113 for outer_cycle
in range(1, fa_relax.outer_cycles + 1):
115 fa_relax.outer_cycle = outer_cycle
116 fa_relax.set_max_angle(30/(outer_cycle))
117 fa_relax.score_high.set_weight(fa_rep, rep)
133 sol_cycles = randint(1,5)
136 ads_cycles = 5 - sol_cycles
144 print "Initializing poses..."
147 pose_from_pdb(start_pose, input)
148 if disulf_file !=
'':
153 score_high = create_score_function(
"score12")
154 score_high.set_weight(fa_elec, elec)
155 score_high.set_weight(fa_pair, 0.0)
156 score_high.set_weight(atom_pair_constraint, 1.0)
157 score_high.set_weight(dihedral_constraint, 1.0)
159 score_pack = create_score_function(
"score12")
160 score_pack.set_weight(fa_elec, elec)
161 score_pack.set_weight(fa_rep, 0.44)
162 score_pack.set_weight(fa_pair, 0.0)
163 score_pack.set_weight(atom_pair_constraint, 1.0)
164 score_pack.set_weight(dihedral_constraint, 1.0)
166 std_scorefxn = create_score_function(
"score12")
167 std_scorefxn.set_weight(fa_elec, elec)
168 std_scorefxn.set_weight(fa_rep, 0.44)
169 std_scorefxn.set_weight(fa_pair, 0.0)
170 std_scorefxn.set_weight(atom_pair_constraint, 1.0)
171 std_scorefxn.set_weight(dihedral_constraint, 1.0)
173 switch_low = SwitchResidueTypeSetMover(
'centroid')
174 switch_high = SwitchResidueTypeSetMover(
'fa_standard')
185 cwd2 = cwd1.split(
'/')
188 print 'Current folder: ', dir
190 jd = PyJobDistributor(
"AdsState_" + PDB +
"_" + dir, decoy_num, score_high)
191 jd1 = PyJobDistributor(
"SolState_" + PDB +
"_" + dir, decoy_num, score_high)
193 while (jd.job_complete ==
False):
201 time_start = datetime.datetime.now()
205 if frag3 !=
'' and frag9 !=
'':
206 combined_pose = Pose()
207 combined_pose.assign(start_pose)
208 pose.assign(start_pose.split_by_chain()[2])
210 switch_low.apply(pose)
215 print "-------------Starting ab initio protocol-----------"
218 print "-------------- End ab initio protocol--------------"
221 print "--------Starting centroid relax protocol-----------"
223 cen_relax.apply(pose)
224 print "---------End centroid relax protocol--------------"
226 switch_high.apply(pose)
229 combined_pose.copy_segment(pose.total_residue(), pose, combined_pose.num_jump() + 1, 1)
230 pose.assign(combined_pose)
233 pose.assign(start_pose)
234 switch_high.apply(pose)
239 print ">> Starting full atom relaxation..."
241 fa_relax =
FullAtomRelax(score_high, score_pack, std_scorefxn, nosmallshear_ref)
242 fa_relax.set_params(pose)
243 fa_relax.loadSurf(input)
244 fa_relax.constraints = constraints
247 fa_relax.fullRepack(pose)
249 print "-------------- Starting solution state refinement --------------"
254 fa_relax.loadConstraints(PDB)
255 fa_relax.applyConstraints(pose,
"sol")
257 fa_relax.ref_cycles = sol_cycles
258 fa_relax.outer_cycles = sol_outer_cycles
259 fa_relax.inner_cycles = sol_inner_cycles
262 for cycle
in range(1, sol_cycles + 1):
263 fa_relax.curr_cycle = cycle
264 print "Solution state cycle ", cycle
268 fa_relax.fullRepack(pose)
272 sol_pose.assign(pose)
273 print "-------------- End of solution state refinement --------------"
276 fa_relax._slideProt(pose)
278 print "-------------- Starting adsorbed state refinement --------------"
283 fa_relax.applyConstraints(pose,
"ads")
285 fa_relax.ref_cycles = ads_cycles
286 fa_relax.outer_cycles = ads_outer_cycles
287 fa_relax.inner_cycles = ads_inner_cycles
290 for cycle
in range(1, ads_cycles + 1):
291 fa_relax.curr_cycle = cycle
292 print "Adsorbed cycle ", cycle
296 fa_relax.fullRepack(pose)
299 if fa_relax.constraints ==
'False':
300 fa_relax.score_high.set_weight(fa_rep, 0.44)
301 fa_relax.set_max_angle(6)
304 for outer_cycle
in range(2, 4):
305 fa_relax.outer_cycle = outer_cycle
308 fa_relax.fullRepack(pose)
310 print "-------------- End of adsorbed state refinement --------------"
317 jd1.output_decoy(sol_pose)
318 jd.output_decoy(pose)
320 append_surf_sol =
"grep SURFA " + input +
" >> " + curr_sol
321 append_surf_ads =
"grep SURFA " + input +
" >> " + curr_ads
323 os.system(append_surf_sol)
324 os.system(append_surf_ads)
326 append_data(curr_sol, sol_pose, score_high, PDB, 0)
329 time_end = datetime.datetime.now()
330 time_diff = time_end - time_start
Fstring::size_type len(Fstring const &s)
Length.