def run(args, params=None, out=sys.stdout, log=sys.stderr): if (((len(args) == 0) and (params is None)) or ((len(args) > 0) and ((args[0] == "-h") or (args[0] == "--help")))): show_usage() return if (params is None): pcl = iotbx.phil.process_command_line_with_files( args=args, master_phil_string=master_phil_str, pdb_file_def="file_name") work_params = pcl.work.extract() # or use parameters defined by GUI else: work_params = params pdb_inp = iotbx.pdb.input(file_name=work_params.file_name) pdb_int_params = mmtbx.model.manager.get_default_pdb_interpretation_params( ) pdb_int_params.pdb_interpretation.clash_guard.nonbonded_distance_threshold = None model = mmtbx.model.manager(model_input=pdb_inp, pdb_interpretation_params=pdb_int_params, build_grm=True) fixed_pdb_h = model.get_hierarchy().deep_copy() fixed_pdb_h.reset_atom_i_seqs() fixed_pdb_h = fix_rotamer_outliers( model=model, radius=work_params.radius, ) res_pdb_str = model.model_as_pdb() with open("%s.pdb" % work_params.output_prefix, "w") as f: f.write(res_pdb_str)
def run(args, params=None, out=sys.stdout, log=sys.stderr): if ( ((len(args) == 0) and (params is None)) or ((len(args) > 0) and ((args[0] == "-h") or (args[0] == "--help"))) ): show_usage() return if (params is None): pcl = iotbx.phil.process_command_line_with_files( args=args, master_phil_string=master_phil_str, pdb_file_def="file_name") work_params = pcl.work.extract() # or use parameters defined by GUI else: work_params = params pdb_files = work_params.file_name mon_lib_srv = mmtbx.monomer_library.server.server() ppf_srv = mmtbx.utils.process_pdb_file_srv( crystal_symmetry = None, pdb_interpretation_params = None, stop_for_unknowns = False, log = log, cif_objects = None, # need to figure out how to get them mon_lib_srv = mon_lib_srv, ener_lib = None, use_neutron_distances = False) processed_pdb_file, pdb_inp = ppf_srv.process_pdb_files( pdb_file_names = pdb_files) cs = ppf_srv.crystal_symmetry xrs = processed_pdb_file.xray_structure(show_summary = True) if(xrs is None): raise Sorry("Cannot extract xray_structure.") grm = get_geometry_restraints_manager( processed_pdb_file=processed_pdb_file, xray_structure=xrs, log=log) pdb_h = processed_pdb_file.all_chain_proxies.pdb_hierarchy fixed_pdb_h = pdb_h.deep_copy() fixed_pdb_h.reset_atom_i_seqs() rotamer_manager = RotamerEval(mon_lib_srv=mon_lib_srv) fixed_pdb_h = fix_rotamer_outliers( pdb_hierarchy=fixed_pdb_h, grm=grm.geometry, xrs=xrs, radius=work_params.radius, mon_lib_srv=mon_lib_srv, rotamer_manager=rotamer_manager, asc=None) iotbx.pdb.write_whole_pdb_file( file_name="%s.pdb" % work_params.output_prefix, processed_pdb_file=processed_pdb_file, pdb_hierarchy=fixed_pdb_h, crystal_symmetry=cs)
def exercise_2(): model = get_necessary_inputs(pdb_str_2) pdb_h = fix_rotamer_outliers(model=model, radius=5) rotamers = [] for res in pdb_h.only_chain().only_conformer().residues(): rotamers.append(model.get_rotamer_manager().evaluate_residue(res)) assert rotamers == [ 'mtt180', 'tttt', 'm-30', 'pt', 'p', 'mt-10', 'm-40', 'EXCEPTION', 'tt', 'tttt' ], rotamers
def exercise_1(): """ 58 is outlier """ model = get_necessary_inputs(pdb_str_1) # pdb_h.write_pdb_file("fix_rot_out_ex1_start.pdb") pdb_h = fix_rotamer_outliers(model=model, radius=5) rotamers = [] # pdb_h.write_pdb_file("fix_rot_out_ex1_end.pdb") for res in pdb_h.only_chain().only_conformer().residues(): rotamers.append(model.get_rotamer_manager().evaluate_residue(res)) # print rotamers assert rotamers == ['m-80', 'p'], rotamers
def exercise_2(mon_lib_srv, ener_lib, rotamer_manager): pdb_h, grm, xrs = get_necessary_inputs(pdb_str_2, mon_lib_srv, ener_lib) pdb_h = fix_rotamer_outliers( pdb_hierarchy=pdb_h, grm=grm, xrs=xrs, radius=5, mon_lib_srv=mon_lib_srv, rotamer_manager=rotamer_manager, asc=None) rotamers = [] for res in pdb_h.only_chain().only_conformer().residues(): rotamers.append(rotamer_manager.evaluate_residue(res)) assert rotamers == ['mtt180', 'tttt', 'm-30', 'pt', 'p', 'mt-10', 'm-40', 'EXCEPTION', 'tt', 'tttt'], rotamers
def exercise_2(mon_lib_srv, ener_lib, rotamer_manager): pdb_h, grm, xrs = get_necessary_inputs(pdb_str_2, mon_lib_srv, ener_lib) pdb_h = fix_rotamer_outliers(pdb_hierarchy=pdb_h, grm=grm, xrs=xrs, radius=5, mon_lib_srv=mon_lib_srv, rotamer_manager=rotamer_manager, asc=None) rotamers = [] for res in pdb_h.only_chain().only_conformer().residues(): rotamers.append(rotamer_manager.evaluate_residue(res)) assert rotamers == [ 'mtt180', 'tttt', 'm-30', 'pt', 'p', 'mt-10', 'm-40', 'EXCEPTION', 'tt', 'tttt' ], rotamers
def exercise_1(mon_lib_srv, ener_lib, rotamer_manager): """ 58 is outlier """ pdb_h, grm, xrs = get_necessary_inputs(pdb_str_1, mon_lib_srv, ener_lib) # pdb_h.write_pdb_file("fix_rot_out_ex1_start.pdb") pdb_h = fix_rotamer_outliers(pdb_hierarchy=pdb_h, grm=grm, xrs=xrs, radius=5, mon_lib_srv=mon_lib_srv, rotamer_manager=rotamer_manager, asc=None) rotamers = [] # pdb_h.write_pdb_file("fix_rot_out_ex1_end.pdb") for res in pdb_h.only_chain().only_conformer().residues(): rotamers.append(rotamer_manager.evaluate_residue(res)) # print rotamers assert rotamers == ['m-80', 'p'], rotamers
def exercise_1(mon_lib_srv, ener_lib, rotamer_manager): """ 58 is outlier """ pdb_h, grm, xrs = get_necessary_inputs(pdb_str_1, mon_lib_srv, ener_lib) # pdb_h.write_pdb_file("fix_rot_out_ex1_start.pdb") pdb_h = fix_rotamer_outliers( pdb_hierarchy=pdb_h, grm=grm, xrs=xrs, radius=5, mon_lib_srv=mon_lib_srv, rotamer_manager=rotamer_manager, asc=None) rotamers = [] # pdb_h.write_pdb_file("fix_rot_out_ex1_end.pdb") for res in pdb_h.only_chain().only_conformer().residues(): rotamers.append(rotamer_manager.evaluate_residue(res)) # print rotamers assert rotamers == ['m-80', 'p'], rotamers
def run(self): t_0 = time() ncs_obj = iotbx.ncs.input( hierarchy=self.whole_pdb_h, chain_max_rmsd=4.0, chain_similarity_threshold=0.99, residue_match_radius=999.0) print >> self.log, "Found NCS groups:" ncs_obj.show(format='phil', log=self.log) ncs_restr_group_list = ncs_obj.get_ncs_restraints_group_list( raise_sorry=False) self.using_ncs = False total_ncs_selected_atoms = 0 master_sel = flex.size_t([]) filtered_ncs_restr_group_list = self.filter_ncs_restraints_group_list( self.whole_pdb_h, ncs_restr_group_list) if len(filtered_ncs_restr_group_list) > 0: self.using_ncs = True master_sel = flex.bool(self.whole_pdb_h.atoms_size(), True) for ncs_gr in filtered_ncs_restr_group_list: for copy in ncs_gr.copies: master_sel.set_selected(copy.iselection, False) self.master_pdb_h = self.whole_pdb_h.select(master_sel) self.master_sel=master_sel self.master_pdb_h.reset_atom_i_seqs() if self.using_ncs: self.master_pdb_h.write_pdb_file("%s_master_h.pdb" % self.params.output_prefix) self.working_pdb_h = self.master_pdb_h else: self.working_pdb_h = self.whole_pdb_h self.working_pdb_h.reset_atom_i_seqs() self.ann = ioss.annotation.from_phil( phil_helices=self.params.secondary_structure.protein.helix, phil_sheets=self.params.secondary_structure.protein.sheet, pdb_hierarchy=self.whole_pdb_h) self.working_xrs = self.working_pdb_h.extract_xray_structure(crystal_symmetry=self.cs) if self.using_ncs: self.whole_xrs = self.whole_pdb_h.extract_xray_structure(crystal_symmetry=self.cs) else: self.whole_xrs = self.working_xrs if self.params.use_map_for_reference: # self.prepare_reference_map(xrs=self.whole_xrs, pdb_h=self.whole_pdb_h) # self.prepare_reference_map_2(xrs=self.whole_xrs, pdb_h=self.whole_pdb_h) self.prepare_reference_map_3(xrs=self.whole_xrs, pdb_h=self.whole_pdb_h) # STOP() if self.ann.get_n_helices() + self.ann.get_n_sheets() == 0: self.ann = self.pdb_input.extract_secondary_structure() self.original_ann = None self.filtered_whole_ann = None if self.ann is not None: self.original_ann = self.ann.deep_copy() print >> self.log, "Original SS annotation" print >> self.log, self.original_ann.as_pdb_str() self.ann.remove_short_annotations() self.filtered_whole_ann = self.ann.deep_copy() self.ann.remove_empty_annotations( hierarchy=self.working_pdb_h) self.filtered_whole_ann.remove_empty_annotations( hierarchy=self.whole_pdb_h) # self.ann.concatenate_consecutive_helices() self.ann.split_helices_with_prolines( hierarchy=self.working_pdb_h, asc=None) self.filtered_whole_ann.split_helices_with_prolines( hierarchy=self.whole_pdb_h, asc=None) # print >> self.log, "Splitted SS annotation" # print >> self.log, ann.as_pdb_str() print >> self.log, "Filtered SS annotation" print >> self.log, self.ann.as_pdb_str() # getting grm with SS restraints self.get_grm() if (self.ann is None or self.ann.get_n_helices() + self.ann.get_n_sheets() == 0 or not self.params.ss_idealization.enabled): print >> self.log, "No secondary structure annotations found or SS idealization is disabled." print >> self.log, "Secondary structure substitution step will be skipped" self.log.flush() # here we want to do geometry minimization anyway! negate_selection = None if self.reference_map is None: outlier_selection_txt = mmtbx.building.loop_closure.utils. \ rama_outliers_selection(self.working_pdb_h, self.rama_manager, 1) print >> self.log, "outlier_selection_txt", outlier_selection_txt negate_selection = "all" if outlier_selection_txt != "" and outlier_selection_txt is not None: negate_selection = "not (%s)" % outlier_selection_txt self.minimize( hierarchy=self.whole_pdb_h, xrs=self.whole_xrs, original_pdb_h=self.whole_pdb_h, grm=self.whole_grm, ncs_restraints_group_list=filtered_ncs_restr_group_list, excl_string_selection=negate_selection, ss_annotation=self.ann, reference_map=self.reference_map) # self.original_boxed_hierarchy.write_pdb_file(file_name="original_boxed_h_1.pdb") else: self.params.ss_idealization.file_name_before_regularization = \ "%s_ss_before_reg.pdb" % self.params.output_prefix ssb.substitute_ss( real_h=self.working_pdb_h, xray_structure=self.working_xrs, ss_annotation=self.ann, params=self.params.ss_idealization, grm=self.working_grm, fix_rotamer_outliers=True, cif_objects=self.cif_objects, verbose=True, reference_map=self.reference_map, rotamer_manager=self.rotamer_manager, log=self.log) self.log.flush() self.after_ss_idealization = geometry_no_grm( pdb_hierarchy=iotbx.pdb.input( source_info=None, lines=self.working_pdb_h.as_pdb_string()).construct_hierarchy(), molprobity_scores=True) # Write resulting pdb file. self.shift_and_write_result( hierarchy=self.working_pdb_h, fname_suffix="ss_ideal", grm=self.working_grm) # STOP() self.params.loop_idealization.minimize_whole = not self.using_ncs # self.params.loop_idealization.enabled = False # self.params.loop_idealization.variant_search_level = 0 loop_ideal = loop_idealization( pdb_hierarchy=self.working_pdb_h, params=self.params.loop_idealization, secondary_structure_annotation=self.ann, reference_map=self.reference_map, crystal_symmetry=self.working_xrs.crystal_symmetry(), grm=self.working_grm, rama_manager=self.rama_manager, rotamer_manager=self.rotamer_manager, log=self.log, verbose=True) self.log.flush() # STOP() self.shift_and_write_result( hierarchy=loop_ideal.resulting_pdb_h, fname_suffix="rama_ideal", grm=self.working_grm) self.after_loop_idealization = geometry_no_grm( pdb_hierarchy=iotbx.pdb.input( source_info=None, lines=loop_ideal.resulting_pdb_h.as_pdb_string()).construct_hierarchy(), molprobity_scores=True) # fixing remaining rotamer outliers fixed_rot_pdb_h = loop_ideal.resulting_pdb_h.deep_copy() fixed_rot_pdb_h.reset_atom_i_seqs() if (self.params.additionally_fix_rotamer_outliers and self.after_loop_idealization.rotamer_outliers > 0.004): print >> self.log, "Processing pdb file again for fixing rotamers..." self.log.flush() print >> self.log, "Fixing rotamers..." self.log.flush() self.shift_and_write_result( hierarchy=fixed_rot_pdb_h, fname_suffix="just_before_rota") fixed_rot_pdb_h = fix_rotamer_outliers( pdb_hierarchy=fixed_rot_pdb_h, grm=self.working_grm.geometry, xrs=self.working_xrs, map_data=self.reference_map, mon_lib_srv=self.mon_lib_srv, rotamer_manager=self.rotamer_manager, verbose=True) self.shift_and_write_result( hierarchy=fixed_rot_pdb_h, fname_suffix="rota_ideal", grm=self.working_grm) cs_to_write = self.cs if self.shift_vector is None else None self.after_rotamer_fixing = geometry_no_grm( pdb_hierarchy=iotbx.pdb.input( source_info=None, lines=fixed_rot_pdb_h.as_pdb_string()).construct_hierarchy(), molprobity_scores=True) ref_hierarchy_for_final_gm = self.original_boxed_hierarchy if not self.params.use_starting_model_for_final_gm: ref_hierarchy_for_final_gm = self.whole_pdb_h ref_hierarchy_for_final_gm.reset_atom_i_seqs() if self.params.additionally_fix_rotamer_outliers: ssb.set_xyz_smart(self.working_pdb_h, fixed_rot_pdb_h) if self.using_ncs: print >> self.log, "Using ncs" # multiply back and do geometry_minimization for the whole molecule for ncs_gr in ncs_restr_group_list: master_h = self.whole_pdb_h.select(ncs_gr.master_iselection) for c in ncs_gr.copies: new_sites = master_h.atoms().extract_xyz() new_c_sites = c.r.elems * new_sites + c.t self.whole_pdb_h.select(c.iselection).atoms().set_xyz(new_c_sites) self.log.flush() else: # still need to run gm if rotamers were fixed print >> self.log, "Not using ncs" # need to update SS manager for the whole model here. if self.params.use_ss_restraints: ss_manager = manager( pdb_hierarchy=self.whole_pdb_h, geometry_restraints_manager=self.whole_grm.geometry, sec_str_from_pdb_file=self.filtered_whole_ann, params=None, mon_lib_srv=self.mon_lib_srv, verbose=-1, log=self.log) self.whole_grm.geometry.set_secondary_structure_restraints( ss_manager=ss_manager, hierarchy=self.whole_pdb_h, log=self.log) print >> self.log, "loop_ideal.ref_exclusion_selection", loop_ideal.ref_exclusion_selection print >> self.log, "Minimizing whole model" self.minimize( hierarchy=self.whole_pdb_h, xrs=self.whole_xrs, grm=self.whole_grm, ncs_restraints_group_list=filtered_ncs_restr_group_list, original_pdb_h=ref_hierarchy_for_final_gm, excl_string_selection=loop_ideal.ref_exclusion_selection, ss_annotation=self.ann, reference_map = self.reference_map) self.shift_and_write_result( hierarchy=self.whole_pdb_h, fname_suffix="all_idealized", grm=self.whole_grm) self.final_model_statistics = geometry_no_grm( pdb_hierarchy=iotbx.pdb.input( source_info=None, lines=self.whole_pdb_h.as_pdb_string()).construct_hierarchy(), molprobity_scores=True) # self.original_boxed_hierarchy.write_pdb_file(file_name="original_boxed_end.pdb") self.time_for_run = time() - t_0
def run(self): t_0 = time() self.ann = self.model.get_ss_annotation() self.get_grm() self.model.setup_ncs_constraints_groups() self.init_model_statistics = self.get_statistics(self.model) # Here we are preparing maps if needed. if self.user_supplied_map is not None: self.prepare_user_map() if self.reference_map is None and self.params.use_map_for_reference: self.prepare_reference_map_3() if self.params.run_minimization_first: # running simple minimization and updating all # self.master, self.working, etc... # self.whole_pdb_h.reset_atom_i_seqs() if self.init_ref_map is None: self.prepare_init_reference_map() print >> self.log, "Minimization first" self.minimize( model=self.model, original_pdb_h=self.original_hierarchy, excl_string_selection=None, # don't need if we have map reference_map=self.init_ref_map, ) self.init_gm_model_statistics = self.get_statistics(self.model) if self.params.debug: self.shift_and_write_result( model = self.model, fname_suffix="init_gm") if (self.init_gm_model_statistics is not None and self.init_gm_model_statistics.ramachandran.outliers == 0 and self.init_gm_model_statistics.omega.twisted_general <= 0.01 and self.init_gm_model_statistics.omega.twisted_proline <= 0.01 and self.init_gm_model_statistics.omega.cis_general <= 0.01 and self.init_gm_model_statistics.omega.cis_proline <= 0.01): print >> self.log, "Simple minimization was enough" # Early exit!!! self.shift_and_write_result( model=self.model, fname_suffix="all_idealized") self.final_model_statistics = self.get_statistics(self.model) # self.original_boxed_hierarchy.write_pdb_file(file_name="original_boxed_end.pdb") self.time_for_run = time() - t_0 if self.params.output_pkl: easy_pickle.dump( file_name="%s.pkl" % self.params.output_prefix, obj = self.get_stats_obj()) return self.filtered_whole_ann = None if self.ann is not None: self.filtered_whole_ann = self.ann.deep_copy() print >> self.log, "Original SS annotation" print >> self.log, self.ann.as_pdb_str() if self.params.filter_input_ss: self.filtered_whole_ann = self.ann.filter_annotation( hierarchy=self.model.get_hierarchy(), asc=self.model.get_atom_selection_cache()) print >> self.log, "Filtered SS annotation" print >> self.log, self.filtered_whole_ann.as_pdb_str() self.model.set_ss_annotation(self.filtered_whole_ann) # getting grm with SS restraints self.update_ss_in_grm(self.filtered_whole_ann) if (self.ann is None or self.ann.get_n_helices() + self.ann.get_n_sheets() == 0 or not self.params.ss_idealization.enabled): print >> self.log, "No secondary structure annotations found or SS idealization is disabled." print >> self.log, "Secondary structure substitution step will be skipped" self.log.flush() # here we want to do geometry minimization anyway! negate_selection = None if self.reference_map is None: outlier_selection_txt = mmtbx.building.loop_closure.utils. \ rama_score_selection(self.model, self.model.get_ramachandran_manager(), "outlier",1) print >> self.log, "outlier_selection_txt", outlier_selection_txt negate_selection = "all" if outlier_selection_txt != "" and outlier_selection_txt is not None: negate_selection = "not (%s)" % outlier_selection_txt # if self.params.run_minimization_first: # self.minimize( # model=self.model, # original_pdb_h=self.whole_pdb_h, # ncs_restraints_group_list=self.filtered_ncs_restr_group_list, # excl_string_selection=negate_selection, # reference_map=self.reference_map) # self.original_boxed_hierarchy.write_pdb_file(file_name="original_boxed_h_1.pdb") else: if self.params.debug: self.params.ss_idealization.file_name_before_regularization = \ "%s_ss_before_reg.pdb" % self.params.output_prefix self.params.ss_idealization.skip_good_ss_elements = True ssb.substitute_ss( model = self.model, params=self.params.ss_idealization, fix_rotamer_outliers=True, verbose=self.params.verbose, reference_map=self.master_map, log=self.log) self.log.flush() # for_stat_h = self.get_intermediate_result_hierarchy() self.after_ss_idealization = self.get_statistics(self.model) self.shift_and_write_result( model=self.model, fname_suffix="ss_ideal_stat") # Write resulting pdb file. if self.params.debug: self.shift_and_write_result( model=self.model, fname_suffix="ss_ideal", ) self.params.loop_idealization.minimize_whole = not self.model.ncs_constraints_present() and self.params.loop_idealization.minimize_whole self.params.loop_idealization.debug = self.params.debug or self.params.loop_idealization.debug # self.params.loop_idealization.enabled = False # self.params.loop_idealization.variant_search_level = 0 print >> self.log, "Starting loop idealization" loop_ideal = loop_idealization( self.model, params=self.params.loop_idealization, reference_map=self.master_map, log=self.log, verbose=True) self.log.flush() if self.params.debug: self.shift_and_write_result( model = self.model, fname_suffix="rama_ideal") self.after_loop_idealization = self.get_statistics(self.model) if self.params.add_hydrogens: print >> self.log, "Adding hydrogens" assert 0, "not implemented anymore" self.add_hydrogens() # fixing remaining rotamer outliers if (self.params.additionally_fix_rotamer_outliers and self.after_loop_idealization.rotamer.outliers > 0.004): print >> self.log, "Processing pdb file again for fixing rotamers..." self.log.flush() print >> self.log, "Fixing rotamers..." self.log.flush() if self.params.debug: self.shift_and_write_result( model = self.model, fname_suffix="just_before_rota") fix_rotamer_outliers( model = self.model, map_data=self.master_map, verbose=True, log=self.log) if self.params.debug: self.shift_and_write_result( model = self.model, fname_suffix="rota_ideal") cs_to_write = self.cs if self.shift_vector is None else None self.after_rotamer_fixing = self.get_statistics(self.model) ref_hierarchy_for_final_gm = self.original_boxed_hierarchy if not self.params.use_starting_model_for_final_gm: ref_hierarchy_for_final_gm = self.model.get_hierarchy().deep_copy() ref_hierarchy_for_final_gm.reset_atom_i_seqs() if self.model.ncs_constraints_present(): print >> self.log, "Using ncs" # assert 0 else: print >> self.log, "Not using ncs" # assert 0 # need to update SS manager for the whole model here. if self.params.use_ss_restraints: ss_params = sec_str_master_phil.fetch().extract() ss_params.secondary_structure.protein.remove_outliers = not self.params.ss_idealization.enabled self.set_ss_restraints( ss_annotation=self.filtered_whole_ann, params=ss_params.secondary_structure) if self.params.run_minimization_last: print >> self.log, "loop_ideal.ref_exclusion_selection", loop_ideal.ref_exclusion_selection print >> self.log, "Minimizing whole model" self.minimize( model = self.model, original_pdb_h=ref_hierarchy_for_final_gm, excl_string_selection=loop_ideal.ref_exclusion_selection, reference_map = self.reference_map) self.shift_and_write_result( model = self.model, fname_suffix="all_idealized") self.final_model_statistics = self.get_statistics(self.model) self.time_for_run = time() - t_0 if self.params.output_pkl or self.params.debug: easy_pickle.dump( file_name="%s.pkl" % self.params.output_prefix, obj = self.get_stats_obj())
def run(args, params=None, out=sys.stdout, log=sys.stderr): if (((len(args) == 0) and (params is None)) or ((len(args) > 0) and ((args[0] == "-h") or (args[0] == "--help")))): show_usage() return if (params is None): pcl = iotbx.phil.process_command_line_with_files( args=args, master_phil_string=master_phil_str, pdb_file_def="file_name") work_params = pcl.work.extract() # or use parameters defined by GUI else: work_params = params pdb_files = work_params.file_name from mmtbx.monomer_library.pdb_interpretation import grand_master_phil_str params = iotbx.phil.parse(input_string=grand_master_phil_str, process_includes=True).extract() params.pdb_interpretation.clash_guard.nonbonded_distance_threshold = None mon_lib_srv = mmtbx.monomer_library.server.server() ppf_srv = mmtbx.utils.process_pdb_file_srv( crystal_symmetry=None, pdb_interpretation_params=params.pdb_interpretation, stop_for_unknowns=False, log=log, cif_objects=None, # need to figure out how to get them mon_lib_srv=mon_lib_srv, ener_lib=None, use_neutron_distances=False) processed_pdb_file, pdb_inp = ppf_srv.process_pdb_files( pdb_file_names=pdb_files) cs = ppf_srv.crystal_symmetry xrs = processed_pdb_file.xray_structure(show_summary=True) if (xrs is None): raise Sorry("Cannot extract xray_structure.") grm = get_geometry_restraints_manager( processed_pdb_file=processed_pdb_file, xray_structure=xrs, log=log) pdb_h = processed_pdb_file.all_chain_proxies.pdb_hierarchy fixed_pdb_h = pdb_h.deep_copy() fixed_pdb_h.reset_atom_i_seqs() rotamer_manager = RotamerEval(mon_lib_srv=mon_lib_srv) fixed_pdb_h = fix_rotamer_outliers(pdb_hierarchy=fixed_pdb_h, grm=grm.geometry, xrs=xrs, radius=work_params.radius, mon_lib_srv=mon_lib_srv, rotamer_manager=rotamer_manager, asc=None) iotbx.pdb.write_whole_pdb_file(file_name="%s.pdb" % work_params.output_prefix, processed_pdb_file=processed_pdb_file, pdb_hierarchy=fixed_pdb_h, crystal_symmetry=cs)