def summary(pdb_file=None, pdb_hierarchy=None, crystal_symmetry=None): header_info = None if (pdb_hierarchy is None): assert (pdb_file is not None) pdb_in = file_reader.any_file(pdb_file, force_type="pdb") pdb_in.assert_file_type("pdb") pdb_hierarchy = pdb_in.file_object.hierarchy pdb_hierarchy.atoms().reset_i_seq() header_info = molprobity.pdb_header_info(pdb_file=pdb_file) crystal_symmetry = pdb_in.file_object.crystal_symmetry() else: assert (pdb_file is None) # cache = pdb_hierarchy.atom_selection_cache() sel = cache.selection('protein') pdb_hierarchy = pdb_hierarchy.select(sel) # model = mmtbx.model.manager(model_input=pdb_hierarchy.as_pdb_input()) if crystal_symmetry and model.crystal_symmetry() is None: model.set_crystal_symmetry( crystal_symmetry) # Somehow pdb_hiearchy lacks cs if not model.crystal_symmetry(): aaa = bbb return molprobity.molprobity(model=model, keep_hydrogens=False, header_info=header_info).summarize()
def analyze_fragment(pdb_str): pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_str) model = mmtbx.model.manager(pdb_in.input) validation = molprobity.molprobity(model, outliers_only=False) result = analyze_model.process_pdb_hierarchy( pdb_hierarchy=model.get_hierarchy(), validation=validation, log=null_out()) return result
def analyze_fragment(pdb_str): pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_str) hierarchy = pdb_in.hierarchy validation = molprobity.molprobity(pdb_hierarchy=hierarchy, outliers_only=False) result = analyze_model.process_pdb_hierarchy(pdb_hierarchy=hierarchy, validation=validation, log=null_out()) return result
def analyze_fragment (pdb_str) : pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_str) hierarchy = pdb_in.hierarchy validation = molprobity.molprobity(pdb_hierarchy=hierarchy, outliers_only=False) result = analyze_model.process_pdb_hierarchy( pdb_hierarchy=hierarchy, validation=validation, log=null_out()) return result
def run(): result = [] for p in [True, False]: for mr in [True, False]: pdb_inp = iotbx.pdb.input(source_info=None, lines = pdb_str) hierarchy = pdb_inp.construct_hierarchy() model = mmtbx.model.manager(model_input=pdb_inp, log=null_out()) if(p): model.process(make_restraints=mr) o = molprobity.molprobity(model = model) result.append("%8.4f"%o.rms_bonds()) assert len(list(set(result)))==1
def __init__ (self, fmodel, pdb_hierarchy, params=None, processed_pdb_file=None, geometry_restraints_manager=None, cif_objects=(), cif_files=(), # XXX bug debug=None, verbose=True, out=sys.stdout) : adopt_init_args(self, locals()) if (self.params is None) : self.params = master_phil.extract().alt_confs self.extract_selection() self.refine_cycle = 1 self.map_file = None self.r_work_start = fmodel.r_work() self.r_free_start = fmodel.r_free() t_start = time.time() for i_cycle in range(params.macro_cycles) : n_alts = self.build_residue_conformers(stop_if_none=(i_cycle==0)) if (n_alts == 0) : if (i_cycle == 0) : raise Sorry("No alternate conformations found.") else : self.refine(constrain_occupancies=False) refine_again = self.params.refinement.constrain_correlated_occupancies if (self.rejoin()) : refine_again = True self.refine(title="Refining final model") make_header("Finished", out=out) from mmtbx.validation import molprobity validation = molprobity.molprobity( pdb_hierarchy=self.pdb_hierarchy, outliers_only=False) print >> self.out, "" validation.show_summary(out=self.out, prefix=" ") make_sub_header("Analyzing final model", out=out) analyze_model.process_pdb_hierarchy( pdb_hierarchy=self.pdb_hierarchy, validation=validation, log=self.out).show(out=out, verbose=self.verbose) print >> self.out, "" print >> self.out, "Start: r_work=%6.4f r_free=%6.4f" % \ (self.r_work_start, self.r_free_start) print >> self.out, "Final: r_work=%6.4f r_free=%6.4f" % \ (self.fmodel.r_work(), self.fmodel.r_free()) t_end = time.time() print >> self.out, "" print >> self.out, "Total runtime: %d s" % int(t_end - t_start) print >> self.out, ""
def summary(pdb_file=None, pdb_hierarchy=None): header_info = None if (pdb_hierarchy is None): assert (pdb_file is not None) pdb_in = file_reader.any_file(pdb_file, force_type="pdb") pdb_in.assert_file_type("pdb") pdb_hierarchy = pdb_in.file_object.hierarchy pdb_hierarchy.atoms().reset_i_seq() header_info = molprobity.pdb_header_info(pdb_file=pdb_file) else: assert (pdb_file is None) return molprobity.molprobity(None, pdb_hierarchy=pdb_hierarchy, keep_hydrogens=False, header_info=header_info).summarize()
def summary (pdb_file=None, pdb_hierarchy=None) : header_info = None if (pdb_hierarchy is None) : assert (pdb_file is not None) pdb_in = file_reader.any_file(pdb_file, force_type="pdb") pdb_in.assert_file_type("pdb") pdb_hierarchy = pdb_in.file_object.hierarchy pdb_hierarchy.atoms().reset_i_seq() header_info = molprobity.pdb_header_info( pdb_file=pdb_file) else : assert (pdb_file is None) return molprobity.molprobity( pdb_hierarchy=pdb_hierarchy, keep_hydrogens=False, header_info=header_info).summarize()
def filter_before_build ( pdb_hierarchy, fmodel, geometry_restraints_manager, selection=None, params=None, verbose=True, log=sys.stdout) : """ Pick residues suitable for building alternate conformations - by default, this means no MolProbity/geometry outliers, good fit to map, no missing atoms, and no pre-existing alternates, but with significant difference density nearby. """ from mmtbx.validation import molprobity from mmtbx.rotamer import rotamer_eval import mmtbx.monomer_library.server from mmtbx import building from iotbx.pdb import common_residue_names_get_class from scitbx.array_family import flex if (selection is None) : selection = flex.bool(fmodel.xray_structure.scatterers().size(), True) pdb_atoms = pdb_hierarchy.atoms() assert (pdb_atoms.size() == fmodel.xray_structure.scatterers().size()) pdb_atoms.reset_i_seq() full_validation = molprobity.molprobity( pdb_hierarchy=pdb_hierarchy, fmodel=fmodel, geometry_restraints_manager=geometry_restraints_manager, outliers_only=False, rotamer_library="8000") if (verbose) : full_validation.show(out=log) multi_criterion = full_validation.as_multi_criterion_view() if (params is None) : params = libtbx.phil.parse(filter_params_str).extract() mon_lib_srv = mmtbx.monomer_library.server.server() two_fofc_map, fofc_map = building.get_difference_maps(fmodel=fmodel) residues = [] filters = params.discard_outliers make_sub_header("Identifying candidates for building", out=log) # TODO parallelize for chain in pdb_hierarchy.only_model().chains() : if (not chain.is_protein()) : continue for residue_group in chain.residue_groups() : atom_groups = residue_group.atom_groups() id_str = residue_group.id_str() i_seqs = residue_group.atoms().extract_i_seq() residue_sel = selection.select(i_seqs) if (not residue_sel.all_eq(True)) : continue if (len(atom_groups) > 1) : print >> log, " %s is already multi-conformer" % id_str continue atom_group = atom_groups[0] res_class = common_residue_names_get_class(atom_group.resname) if (res_class != "common_amino_acid") : print >> log, " %s: non-standard residue" % id_str continue missing_atoms = rotamer_eval.eval_residue_completeness( residue=atom_group, mon_lib_srv=mon_lib_srv, ignore_hydrogens=True) if (len(missing_atoms) > 0) : # residues modeled as pseudo-ALA are allowed by default; partially # missing sidechains are more problematic if ((building.is_stub_residue(atom_group)) and (not params.ignore_stub_residues)) : pass else : print >> log, " %s: missing or incomplete sidechain" % \ (id_str, len(missing_atoms)) continue validation = multi_criterion.get_residue_group_data(residue_group) is_outlier = is_validation_outlier(validation, params) if (is_outlier) : print >> log, " %s" % str(validation) continue if (params.use_difference_map) : i_seqs_no_hd = building.get_non_hydrogen_atom_indices(residue_group) map_stats = building.local_density_quality( fofc_map=fofc_map, two_fofc_map=two_fofc_map, atom_selection=i_seqs_no_hd, xray_structure=fmodel.xray_structure, radius=params.sampling_radius) if ((map_stats.number_of_atoms_below_fofc_map_level() == 0) and (map_stats.fraction_of_nearby_grid_points_above_cutoff()==0)) : if (verbose) : print >> log, " no difference density for %s" % id_str continue residues.append(residue_group.only_atom_group()) if (len(residues) == 0) : raise Sorry("No residues passed the filtering criteria.") print >> log, "" print >> log, "Alternate conformations will be tried for %d residue(s):" % \ len(residues) building.show_chain_resseq_ranges(residues, out=log, prefix=" ") print >> log, "" return residues