Пример #1
0
 def find_approximate_helices (self, log=sys.stdout) :
   print >> log, "  Looking for approximately helical regions. . ."
   print >> log, "    warning: experimental, results not guaranteed to work!"
   find_helices = proteins.find_helices_simple(self.pdb_hierarchy)
   find_helices.show(out=log)
   restraint_groups = find_helices.as_restraint_groups()
   return restraint_groups
Пример #2
0
 def find_approximate_helices(self, log=sys.stdout):
     print >> log, "  Looking for approximately helical regions. . ."
     print >> log, "    warning: experimental, results not guaranteed to work!"
     find_helices = proteins.find_helices_simple(self.pdb_hierarchy)
     find_helices.show(out=log)
     restraint_groups = find_helices.as_restraint_groups()
     return restraint_groups
Пример #3
0
def run(
    fmodel,
    geometry_restraints_manager,
    pdb_hierarchy,
    solvent_selection,
    secondary_structure=None,
    params=None,
    optimize_hd=False,
    log=None,
):
    from mmtbx.refinement import print_statistics
    from mmtbx.secondary_structure import proteins
    import mmtbx.restraints
    import mmtbx.model
    from scitbx.array_family import flex

    if log is None:
        log = sys.stdout
    if params is None:
        params = master_params().extract()
    if secondary_structure is None:
        import mmtbx.secondary_structure

        secondary_structure = mmtbx.secondary_structure.manager(pdb_hierarchy=pdb_hierarchy)
    print_statistics.make_sub_header(text="Peptide bond flips", out=log)
    validator = ramachandran_validator()
    restraints_manager = mmtbx.restraints.manager(geometry=geometry_restraints_manager, normalization=True)
    model = mmtbx.model.manager(
        restraints_manager=restraints_manager, xray_structure=fmodel.xray_structure, pdb_hierarchy=pdb_hierarchy
    )
    backbone_selections = model.backbone_selections()
    if params.ignore_water_when_flipping:
        selection = ~model.solvent_selection()
    else:
        selection = flex.bool(model.xray_structure.scatterers().size(), True)
    selection &= backbone_selections
    fmt = "Macro-cycle %2d: r_work=%6.4f r_free=%6.4f"
    print >> log, fmt % (0, fmodel.r_work(), fmodel.r_free())
    n_mac = params.number_of_macro_cycles
    if n_mac is None:
        n_mac = 0
    for macro_cycle in range(1, n_mac + 1):
        target_map_data, fft_map_1 = fit_rotamers.get_map_data(fmodel=fmodel, map_type=params.target_map)
        model_map_data, fft_map_2 = fit_rotamers.get_map_data(fmodel=fmodel, map_type=params.model_map)
        residual_map_data, fft_map_3 = fit_rotamers.get_map_data(fmodel=fmodel, map_type=params.residual_map)
        if params.filter_residual_map_value is not None:  # XXX use filtering....
            map_sel = flex.abs(residual_map_data) < params.filter_residual_map_value
            residual_map_data = residual_map_data.set_selected(map_sel, 0)
        if params.filter_2fofc_map is not None:
            map_sel = flex.abs(target_map_data) < params.filter_2fofc_map
            target_map_data = target_map_data.set_selected(map_sel, 0)
        rsr_manager = fit_rotamers.refiner(
            pdb_hierarchy=pdb_hierarchy,
            target_map=target_map_data,
            geometry_restraints_manager=geometry_restraints_manager,
            real_space_target_weight=params.residue_iteration.real_space_refine_target_weight,
            real_space_gradients_delta=fmodel.f_obs().d_min() / 4,
            max_iterations=params.residue_iteration.real_space_refine_max_iterations,
        )
        secondary_structure.pdb_hierarchy = pdb_hierarchy
        alpha_selection = secondary_structure.helix_selection(alpha_only=True)
        if params.skip_approximate_helices:
            cache = pdb_hierarchy.atom_selection_cache()
            print >> log, "Looking for roughly helical residues. . ."
            find_helices = proteins.find_helices_simple(pdb_hierarchy)
            # find_helices.show(out=log)
            print >> log, ""
            ss_params = find_helices.as_restraint_groups()
            if ss_params is not None:
                for helix in ss_params.helix:
                    helix_selection = cache.selection(helix.selection)
                    alpha_selection |= helix_selection
        residue_rsr_monitor = residue_iteration(
            pdb_hierarchy=pdb_hierarchy,
            xray_structure=fmodel.xray_structure,
            selection=selection,
            alpha_selection=alpha_selection,
            target_map_data=target_map_data,
            model_map_data=model_map_data,
            residual_map_data=residual_map_data,
            rsr_manager=rsr_manager,
            params=params.residue_iteration,
            validator=validator,
            log=log,
        )
        fmodel.update_xray_structure(update_f_calc=True, update_f_mask=True)
        print >> log, "1:", fmt % (macro_cycle, fmodel.r_work(), fmodel.r_free())
        del target_map_data, model_map_data, residual_map_data, fft_map_1, fft_map_2, fft_map_3
        if params.real_space_refine_overall:
            pass
            # FIXME this method has completely disappeared...
            # fit_rotamers.rsr_overall(
            #  model=model,
            #  fmodel=fmodel,
            #  params=params,
            #  optimize_hd=optimize_hd,
            #  macro_cycle=macro_cycle,
            #  log=log)
            # print >> log, "1:", fmt%(macro_cycle, fmodel.r_work(), fmodel.r_free())
        if params.validate_change:
            fit_rotamers.validate_changes(
                fmodel=fmodel, residue_rsr_monitor=residue_rsr_monitor, validate_method=validator, log=log
            )
        pdb_hierarchy.atoms().set_xyz(fmodel.xray_structure.sites_cart())