Ejemplo n.º 1
0
 def show(self):
   b = self.bss_result
   print >> self.log, "  Statistics in resolution bins:"
   #assert k_mask.size() == len(self.bin_selections)
   fmt="  %7.5f %6.2f -%6.2f %5.1f %5d %-6s %-6s %-6s  %6.3f %6.3f %8.2f %6.4f"
   f_model = self.core.f_model.data()
   print >> self.log, "  s^2      Resolution    Compl Nrefl k_mask                 k_iso  k_ani <Fobs>   R"
   print >> self.log, "                (A)        (%)       orig   smooth average"
   k_mask_bin_orig_   = str(None)
   k_mask_bin_smooth_ = str(None)
   k_mask_bin_approx_ = str(None)
   for i_sel, cas in enumerate(self.cores_and_selections):
     selection, core, selection_use, sel_work = cas
     sel = sel_work
     ss_ = self.ss_bin_values[i_sel][2]
     if(b is not None and self.bss_result.k_mask_bin_orig is not None):
       k_mask_bin_orig_ = "%6.4f"%self.bss_result.k_mask_bin_orig[i_sel]
     if(b is not None and self.bss_result.k_mask_bin_smooth is not None):
       k_mask_bin_smooth_ = "%6.4f"%self.bss_result.k_mask_bin_smooth[i_sel]
     k_mask_bin_averaged_ = "%6.4f"%flex.mean(self.core.k_mask().select(sel))
     d_             = self.d_spacings.data().select(sel)
     d_min_         = flex.min(d_)
     d_max_         = flex.max(d_)
     n_ref_         = d_.size()
     f_obs_         = self.f_obs.select(sel)
     f_obs_mean_    = flex.mean(f_obs_.data())
     k_isotropic_   = flex.mean(self.core.k_isotropic.select(sel))
     k_anisotropic_ = flex.mean(self.core.k_anisotropic.select(sel))
     cmpl_          = f_obs_.completeness(d_max=d_max_)*100.
     r_             = bulk_solvent.r_factor(f_obs_.data(),f_model.select(sel),1)
     print >> self.log, fmt%(ss_, d_max_, d_min_, cmpl_, n_ref_,
       k_mask_bin_orig_, k_mask_bin_smooth_,k_mask_bin_averaged_,
       k_isotropic_, k_anisotropic_, f_obs_mean_, r_)
Ejemplo n.º 2
0
 def show(self):
     b = self.bss_result
     print("  Statistics in resolution bins:", file=self.log)
     #assert k_mask.size() == len(self.bin_selections)
     fmt = "  %7.5f %6.2f -%6.2f %5.1f %5d %-6s %-6s %-6s  %6.3f %6.3f %8.2f %6.4f"
     f_model = self.core.f_model.data()
     print(
         "  s^2      Resolution    Compl Nrefl k_mask                 k_iso  k_ani <Fobs>   R",
         file=self.log)
     print("                (A)        (%)       orig   smooth average",
           file=self.log)
     k_mask_bin_orig_ = str(None)
     k_mask_bin_smooth_ = str(None)
     k_mask_bin_approx_ = str(None)
     for i_sel, cas in enumerate(self.cores_and_selections):
         selection, core, selection_use, sel_work = cas
         sel = sel_work
         ss_ = self.ss_bin_values[i_sel][2]
         if (b is not None and self.bss_result.k_mask_bin_orig is not None):
             k_mask_bin_orig_ = "%6.4f" % self.bss_result.k_mask_bin_orig[
                 i_sel]
         if (b is not None
                 and self.bss_result.k_mask_bin_smooth is not None):
             k_mask_bin_smooth_ = "%6.4f" % self.bss_result.k_mask_bin_smooth[
                 i_sel]
         k_mask_bin_averaged_ = "%6.4f" % flex.mean(
             self.core.k_mask().select(sel))
         d_ = self.d_spacings.data().select(sel)
         d_min_ = flex.min(d_)
         d_max_ = flex.max(d_)
         n_ref_ = d_.size()
         f_obs_ = self.f_obs.select(sel)
         f_obs_mean_ = flex.mean(f_obs_.data())
         k_isotropic_ = flex.mean(self.core.k_isotropic.select(sel))
         k_anisotropic_ = flex.mean(self.core.k_anisotropic.select(sel))
         cmpl_ = f_obs_.completeness(d_max=d_max_) * 100.
         r_ = bulk_solvent.r_factor(f_obs_.data(), f_model.select(sel), 1)
         print(fmt % (ss_, d_max_, d_min_, cmpl_, n_ref_, k_mask_bin_orig_,
                      k_mask_bin_smooth_, k_mask_bin_averaged_,
                      k_isotropic_, k_anisotropic_, f_obs_mean_, r_),
               file=self.log)
Ejemplo n.º 3
0
  def scaling_metrics(self,other):
    # Read reflections
    # some requirements. 1) Fobs scaled to Fcalc, not the other way around.
    # 2) ability to make a plot of the two scaled sets
    # 3) set the number of bins
    # 4) understand and print out the per-bin scaling factor
    # 5) print an overall stats line at the end of the table
    # 6) choose one or the other binnings
    """1) scaling and analysis are separate functions"""

    #f_obs, r_free_flags = f_obs.common_sets(r_free_flags)
    f_obs = other
    #r_free_flags = r_free_flags.array(data=r_free_flags.data()==1)
    # Read model

    # Get Fmodel
    fmodel = mmtbx.f_model.manager(
      f_obs          = f_obs,
      #r_free_flags   = r_free_flags,
      xray_structure = self.xray_structure)
    # Do anisotropic overall scaling, bulk-solvent modeling, outlier rejection
    #fmodel.update_all_scales()
    print "r_work, r_free: %6.4f, %6.4f"%(fmodel.r_work(), fmodel.r_free())
    # Print statistics in resolution bins
    f_model = fmodel.f_model_scaled_with_k1()
    bin_selections = fmodel.f_obs().log_binning()
    dsd = fmodel.f_obs().d_spacings().data()
    print "Bin# Resolution    Nref Cmpl  Rw     CC"
    fmt="%2d: %6.3f-%-6.3f %5d %5.3f %6.4f %6.4f"
    for i_bin, sel in enumerate(bin_selections):
      d           = dsd.select(sel)
      d_min       = flex.min(d)
      d_max       = flex.max(d)
      fmodel_sel  = fmodel.select(sel)
      n           = d.size()
      f_obs_sel   = fmodel.f_obs().select(sel)
      f_model_sel = abs(f_model.select(sel)).data()
      cmpl        = f_obs_sel.completeness(d_max=d_max)
      r_work      = fmodel_sel.r_work()
      cc          = flex.linear_correlation(x=f_obs_sel.data(),
                    y=f_model_sel).coefficient()
      print fmt%(i_bin, d_max, d_min, n, cmpl, r_work, cc)
    # Alternative binning
    print
    print "Bin# Resolution    Nref Cmpl  Rw     CC"
    fmodel.f_obs().setup_binner(reflections_per_bin = 2500)
    f_model.use_binning_of(fmodel.f_obs())
    for i_bin in fmodel.f_obs().binner().range_used():
      sel = fmodel.f_obs().binner().selection(i_bin)
      d           = dsd.select(sel)
      d_min       = flex.min(d)
      d_max       = flex.max(d)
      fmodel_sel  = fmodel.select(sel)
      n           = d.size()
      f_obs_sel   = fmodel.f_obs().select(sel)
      f_model_sel = abs(f_model.select(sel)).data()
      cmpl        = f_obs_sel.completeness(d_max=d_max)
      r_work      = fmodel_sel.r_work()
      cc          = flex.linear_correlation(x=f_obs_sel.data(),
                    y=f_model_sel).coefficient()
      print fmt%(i_bin, d_max, d_min, n, cmpl, r_work, cc)
Ejemplo n.º 4
0
    def scaling_metrics(self, other):
        # Read reflections
        # some requirements. 1) Fobs scaled to Fcalc, not the other way around.
        # 2) ability to make a plot of the two scaled sets
        # 3) set the number of bins
        # 4) understand and print out the per-bin scaling factor
        # 5) print an overall stats line at the end of the table
        # 6) choose one or the other binnings
        """1) scaling and analysis are separate functions"""

        #f_obs, r_free_flags = f_obs.common_sets(r_free_flags)
        f_obs = other
        #r_free_flags = r_free_flags.array(data=r_free_flags.data()==1)
        # Read model

        # Get Fmodel
        fmodel = mmtbx.f_model.manager(
            f_obs=f_obs,
            #r_free_flags   = r_free_flags,
            xray_structure=self.xray_structure)
        # Do anisotropic overall scaling, bulk-solvent modeling, outlier rejection
        #fmodel.update_all_scales()
        print "r_work, r_free: %6.4f, %6.4f" % (fmodel.r_work(),
                                                fmodel.r_free())
        # Print statistics in resolution bins
        f_model = fmodel.f_model_scaled_with_k1()
        bin_selections = fmodel.f_obs().log_binning()
        dsd = fmodel.f_obs().d_spacings().data()
        print "Bin# Resolution    Nref Cmpl  Rw     CC"
        fmt = "%2d: %6.3f-%-6.3f %5d %5.3f %6.4f %6.4f"
        for i_bin, sel in enumerate(bin_selections):
            d = dsd.select(sel)
            d_min = flex.min(d)
            d_max = flex.max(d)
            fmodel_sel = fmodel.select(sel)
            n = d.size()
            f_obs_sel = fmodel.f_obs().select(sel)
            f_model_sel = abs(f_model.select(sel)).data()
            cmpl = f_obs_sel.completeness(d_max=d_max)
            r_work = fmodel_sel.r_work()
            cc = flex.linear_correlation(x=f_obs_sel.data(),
                                         y=f_model_sel).coefficient()
            print fmt % (i_bin, d_max, d_min, n, cmpl, r_work, cc)
        # Alternative binning
        print
        print "Bin# Resolution    Nref Cmpl  Rw     CC"
        fmodel.f_obs().setup_binner(reflections_per_bin=2500)
        f_model.use_binning_of(fmodel.f_obs())
        for i_bin in fmodel.f_obs().binner().range_used():
            sel = fmodel.f_obs().binner().selection(i_bin)
            d = dsd.select(sel)
            d_min = flex.min(d)
            d_max = flex.max(d)
            fmodel_sel = fmodel.select(sel)
            n = d.size()
            f_obs_sel = fmodel.f_obs().select(sel)
            f_model_sel = abs(f_model.select(sel)).data()
            cmpl = f_obs_sel.completeness(d_max=d_max)
            r_work = fmodel_sel.r_work()
            cc = flex.linear_correlation(x=f_obs_sel.data(),
                                         y=f_model_sel).coefficient()
            print fmt % (i_bin, d_max, d_min, n, cmpl, r_work, cc)