import optparse # for sorting options from rosetta import * rosetta.init() # init() # normally, init() works fine # for this sample script, we want to ease comparison by making sure all random # variables generated by Rosetta in this instance of PyRosetta start from a # constant seed # here we provide the additional argument "-constant_seed" which sets all the # random variables generated by Rosetta from a constant seed (google random # seed for more information) # some options can be set after initialization, please see PyRosetta.org FAQs # for more information # WARNING: option '-constant_seed' is for testing only! MAKE SURE TO REMOVE IT IN PRODUCTION RUNS!!!!! import os ######### # Methods def sample_ligand_interface(pdb_filename, partners, ligand_params = [''], jobs = 10, job_output = 'lig_output' ): pose = Pose() if ligand_params[0]: ligand_params = Vector1(ligand_params) new_res_set = generate_nonstandard_residue_set(ligand_params) pose_from_pdb(pose, new_res_set, pdb_filename) else: pose_from_pdb(pose, pdb_filename) dock_jump = 1 setup_foldtree(pose, partners, Vector1([dock_jump])) test_pose = Pose() test_pose.assign(pose) scorefxn = create_score_function('ligand') docking = DockMCMProtocol() docking.set_scorefxn(scorefxn) jd = PyJobDistributor(job_output, jobs, scorefxn) counter = 0 # for pretty output to PyMOL while not jd.job_complete: test_pose.assign(pose) counter += 1 test_pose.pdb_info().name(job_output + '_' + str(counter)) docking.apply(test_pose) test_pose.pdb_info().name(job_output + '_' + str(counter) + '_fa') jd.output_decoy(test_pose) def generate_nonstandard_residue_set( params_list ): """ Returns a "custom" ResidueTypeSet with the normal ResidueTypes and any new ones added as a Vector1 of .params filenames, the input example(s): res_set = generate_nonstandard_residue_set( Vector1( ['ATP.params'] ) ) See Also: Pose Residue ResidueType ResidueTypeSet """ res_set = ChemicalManager.get_instance().nonconst_residue_type_set( 'fa_standard' ) atoms = ChemicalManager.get_instance().atom_type_set( 'fa_standard' ) mm_atoms = ChemicalManager.get_instance().mm_atom_type_set( 'fa_standard' ) orbitals = ChemicalManager.get_instance().orbital_type_set( 'fa_standard' ) try: # then this PyRosetta is a newer version, sorry, element_sets were added # to the chemical database and changed the syntax of read_files elements = ChemicalManager.get_instance().element_set( 'default' ) res_set.read_files( params_list , atoms , elements , mm_atoms , orbitals ) except: # then this PyRosetta is v2.0 beta or earlier, as this is being written, # we support v2.0 beta, notice the subtle difference below res_set.read_files( params_list , atoms , mm_atoms , orbitals ) return res_set parser = optparse.OptionParser() parser.add_option('--pdb_filename', dest = 'pdb_filename', default = 'complex.pdb', # default example PDB help = 'the PDB file containing the ligand and protein to dock') # for more information on "partners", see sample_docking step 2. parser.add_option('--partners', dest = 'partners', default = 'A_X', # default for the example test_lig.pdb help = 'the relative chain partners for docking') # ligand options parser.add_option('--ligand_params', dest = 'ligand_params' , default = 'ATP.params' , # default for the example test_lig.pdb help = 'the ligand residue parameter file') # PyJobDistributor options parser.add_option('--jobs', dest='jobs', default = '10', # default to single trajectory for speed help = 'the number of jobs (trajectories) to perform') parser.add_option('--job_output', dest = 'job_output', default = 'lig_output', # if a specific output name is desired help = 'the name preceding all output, output PDB files and .fasc') (options,args) = parser.parse_args() # PDB file option pdb_filename = options.pdb_filename partners = options.partners # ligand options ligand_params = options.ligand_params.split(',') # JobDistributor options jobs = int(options.jobs) job_output = options.job_output sample_ligand_interface(pdb_filename, partners, ligand_params, jobs, job_output)