示例#1
0
    def run(self):
        r = self.parse_cl()
        if r != 0:
            return
        r = self.read_model_file()
        if r != 0:
            return

        pi_params = self.get_pdb_interpretation_params()
        model = mmtbx.model.manager(
            model_input=self.pdb_inp,
            #        process_input             = True,
            build_grm=True,
            stop_for_unknowns=False,
            pdb_interpretation_params=pi_params,
            restraint_objects=self.input_objects.cif_objects)

        print("Model object created from file %s:" % \
          getattr(self.work_params, self.pdbf_def), file=self.log)

        # If needed, this could be wrapped in try...except to catch errors.
        c = validate_H(model=model,
                       use_neutron_distances=pi_params.pdb_interpretation.
                       use_neutron_distances)
        c.validate_inputs()
        c.run()
        results = c.get_results()
        self.print_results(results)
示例#2
0
    def __init__(
            self,
            model,
            pdb_hierarchy=None,  # keep for mmtbx.validation_summary (multiple models)
            fmodel=None,
            fmodel_neutron=None,
            sequences=None,
            flags=None,
            header_info=None,
            raw_data=None,
            unmerged_data=None,
            keep_hydrogens=True,
            nuclear=False,
            save_probe_unformatted_file=None,
            show_hydrogen_outliers=False,
            min_cc_two_fofc=0.8,
            n_bins_data=10,
            count_anomalous_pairs_separately=False,
            use_internal_variance=True,
            outliers_only=True,
            use_pdb_header_resolution_cutoffs=False,
            file_name=None,
            ligand_selection=None,
            rotamer_library="8000",
            map_params=None):
        assert rotamer_library == "8000", "data_version given to RotamerEval not recognized."
        for name in self.__slots__:
            setattr(self, name, None)

        # use objects from model
        self.model = model
        if (self.model is not None):
            pdb_hierarchy = self.model.get_hierarchy()
            xray_structure = self.model.get_xray_structure()
            geometry_restraints_manager = self.model.get_restraints_manager(
            ).geometry
            crystal_symmetry = self.model.crystal_symmetry()
            all_chain_proxies = self.model.all_chain_proxies
        else:
            assert (pdb_hierarchy is not None)
            xray_structure = None
            geometry_restraints_manager = None
            crystal_symmetry = None
            all_chain_proxies = None

        # very important - the i_seq attributes may be extracted later
        pdb_hierarchy.atoms().reset_i_seq()
        self.pdb_hierarchy = pdb_hierarchy
        if (xray_structure is None):
            if (fmodel is not None):
                xray_structure = fmodel.xray_structure
            elif (crystal_symmetry is not None):
                xray_structure = pdb_hierarchy.extract_xray_structure(
                    crystal_symmetry=crystal_symmetry)
        self.crystal_symmetry = crystal_symmetry
        if (crystal_symmetry is None) and (fmodel is not None):
            self.crystal_symmetry = fmodel.f_obs().crystal_symmetry()

        # use maps (fmodel is not used)
        # run earlier since pdb_hierarchy gets modified
        use_maps = False
        if (map_params is not None):
            use_maps = ((map_params.input.maps.map_file_name) or
                        ((map_params.input.maps.map_coefficients_file_name) and
                         (map_params.input.maps.map_coefficients_label)))
        if (use_maps):
            if (flags.real_space):
                self.real_space = experimental.real_space(
                    fmodel=None,
                    model=self.model,
                    cc_min=min_cc_two_fofc,
                    molprobity_map_params=map_params.input.maps)
            if (flags.waters):
                self.waters = waters.waters(
                    pdb_hierarchy=pdb_hierarchy,
                    xray_structure=xray_structure,
                    fmodel=None,
                    collect_all=True,
                    molprobity_map_params=map_params.input.maps)

        self.header_info = header_info
        if (flags is None):
            flags = molprobity_flags()
        import mmtbx.model.statistics
        self.model_statistics_geometry = mmtbx.model.statistics.geometry(
            pdb_hierarchy=pdb_hierarchy,
            geometry_restraints_manager=geometry_restraints_manager,
            use_hydrogens=keep_hydrogens,
            use_nuclear=nuclear)
        self.model_statistics_geometry_result = \
          self.model_statistics_geometry.result()
        self.ramalyze = self.model_statistics_geometry_result.ramachandran.ramalyze
        self.omegalyze = self.model_statistics_geometry_result.omega.omegalyze
        self.rotalyze = self.model_statistics_geometry_result.rotamer.rotalyze
        self.cbetadev = self.model_statistics_geometry_result.c_beta.cbetadev
        self.clashes = self.model_statistics_geometry_result.clash.clashes
        if pdb_hierarchy.contains_protein():
            self.find_missing_atoms(out=null_out())
            if (flags.nqh):
                self.nqh_flips = clashscore.nqh_flips(
                    pdb_hierarchy=pdb_hierarchy)
        if (pdb_hierarchy.contains_rna() and flags.rna
                and libtbx.env.has_module(name="suitename")):
            if (geometry_restraints_manager is not None):
                self.rna = rna_validate.rna_validation(
                    pdb_hierarchy=pdb_hierarchy,
                    geometry_restraints_manager=geometry_restraints_manager,
                    outliers_only=outliers_only,
                    params=None)
        if (flags.model_stats) and (xray_structure is not None):
            self.model_stats = model_properties.model_statistics(
                pdb_hierarchy=pdb_hierarchy,
                xray_structure=xray_structure,
                all_chain_proxies=all_chain_proxies,
                ignore_hd=(not nuclear),
                ligand_selection=ligand_selection)
        if (geometry_restraints_manager is not None) and (flags.restraints):
            assert (xray_structure is not None)
            self.restraints = restraints.combined(
                pdb_hierarchy=pdb_hierarchy,
                xray_structure=xray_structure,
                geometry_restraints_manager=geometry_restraints_manager,
                ignore_hd=(not nuclear),
                cdl=getattr(all_chain_proxies, "use_cdl", None))
        if (sequences is not None) and (flags.seq):
            self.sequence = sequence.validation(
                pdb_hierarchy=pdb_hierarchy,
                sequences=sequences,
                log=null_out(),
                include_secondary_structure=True,
                extract_coordinates=True)

        if (fmodel is not None):
            if (use_pdb_header_resolution_cutoffs) and (header_info
                                                        is not None):
                fmodel = fmodel.resolution_filter(d_min=header_info.d_min,
                                                  d_max=header_info.d_max)
            if (flags.rfactors):
                self.data_stats = experimental.data_statistics(
                    fmodel,
                    raw_data=raw_data,
                    n_bins=n_bins_data,
                    count_anomalous_pairs_separately=
                    count_anomalous_pairs_separately)

            if (not use_maps):  # if maps are used, keep previous results
                if (flags.real_space):
                    self.real_space = experimental.real_space(
                        model=model, fmodel=fmodel, cc_min=min_cc_two_fofc)
                if (flags.waters):
                    self.waters = waters.waters(pdb_hierarchy=pdb_hierarchy,
                                                xray_structure=xray_structure,
                                                fmodel=fmodel,
                                                collect_all=True)

            if (unmerged_data is not None):
                self.merging = experimental.merging_and_model_statistics(
                    f_obs=fmodel.f_obs(),
                    f_model=fmodel.f_model(),
                    r_free_flags=fmodel.r_free_flags(),
                    unmerged_i_obs=unmerged_data,
                    anomalous=count_anomalous_pairs_separately,
                    use_internal_variance=use_internal_variance,
                    n_bins=n_bins_data)
            if (flags.xtriage):
                import mmtbx.scaling.xtriage
                f_model = abs(
                    fmodel.f_model()).set_observation_type_xray_amplitude()
                if (raw_data is not None):
                    f_model, obs = f_model.common_sets(other=raw_data)
                else:
                    obs = fmodel.f_obs()
                self.xtriage = mmtbx.scaling.xtriage.xtriage_analyses(
                    miller_obs=obs,
                    miller_calc=f_model,
                    unmerged_obs=unmerged_data,  # XXX some redundancy here...
                    text_out=null_out())
        if (fmodel_neutron is not None) and (flags.rfactors):
            self.neutron_stats = experimental.data_statistics(
                fmodel_neutron,
                n_bins=n_bins_data,
                count_anomalous_pairs_separately=False)
        if (pdb_hierarchy.models_size() == 1):
            self._multi_criterion = multi_criterion_view(pdb_hierarchy)

        # wilson B
        self.wilson_b = None
        if (fmodel is not None):
            self.wilson_b = fmodel.wilson_b()
        elif (fmodel_neutron is not None):
            self.wilson_b = fmodel_neutron.wilson_b()

        # validate hydrogens
        self.hydrogens = None
        if ((self.model is not None) and (self.model.has_hd)):
            # import here to avoid circular import issues
            from mmtbx.hydrogens.validate_H import validate_H, validate_H_results
            hydrogens = validate_H(model, nuclear)
            hydrogens.validate_inputs()
            hydrogens.run()
            self.hydrogens = validate_H_results(hydrogens.get_results())

        # write probe file if needed (CLI and GUI)
        if (save_probe_unformatted_file is not None):
            pcm = self.clashes.probe_clashscore_manager
            try:
                with open(save_probe_unformatted_file, 'w') as f:
                    f.write(pcm.probe_unformatted)
                self.clashes.probe_file = save_probe_unformatted_file
            except IOError as err:
                raise Sorry('%s could not be written correctly.\n%s' %
                            (save_probe_unformatted_file, err))