コード例 #1
0
 def show(self, message):
     print >> self.log, message
     sol_sel = self.model.solvent_selection()
     xrs_mac_h = self.model.get_xray_structure().select(~sol_sel)
     xrs_sol_h = self.model.get_xray_structure().select(sol_sel)
     hd_sol = self.model.get_hd_selection().select(sol_sel)
     hd_mac = self.model.get_hd_selection().select(~sol_sel)
     xrs_sol = xrs_sol_h.select(~hd_sol)
     xrs_mac = xrs_mac_h.select(~hd_mac)
     scat = xrs_sol.scatterers()
     occ = scat.extract_occupancies()
     b_isos = scat.extract_u_iso_or_u_equiv(
         self.model.get_xray_structure().unit_cell()) * math.pi**2 * 8
     smallest_distances = xrs_mac.closest_distances(
       sites_frac      = xrs_sol.sites_frac(),
       distance_cutoff = self.find_peaks_params.map_next_to_model.\
         max_model_peak_dist).smallest_distances
     number = format_value("%-7d", scat.size())
     b_min = format_value("%-7.2f", flex.min_default(b_isos, None))
     b_max = format_value("%-7.2f", flex.max_default(b_isos, None))
     b_ave = format_value("%-7.2f", flex.mean_default(b_isos, None))
     bl_min = format_value("%-7.2f", self.params.b_iso_min).strip()
     bl_max = format_value("%-7.2f", self.params.b_iso_max).strip()
     o_min = format_value("%-7.2f", flex.min_default(occ, None))
     o_max = format_value("%-7.2f", flex.max_default(occ, None))
     ol_min = format_value("%-7.2f", self.params.occupancy_min).strip()
     ol_max = format_value("%-7.2f", self.params.occupancy_max).strip()
     d_min = format_value("%-7.2f",
                          flex.min_default(smallest_distances, None))
     d_max = format_value("%-7.2f",
                          flex.max_default(smallest_distances, None))
     dl_min = format_value(
         "%-7.2f", self.find_peaks_params.map_next_to_model.
         min_model_peak_dist).strip()
     dl_max = format_value(
         "%-7.2f", self.find_peaks_params.map_next_to_model.
         max_model_peak_dist).strip()
     ani_min = format_value(
         "%-7.2f",
         flex.min_default(scat.anisotropy(unit_cell=xrs_sol.unit_cell()),
                          None))
     ani_min_l = format_value("%-7.2f", self.params.anisotropy_min).strip()
     print >> self.log, "  number           = %s" % number
     print >> self.log, "  b_iso_min        = %s (limit = %s)" % (b_min,
                                                                  bl_min)
     print >> self.log, "  b_iso_max        = %s (limit = %s)" % (b_max,
                                                                  bl_max)
     print >> self.log, "  b_iso_mean       = %s             " % (b_ave)
     print >> self.log, "  anisotropy_min   = %s (limit = %s)" % (ani_min,
                                                                  ani_min_l)
     print >> self.log, "  occupancy_min    = %s (limit = %s)" % (o_min,
                                                                  ol_min)
     print >> self.log, "  occupancy_max    = %s (limit = %s)" % (o_max,
                                                                  ol_max)
     print >> self.log, "  dist_sol_mol_min = %s (limit = %s)" % (d_min,
                                                                  dl_min)
     print >> self.log, "  dist_sol_mol_max = %s (limit = %s)" % (d_max,
                                                                  dl_max)
コード例 #2
0
 def __init__(self, xray_structure,
                    n_real    = None,
                    grid_step = None):
   assert [n_real, grid_step].count(None) == 1
   self.xray_structure = xray_structure
   # XXX Use crystal gridding
   if(n_real is None):
      a_cell, b_cell, c_cell = self.xray_structure.unit_cell().parameters()[:3]
      nx,ny,nz = \
             int(a_cell/grid_step),int(b_cell/grid_step),int(c_cell/grid_step)
   else:
      nx,ny,nz = n_real[0],n_real[1],n_real[2]
   #
   occs = self.xray_structure.scatterers().extract_occupancies()
   sel = occs>0
   self.xray_structure = self.xray_structure.select(sel)
   #
   self.xray_structure.tidy_us()
   us = flex.min_default(self.xray_structure.extract_u_iso_or_u_equiv(),0)
   u_base = self.xray_structure.min_u_cart_eigenvalue()
   u_base = min(us, u_base)
   self.sampled_model_density = ext.sampled_model_density(
      unit_cell                        = self.xray_structure.unit_cell(),
      scatterers                       = self.xray_structure.scatterers(),
      scattering_type_registry =self.xray_structure.scattering_type_registry(),
      fft_n_real                       = (nx,ny,nz),
      fft_m_real                       = (nx,ny,nz),
      u_base                           = u_base,
      wing_cutoff                      = 1.e-6,
      exp_table_one_over_step_size     = -1000,
      force_complex                    = False,
      sampled_density_must_be_positive = False,
      tolerance_positive_definite      = 1.e-5)
   assert approx_equal(self.sampled_model_density.u_extra(), 0.0)
コード例 #3
0
ファイル: energies.py プロジェクト: yayahjb/cctbx_project
  def angle_deviations_z(self):
    '''
    Calculate rmsz of angles deviations

    Compute rmsz, the Root-Mean-Square of the z-scors for a set of data
    using z_i = {x_i - mu / sigma}  and rmsz = sqrt(mean(z*z))

    Compute rmsz, the Root-Mean-Square of the z-scors for a set of data
    using z_i = {x_i - mu / sigma}  and rmsz = sqrt(mean(z*z))
    x_i: atcual bond angle
    mu: geometry restraints mean
    sigma:  geometry restraints standard deviation
    z_i: z-score for bond i
    z: array of z_i

    The sigma and the (x_i - mu) are model constrains, geometry restraints. They function extracts
    from self, not calculated from data.

    :returns:
    a_rmsz: rmsz, root mean square of the z-scors of all angles
    a_z_min/max: min/max values of z-scors
    '''
    if(self.n_angle_proxies is not None):
      angle_deltas = self.angle_proxies.proxy_select(origin_id=0).deltas(
          sites_cart=self.sites_cart)
      if len(angle_deltas) > 0:
        sigmas = [geometry_restraints.weight_as_sigma(x.weight) for x in self.angle_proxies]
        z_scores = flex.double([(angle_delta/sigma) for angle_delta,sigma in zip(angle_deltas,sigmas)])
        a_rmsz = math.sqrt(flex.mean_default(z_scores*z_scores,0))
        a_z_max = flex.max_default(flex.abs(z_scores), 0)
        a_z_min = flex.min_default(flex.abs(z_scores), 0)
        return a_z_min, a_z_max, a_rmsz
      else:
        return 0,0,0
コード例 #4
0
ファイル: energies.py プロジェクト: yayahjb/cctbx_project
  def bond_deviations_z(self):
    '''
    Calculate rmsz of bond deviations

    Compute rmsz, the Root-Mean-Square of the z-scors for a set of data
    using z_i = {x_i - mu / sigma}  and rmsz = sqrt(mean(z*z))
    x_i: atcual bond length
    mu: geometry restraints mean
    sigma:  geometry restraints standard deviation
    z_i: z-score for bond i
    z: array of z_i

    The sigma and the (x_i - mu) are model constrains, geometry restraints.
    This function extracts from self, not calculated from data.

    :returns:
    b_rmsz: rmsz, root mean square of the z-scors of all bonds
    b_z_min/max: min/max abolute values of z-scors
    '''
    if(self.n_bond_proxies is not None):
      bond_deltas = self.bond_proxies.deltas(
          sites_cart=self.sites_cart, origin_id=0)
      if len(bond_deltas) >0:
        sigmas = [geometry_restraints.weight_as_sigma(x.weight) for x in self.bond_proxies.simple]
        z_scores = flex.double([(bond_delta/sigma) for bond_delta,sigma in zip(bond_deltas,sigmas)])
        b_rmsz = math.sqrt(flex.mean_default(z_scores*z_scores,0))
        b_z_max = flex.max_default(flex.abs(z_scores), 0)
        b_z_min = flex.min_default(flex.abs(z_scores), 0)
        return b_z_min, b_z_max, b_rmsz
      else:
        return 0,0,0
コード例 #5
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
  def bond_deviations_z(self):
    '''
    Calculate rmsz of bond deviations

    Compute rmsz, the Root-Mean-Square of the z-scors for a set of data
    using z_i = {x_i - mu / sigma}  and rmsz = sqrt(mean(z*z))
    x_i: atcual bond length
    mu: geometry restraints mean
    sigma:  geometry restraints standard deviation
    z_i: z-score for bond i
    z: array of z_i

    The sigma and the (x_i - mu) are model constrains, geometry restraints. They function extracts
    from self, not calculated from data.

    :returns:
    b_rmsz: rmsz, root mean square of the z-scors of all bonds
    b_z_min/max: min/max abolute values of z-scors
    '''
    if(self.n_bond_proxies is not None):
      bond_deltas = self.bond_proxies.deltas(
          sites_cart=self.sites_cart, origin_id=0)
      if len(bond_deltas) >0:
        sigmas = [geometry_restraints.weight_as_sigma(x.weight) for x in self.bond_proxies.simple]
        z_scores = flex.double([(bond_delta/sigma) for bond_delta,sigma in zip(bond_deltas,sigmas)])
        b_rmsz = math.sqrt(flex.mean_default(z_scores*z_scores,0))
        b_z_max = flex.max_default(flex.abs(z_scores), 0)
        b_z_min = flex.min_default(flex.abs(z_scores), 0)
        return b_z_min, b_z_max, b_rmsz
      else:
        return 0,0,0
コード例 #6
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
  def angle_deviations_z(self):
    '''
    Calculate rmsz of angles deviations

    Compute rmsz, the Root-Mean-Square of the z-scors for a set of data
    using z_i = {x_i - mu / sigma}  and rmsz = sqrt(mean(z*z))

    Compute rmsz, the Root-Mean-Square of the z-scors for a set of data
    using z_i = {x_i - mu / sigma}  and rmsz = sqrt(mean(z*z))
    x_i: atcual bond angle
    mu: geometry restraints mean
    sigma:  geometry restraints standard deviation
    z_i: z-score for bond i
    z: array of z_i

    The sigma and the (x_i - mu) are model constrains, geometry restraints. They function extracts
    from self, not calculated from data.

    :returns:
    a_rmsz: rmsz, root mean square of the z-scors of all angles
    a_z_min/max: min/max values of z-scors
    '''
    if(self.n_angle_proxies is not None):
      angle_deltas = self.angle_proxies.proxy_select(origin_id=0).deltas(
          sites_cart=self.sites_cart)
      if len(angle_deltas) > 0:
        sigmas = [geometry_restraints.weight_as_sigma(x.weight) for x in self.angle_proxies]
        z_scores = flex.double([(angle_delta/sigma) for angle_delta,sigma in zip(angle_deltas,sigmas)])
        a_rmsz = math.sqrt(flex.mean_default(z_scores*z_scores,0))
        a_z_max = flex.max_default(flex.abs(z_scores), 0)
        a_z_min = flex.min_default(flex.abs(z_scores), 0)
        return a_z_min, a_z_max, a_rmsz
      else:
        return 0,0,0
コード例 #7
0
 def peaks_mapped(self):
     if (self.peaks_ is None): return None
     assert self.mapped == False
     max_dist = self.params.map_next_to_model.max_model_peak_dist
     min_dist = self.params.map_next_to_model.min_model_peak_dist
     if (min_dist is None):
         min_dist = 0.
     if (max_dist is None):
         max_dist = float(sys.maxsize)
     xray_structure = self.fmodel.xray_structure.deep_copy_scatterers()
     use_selection = None
     if (not self.params.map_next_to_model.use_hydrogens):
         use_selection = ~xray_structure.hd_selection()
     initial_number_of_sites = self.peaks_.sites.size()
     if (not self.silent):
         print("Filter by distance & map next to the model:", file=self.log)
     result = xray_structure.closest_distances(sites_frac=self.peaks_.sites,
                                               distance_cutoff=max_dist,
                                               use_selection=use_selection)
     smallest_distances_sq = result.smallest_distances_sq
     smallest_distances = result.smallest_distances
     in_box = smallest_distances_sq > 0
     not_too_far = smallest_distances_sq <= max_dist**2
     not_too_close = smallest_distances_sq >= min_dist**2
     selection = (not_too_far & not_too_close & in_box)
     iseqs_of_closest_atoms = result.i_seqs.select(selection)
     peaks = peaks_holder(heights=self.peaks_.heights.select(selection),
                          sites=result.sites_frac.select(selection),
                          iseqs_of_closest_atoms=iseqs_of_closest_atoms)
     sd = flex.sqrt(smallest_distances_sq.select(in_box))
     d_min = flex.min_default(sd, 0)
     d_max = flex.max_default(sd, 0)
     if (not self.silent):
         print("   mapped sites are within: %5.3f - %5.3f" % (d_min, d_max),
               file=self.log)
         print("   number of sites selected in [dist_min=%5.2f, " \
           "dist_max=%5.2f]: %d from: %d" % (min_dist, max_dist, peaks.sites.size(),
           initial_number_of_sites), file=self.log)
     smallest_distances = flex.sqrt(smallest_distances_sq.select(selection))
     d_min = flex.min_default(smallest_distances, 0)
     d_max = flex.max_default(smallest_distances, 0)
     if (not self.silent):
         print("   mapped sites are within: %5.3f - %5.3f" % (d_min, d_max),
               file=self.log)
     self.mapped = True
     self.peaks_ = peaks
     return peaks
コード例 #8
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def nonbonded_deviations(self):
   if(self.n_nonbonded_proxies is not None):
     nonbonded_deltas = self.nonbonded_distances()
     r_sq  = nonbonded_deltas * nonbonded_deltas
     r_ave = math.sqrt(flex.mean_default(r_sq, 0))
     r_max = math.sqrt(flex.max_default(r_sq, 0))
     r_min = math.sqrt(flex.min_default(r_sq, 0))
     return r_min, r_max, r_ave
コード例 #9
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def nonbonded_deviations(self):
     if (self.n_nonbonded_proxies is not None):
         nonbonded_deltas = self.nonbonded_distances()
         r_sq = nonbonded_deltas * nonbonded_deltas
         r_ave = math.sqrt(flex.mean_default(r_sq, 0))
         r_max = math.sqrt(flex.max_default(r_sq, 0))
         r_min = math.sqrt(flex.min_default(r_sq, 0))
         return r_min, r_max, r_ave
コード例 #10
0
ファイル: find_peaks.py プロジェクト: cctbx/cctbx-playground
 def peaks_mapped(self):
   if(self.peaks_ is None): return None
   assert self.mapped == False
   max_dist = self.params.map_next_to_model.max_model_peak_dist
   min_dist = self.params.map_next_to_model.min_model_peak_dist
   if (min_dist is None) :
     min_dist = 0.
   if (max_dist is None) :
     max_dist = float(sys.maxint)
   xray_structure = self.fmodel.xray_structure.deep_copy_scatterers()
   use_selection = None
   if(not self.params.map_next_to_model.use_hydrogens):
     use_selection = ~xray_structure.hd_selection()
   initial_number_of_sites = self.peaks_.sites.size()
   if(not self.silent):
     print >> self.log, "Filter by distance & map next to the model:"
   result = xray_structure.closest_distances(sites_frac = self.peaks_.sites,
     distance_cutoff = max_dist, use_selection = use_selection)
   smallest_distances_sq = result.smallest_distances_sq
   smallest_distances = result.smallest_distances
   in_box = smallest_distances_sq > 0
   not_too_far = smallest_distances_sq <= max_dist**2
   not_too_close = smallest_distances_sq >= min_dist**2
   selection = (not_too_far & not_too_close & in_box)
   iseqs_of_closest_atoms = result.i_seqs.select(selection)
   peaks = peaks_holder(
     heights                = self.peaks_.heights.select(selection),
     sites                  = result.sites_frac.select(selection),
     iseqs_of_closest_atoms = iseqs_of_closest_atoms)
   sd = flex.sqrt(smallest_distances_sq.select(in_box))
   d_min = flex.min_default(sd, 0)
   d_max = flex.max_default(sd, 0)
   if(not self.silent):
     print >> self.log,"   mapped sites are within: %5.3f - %5.3f"%(d_min,d_max)
     print >> self.log, "   number of sites selected in [dist_min=%5.2f, " \
       "dist_max=%5.2f]: %d from: %d" % (min_dist, max_dist, peaks.sites.size(),
       initial_number_of_sites)
   smallest_distances = flex.sqrt(smallest_distances_sq.select(selection))
   d_min = flex.min_default(smallest_distances, 0)
   d_max = flex.max_default(smallest_distances, 0)
   if(not self.silent):
     print >> self.log,"   mapped sites are within: %5.3f - %5.3f"%(d_min,d_max)
   self.mapped = True
   self.peaks_ = peaks
   return peaks
コード例 #11
0
 def show(self, message):
   print >> self.log, message
   sol_sel = self.model.solvent_selection()
   xrs_mac_h = self.model.xray_structure.select(~sol_sel)
   xrs_sol_h = self.model.xray_structure.select(sol_sel)
   hd_sol = self.model.xray_structure.hd_selection().select(sol_sel)
   hd_mac = self.model.xray_structure.hd_selection().select(~sol_sel)
   xrs_sol = xrs_sol_h.select(~hd_sol)
   xrs_mac = xrs_mac_h.select(~hd_mac)
   scat = xrs_sol.scatterers()
   occ = scat.extract_occupancies()
   b_isos = scat.extract_u_iso_or_u_equiv(
     self.model.xray_structure.unit_cell()) * math.pi**2*8
   smallest_distances = xrs_mac.closest_distances(
     sites_frac      = xrs_sol.sites_frac(),
     distance_cutoff = self.find_peaks_params.map_next_to_model.\
       max_model_peak_dist).smallest_distances
   number = format_value("%-7d",scat.size())
   b_min  = format_value("%-7.2f", flex.min_default( b_isos, None))
   b_max  = format_value("%-7.2f", flex.max_default( b_isos, None))
   b_ave  = format_value("%-7.2f", flex.mean_default(b_isos, None))
   bl_min = format_value("%-7.2f", self.params.b_iso_min).strip()
   bl_max = format_value("%-7.2f", self.params.b_iso_max).strip()
   o_min  = format_value("%-7.2f", flex.min_default(occ, None))
   o_max  = format_value("%-7.2f", flex.max_default(occ, None))
   ol_min = format_value("%-7.2f", self.params.occupancy_min).strip()
   ol_max = format_value("%-7.2f", self.params.occupancy_max).strip()
   d_min  = format_value("%-7.2f", flex.min_default(smallest_distances, None))
   d_max  = format_value("%-7.2f", flex.max_default(smallest_distances, None))
   dl_min = format_value("%-7.2f",
     self.find_peaks_params.map_next_to_model.min_model_peak_dist).strip()
   dl_max = format_value("%-7.2f",
     self.find_peaks_params.map_next_to_model.max_model_peak_dist).strip()
   ani_min = format_value("%-7.2f", flex.min_default(scat.anisotropy(
     unit_cell = xrs_sol.unit_cell()), None))
   ani_min_l = format_value("%-7.2f",self.params.anisotropy_min).strip()
   print >>self.log,"  number           = %s"%number
   print >>self.log,"  b_iso_min        = %s (limit = %s)"%(b_min, bl_min)
   print >>self.log,"  b_iso_max        = %s (limit = %s)"%(b_max, bl_max)
   print >>self.log,"  b_iso_mean       = %s             "%(b_ave)
   print >>self.log,"  anisotropy_min   = %s (limit = %s)"%(ani_min,ani_min_l)
   print >>self.log,"  occupancy_min    = %s (limit = %s)"%(o_min, ol_min)
   print >>self.log,"  occupancy_max    = %s (limit = %s)"%(o_max, ol_max)
   print >>self.log,"  dist_sol_mol_min = %s (limit = %s)"%(d_min, dl_min)
   print >>self.log,"  dist_sol_mol_max = %s (limit = %s)"%(d_max, dl_max)
コード例 #12
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def isotropic_adp_deviation(self):
     if (self.n_isotropic_adp_proxies is not None):
         isotropic_adp_deltas_rms = adp_restraints.isotropic_adp_deltas_rms(
             u_cart=self.u_cart, proxies=self.isotropic_adp_proxies)
         i_sq = isotropic_adp_deltas_rms * isotropic_adp_deltas_rms
         i_ave = math.sqrt(flex.mean_default(i_sq, 0))
         i_max = math.sqrt(flex.max_default(i_sq, 0))
         i_min = math.sqrt(flex.min_default(i_sq, 0))
         return i_min, i_max, i_ave
コード例 #13
0
 def is_water_last(self):
   result = True
   sol_sel = self.model.solvent_selection()
   i_sol_sel = sol_sel.iselection()
   i_mac_sel = (~sol_sel).iselection()
   if(i_sol_sel.size() > 0 and i_mac_sel.size() > 0):
     if(flex.min_default(i_sol_sel,0)-flex.max_default(i_mac_sel,0) != 1):
       result = False
   return result
コード例 #14
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def parallelity_deviations(self):
     if self.n_parallelity_proxies is not None:
         parallelity_deltas = geometry_restraints.parallelity_deltas(
             sites_cart=self.sites_cart, proxies=self.parallelity_proxies)
         p_sq = parallelity_deltas * parallelity_deltas
         p_ave = math.sqrt(flex.mean_default(p_sq, 0))
         p_max = math.sqrt(flex.max_default(p_sq, 0))
         p_min = math.sqrt(flex.min_default(p_sq, 0))
         return p_min, p_max, p_ave
コード例 #15
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def chirality_deviations(self):
     if (self.n_chirality_proxies is not None):
         chirality_deltas = geometry_restraints.chirality_deltas(
             sites_cart=self.sites_cart, proxies=self.chirality_proxies)
         c_sq = chirality_deltas * chirality_deltas
         c_ave = math.sqrt(flex.mean_default(c_sq, 0))
         c_max = math.sqrt(flex.max_default(c_sq, 0))
         c_min = math.sqrt(flex.min_default(c_sq, 0))
         return c_min, c_max, c_ave
コード例 #16
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def isotropic_adp_deviation(self):
   if (self.n_isotropic_adp_proxies is not None):
     isotropic_adp_deltas_rms = adp_restraints.isotropic_adp_deltas_rms(
       u_cart=self.u_cart,
       proxies=self.isotropic_adp_proxies)
     i_sq = isotropic_adp_deltas_rms * isotropic_adp_deltas_rms
     i_ave = math.sqrt(flex.mean_default(i_sq, 0))
     i_max = math.sqrt(flex.max_default(i_sq, 0))
     i_min = math.sqrt(flex.min_default(i_sq, 0))
     return i_min, i_max, i_ave
コード例 #17
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def dihedral_deviations(self):
     # !!!XXX!!! Warning! this works wrong because it is not aware of origin_id!
     if (self.n_dihedral_proxies is not None):
         dihedral_deltas = geometry_restraints.dihedral_deltas(
             sites_cart=self.sites_cart, proxies=self.dihedral_proxies)
         d_sq = dihedral_deltas * dihedral_deltas
         d_ave = math.sqrt(flex.mean_default(d_sq, 0))
         d_max = math.sqrt(flex.max_default(d_sq, 0))
         d_min = math.sqrt(flex.min_default(d_sq, 0))
         return d_min, d_max, d_ave
コード例 #18
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def chirality_deviations(self):
   if(self.n_chirality_proxies is not None):
     chirality_deltas = geometry_restraints.chirality_deltas(
       sites_cart = self.sites_cart,
       proxies    = self.chirality_proxies)
     c_sq  = chirality_deltas * chirality_deltas
     c_ave = math.sqrt(flex.mean_default(c_sq, 0))
     c_max = math.sqrt(flex.max_default(c_sq, 0))
     c_min = math.sqrt(flex.min_default(c_sq, 0))
     return c_min, c_max, c_ave
コード例 #19
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def parallelity_deviations(self):
   if self.n_parallelity_proxies is not None:
     parallelity_deltas = geometry_restraints.parallelity_deltas(
       sites_cart = self.sites_cart,
       proxies    = self.parallelity_proxies)
     p_sq  = parallelity_deltas * parallelity_deltas
     p_ave = math.sqrt(flex.mean_default(p_sq, 0))
     p_max = math.sqrt(flex.max_default(p_sq, 0))
     p_min = math.sqrt(flex.min_default(p_sq, 0))
     return p_min, p_max, p_ave
コード例 #20
0
 def is_water_last(self):
     result = True
     sol_sel = self.model.solvent_selection()
     i_sol_sel = sol_sel.iselection()
     i_mac_sel = (~sol_sel).iselection()
     if (i_sol_sel.size() > 0 and i_mac_sel.size() > 0):
         if (flex.min_default(i_sol_sel, 0) -
                 flex.max_default(i_mac_sel, 0) != 1):
             result = False
     return result
コード例 #21
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def planarity_deviations(self):
     # XXX Need update, does not respect origin_id
     # assert 0, "Not counting for origin_id"
     if (self.n_planarity_proxies is not None):
         planarity_deltas = geometry_restraints.planarity_deltas_rms(
             sites_cart=self.sites_cart, proxies=self.planarity_proxies)
         p_sq = planarity_deltas * planarity_deltas
         p_ave = math.sqrt(flex.mean_default(p_sq, 0))
         p_max = math.sqrt(flex.max_default(p_sq, 0))
         p_min = math.sqrt(flex.min_default(p_sq, 0))
         return p_min, p_max, p_ave
コード例 #22
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def reference_dihedral_deviations(self):
     assert 0, "Not working"
     if (self.n_reference_dihedral_proxies is not None):
         reference_dihedral_deltas = geometry_restraints.reference_dihedral_deltas(
             sites_cart=self.sites_cart,
             proxies=self.reference_dihedral_proxies)
         d_sq = reference_dihedral_deltas * reference_dihedral_deltas
         d_ave = math.sqrt(flex.mean_default(d_sq, 0))
         d_max = math.sqrt(flex.max_default(d_sq, 0))
         d_min = math.sqrt(flex.min_default(d_sq, 0))
         return d_min, d_max, d_ave
コード例 #23
0
ファイル: energies.py プロジェクト: xue-smile/cctbx_project
 def dihedral_deviations(self):
     if (self.n_dihedral_proxies is not None):
         covalent_dihedrals = self.dihedral_proxies.proxy_select(
             origin_id=0)
         dihedral_deltas = geometry_restraints.dihedral_deltas(
             sites_cart=self.sites_cart, proxies=covalent_dihedrals)
         d_sq = dihedral_deltas * dihedral_deltas
         d_ave = math.sqrt(flex.mean_default(d_sq, 0))
         d_max = math.sqrt(flex.max_default(d_sq, 0))
         d_min = math.sqrt(flex.min_default(d_sq, 0))
         return d_min, d_max, d_ave
コード例 #24
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def rigid_bond_deviation(self):
   if (self.n_rigid_bond_proxies is not None):
     rigid_bond_deltas = adp_restraints.rigid_bond_deltas(
       sites_cart=self.sites_cart,
       u_cart=self.u_cart,
       proxies=self.rigid_bond_proxies)
     r_sq = rigid_bond_deltas * rigid_bond_deltas
     r_ave = math.sqrt(flex.mean_default(r_sq, 0))
     r_max = math.sqrt(flex.max_default(r_sq, 0))
     r_min = math.sqrt(flex.min_default(r_sq, 0))
     return r_min, r_max, r_ave
コード例 #25
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def rigid_bond_deviation(self):
     if (self.n_rigid_bond_proxies is not None):
         rigid_bond_deltas = adp_restraints.rigid_bond_deltas(
             sites_cart=self.sites_cart,
             u_cart=self.u_cart,
             proxies=self.rigid_bond_proxies)
         r_sq = rigid_bond_deltas * rigid_bond_deltas
         r_ave = math.sqrt(flex.mean_default(r_sq, 0))
         r_max = math.sqrt(flex.max_default(r_sq, 0))
         r_min = math.sqrt(flex.min_default(r_sq, 0))
         return r_min, r_max, r_ave
コード例 #26
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def dihedral_deviations(self):
   # !!!XXX!!! Warnign! this works wrong because it is not aware of origin_id!
   if(self.n_dihedral_proxies is not None):
     dihedral_deltas = geometry_restraints.dihedral_deltas(
       sites_cart = self.sites_cart,
       proxies    = self.dihedral_proxies)
     d_sq  = dihedral_deltas * dihedral_deltas
     d_ave = math.sqrt(flex.mean_default(d_sq, 0))
     d_max = math.sqrt(flex.max_default(d_sq, 0))
     d_min = math.sqrt(flex.min_default(d_sq, 0))
     return d_min, d_max, d_ave
コード例 #27
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def reference_dihedral_deviations(self):
   assert 0, "Not working"
   if(self.n_reference_dihedral_proxies is not None):
     reference_dihedral_deltas = geometry_restraints.reference_dihedral_deltas(
       sites_cart = self.sites_cart,
       proxies    = self.reference_dihedral_proxies)
     d_sq  = reference_dihedral_deltas * reference_dihedral_deltas
     d_ave = math.sqrt(flex.mean_default(d_sq, 0))
     d_max = math.sqrt(flex.max_default(d_sq, 0))
     d_min = math.sqrt(flex.min_default(d_sq, 0))
     return d_min, d_max, d_ave
コード例 #28
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def angle_deviations(self):
   if(self.n_angle_proxies is not None):
     angle_deltas = self.angle_proxies.proxy_select(origin_id=0).deltas(
         sites_cart=self.sites_cart)
     if len(angle_deltas) > 0:
       a_sq  = angle_deltas * angle_deltas
       a_ave = math.sqrt(flex.mean_default(a_sq, 0))
       a_max = math.sqrt(flex.max_default(a_sq, 0))
       a_min = math.sqrt(flex.min_default(a_sq, 0))
       return a_min, a_max, a_ave
     else:
       return 0,0,0
コード例 #29
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def bond_deviations(self):
   if(self.n_bond_proxies is not None):
     bond_deltas = self.bond_proxies.deltas(
         sites_cart=self.sites_cart, origin_id=0)
     if len(bond_deltas) >0:
       b_sq  = bond_deltas * bond_deltas
       b_ave = math.sqrt(flex.mean_default(b_sq, 0))
       b_max = math.sqrt(flex.max_default(b_sq, 0))
       b_min = math.sqrt(flex.min_default(b_sq, 0))
       return b_min, b_max, b_ave
     else:
       return 0,0,0
コード例 #30
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def adp_similarity_deviation(self):
     if (self.n_adp_similarity_proxies is not None):
         adp_similarity_deltas_rms = adp_restraints.adp_similarity_deltas_rms(
             u_cart=self.u_cart,
             u_iso=self.u_iso,
             use_u_aniso=self.use_u_aniso,
             proxies=self.adp_similarity_proxies)
         a_sq = adp_similarity_deltas_rms * adp_similarity_deltas_rms
         a_ave = math.sqrt(flex.mean_default(a_sq, 0))
         a_max = math.sqrt(flex.max_default(a_sq, 0))
         a_min = math.sqrt(flex.min_default(a_sq, 0))
         return a_min, a_max, a_ave
コード例 #31
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def bond_deviations(self):
     if (self.n_bond_proxies is not None):
         bond_deltas = self.bond_proxies.deltas(sites_cart=self.sites_cart,
                                                origin_id=0)
         if len(bond_deltas) > 0:
             b_sq = bond_deltas * bond_deltas
             b_ave = math.sqrt(flex.mean_default(b_sq, 0))
             b_max = math.sqrt(flex.max_default(b_sq, 0))
             b_min = math.sqrt(flex.min_default(b_sq, 0))
             return b_min, b_max, b_ave
         else:
             return 0, 0, 0
コード例 #32
0
ファイル: energies.py プロジェクト: hainm/cctbx_project
 def angle_deviations(self):
     if (self.n_angle_proxies is not None):
         angle_deltas = self.angle_proxies.proxy_select(origin_id=0).deltas(
             sites_cart=self.sites_cart)
         if len(angle_deltas) > 0:
             a_sq = angle_deltas * angle_deltas
             a_ave = math.sqrt(flex.mean_default(a_sq, 0))
             a_max = math.sqrt(flex.max_default(a_sq, 0))
             a_min = math.sqrt(flex.min_default(a_sq, 0))
             return a_min, a_max, a_ave
         else:
             return 0, 0, 0
コード例 #33
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def adp_similarity_deviation(self):
   if (self.n_adp_similarity_proxies is not None):
     adp_similarity_deltas_rms = adp_restraints.adp_similarity_deltas_rms(
       u_cart=self.u_cart,
       u_iso=self.u_iso,
       use_u_aniso=self.use_u_aniso,
       proxies=self.adp_similarity_proxies)
     a_sq = adp_similarity_deltas_rms * adp_similarity_deltas_rms
     a_ave = math.sqrt(flex.mean_default(a_sq, 0))
     a_max = math.sqrt(flex.max_default(a_sq, 0))
     a_min = math.sqrt(flex.min_default(a_sq, 0))
     return a_min, a_max, a_ave
コード例 #34
0
ファイル: energies.py プロジェクト: cctbx/cctbx-playground
 def planarity_deviations(self):
   # XXX Need update, does not respect origin_id
   # assert 0, "Not counting for origin_id"
   if(self.n_planarity_proxies is not None):
     planarity_deltas = geometry_restraints.planarity_deltas_rms(
       sites_cart = self.sites_cart,
       proxies    = self.planarity_proxies)
     p_sq  = planarity_deltas * planarity_deltas
     p_ave = math.sqrt(flex.mean_default(p_sq, 0))
     p_max = math.sqrt(flex.max_default(p_sq, 0))
     p_min = math.sqrt(flex.min_default(p_sq, 0))
     return p_min, p_max, p_ave
コード例 #35
0
ファイル: energies.py プロジェクト: yayahjb/cctbx_project
 def bond_deviations_weighted(self):
   if(self.n_bond_proxies is not None):
     bond_deltas = self.bond_proxies.deltas(
         sites_cart=self.sites_cart, origin_id=0)
     if len(bond_deltas) >0:
       sigmas = flex.double([geometry_restraints.weight_as_sigma(x.weight) for x in self.bond_proxies.simple])
       sigma_mean = flex.mean_default(sigmas, 0)
       z_scores = flex.double([(bond_delta/sigma*sigma_mean) for bond_delta,sigma in zip(bond_deltas,sigmas)])
       b_rmsz = math.sqrt(flex.mean_default(z_scores*z_scores,0))
       b_z_max = flex.max_default(flex.abs(z_scores), 0)
       b_z_min = flex.min_default(flex.abs(z_scores), 0)
       return b_z_min, b_z_max, b_rmsz
     else:
       return 0,0,0
コード例 #36
0
ファイル: energies.py プロジェクト: yayahjb/cctbx_project
 def angle_deviations_weighted(self):
   if(self.n_angle_proxies is not None):
     angle_deltas = self.angle_proxies.proxy_select(origin_id=0).deltas(
         sites_cart=self.sites_cart)
     if len(angle_deltas) > 0:
       sigmas = flex.double([geometry_restraints.weight_as_sigma(x.weight) for x in self.angle_proxies])
       sigma_mean = flex.mean_default(sigmas, 0)
       z_scores = flex.double([(angle_delta/sigma*sigma_mean) for angle_delta,sigma in zip(angle_deltas,sigmas)])
       a_rmsz = math.sqrt(flex.mean_default(z_scores*z_scores,0))
       a_z_max = flex.max_default(flex.abs(z_scores), 0)
       a_z_min = flex.min_default(flex.abs(z_scores), 0)
       return a_z_min, a_z_max, a_rmsz
     else:
       return 0,0,0
コード例 #37
0
ファイル: __init__.py プロジェクト: keitaroyam/cctbx_fork
def peak_volume_estimate(map_data, sites_cart, crystal_symmetry, cutoff,
      atom_radius=1.5):
  v = flex.double()
  sites_frac = crystal_symmetry.unit_cell().fractionalize(sites_cart)
  for sc, sf in zip(sites_cart, sites_frac):
    if(map_data.value_at_closest_grid_point(sf)>=cutoff):
      sel = grid_indices_around_sites(
        unit_cell  = crystal_symmetry.unit_cell(),
        fft_n_real = map_data.focus(),
        fft_m_real = map_data.all(),
        sites_cart = flex.vec3_double([sc]),
        site_radii = flex.double([atom_radius]*1))
      v.append((map_data.select(sel)>=cutoff).count(True))
  r = flex.min_default(v, None)
  if(r==0): return None
  return r
コード例 #38
0
def peak_volume_estimate(map_data,
                         sites_cart,
                         crystal_symmetry,
                         cutoff,
                         atom_radius=1.5):
    v = flex.double()
    sites_frac = crystal_symmetry.unit_cell().fractionalize(sites_cart)
    for sc, sf in zip(sites_cart, sites_frac):
        if (map_data.value_at_closest_grid_point(sf) >= cutoff):
            sel = grid_indices_around_sites(
                unit_cell=crystal_symmetry.unit_cell(),
                fft_n_real=map_data.focus(),
                fft_m_real=map_data.all(),
                sites_cart=flex.vec3_double([sc]),
                site_radii=flex.double([atom_radius] * 1))
            v.append((map_data.select(sel) >= cutoff).count(True))
    r = flex.min_default(v, None)
    if (r == 0): return None
    return r
コード例 #39
0
 def mmmd(self, values, eps = None):
   if(eps is not None): values = values * eps
   return flex.min_default(values, None), \
          flex.max_default(values, None), \
          flex.mean_default(values, None)
コード例 #40
0
 def __init__(self,
       si_structure,
       distance_cutoff,
       nonbonded_distance_cutoff=None,
       nonbonded_buffer=1,
       nonbonded_repulsion_function_type="gaussian",
       nonbonded_max_residual_bond_stretch_factor=1.0,
       n_trials=1,
       n_macro_cycles=2,
       max_exceptions_handled=10,
       connectivities=None,
       out=None,
       dev=False):
   assert nonbonded_repulsion_function_type in ["gaussian", "cos", "prolsq"]
   assert n_trials > 0
   assert n_macro_cycles > 0
   assert max_exceptions_handled >= 0
   if (out is None): out = sys.stdout
   si_structure.show_summary(f=out).show_scatterers(f=out)
   print >> out
   out.flush()
   def get_si_si_sym_table():
     si_asu_mappings = si_structure.asu_mappings(
       buffer_thickness=distance_cutoff)
     asu_table = crystal.pair_asu_table(asu_mappings=si_asu_mappings)
     asu_table.add_all_pairs(distance_cutoff=distance_cutoff)
     si_si_sym_table = asu_table.extract_pair_sym_table()
     si_pair_counts = si_structure.pair_sym_table_show_distances(
       pair_sym_table=si_si_sym_table,
       out=out)
     if (connectivities is not None):
       assert list(si_pair_counts) == connectivities
     print >> out
     return si_si_sym_table, si_pair_counts
   si_si_sym_table, si_pair_counts = get_si_si_sym_table()
   out.flush()
   si_o = add_oxygen(
     si_structure=si_structure,
     si_si_sym_table=si_si_sym_table)
   si_o.structure.show_summary(f=out).show_scatterers(f=out)
   si_o_sst = si_o.structure.site_symmetry_table()
   print >> out
   out.flush()
   si_o_pair_counts = si_o.structure.pair_sym_table_show_distances(
     pair_sym_table=si_o.bond_sym_table,
     out=out)
   n_si = si_pair_counts.size()
   n_si_o = si_o_pair_counts.size()
   assert si_o_pair_counts[:n_si].all_eq(si_pair_counts)
   assert si_o_pair_counts[n_si:].count(2) == n_si_o-n_si
   print >> out
   out.flush()
   o_si_o_sym_table = make_o_si_o_sym_table(
     si_o_structure=si_o.structure,
     si_o_bond_sym_table=si_o.bond_sym_table)
   o_si_o_pair_counts = si_o.structure.pair_sym_table_show_distances(
     pair_sym_table=o_si_o_sym_table,
     out=out)
   assert o_si_o_pair_counts[:n_si].all_eq(0)
   if (si_pair_counts.count(4) == n_si):
     assert o_si_o_pair_counts[n_si:].all_eq(6)
   print >> out
   out.flush()
   shell_sym_tables = crystal.coordination_sequences.shell_sym_tables(
     full_pair_sym_table=si_o.bond_sym_table.full_connectivity(
       site_symmetry_table=si_o_sst),
     site_symmetry_table=si_o_sst,
     max_shell=3)
   if (1):
     shell_sym_tables[0].add_pair_sym_table_in_place(other=si_si_sym_table)
   if (1):
     shell_sym_tables[0].add_pair_sym_table_in_place(other=o_si_o_sym_table)
   shell_sym_tables = [_.tidy(site_symmetry_table=si_o_sst)
     for _ in shell_sym_tables]
   bond_params_table = setup_bond_params_table(
     structure=si_o.structure,
     bond_sym_table=shell_sym_tables[0])
   nonbonded_params = setup_nonbonded_params()
   nonbonded_types = flex.std_string()
   for scatterer in si_o.structure.scatterers():
     nonbonded_types.append(scatterer.scattering_type)
   if (nonbonded_repulsion_function_type == "gaussian"):
     nonbonded_function = geometry_restraints.gaussian_repulsion_function(
       max_residual=bond_params_table.mean_residual(
         bond_stretch_factor=nonbonded_max_residual_bond_stretch_factor))
     if (nonbonded_distance_cutoff is None):
       nonbonded_distance_cutoff = 7
   elif (nonbonded_repulsion_function_type == "cos"):
     nonbonded_function = geometry_restraints.cos_repulsion_function(
       max_residual=bond_params_table.mean_residual(
         bond_stretch_factor=nonbonded_max_residual_bond_stretch_factor))
   else:
     nonbonded_function = geometry_restraints.prolsq_repulsion_function()
   geometry_restraints_manager = geometry_restraints.manager.manager(
     crystal_symmetry=si_o.structure,
     site_symmetry_table=si_o_sst,
     bond_params_table=bond_params_table,
     shell_sym_tables=shell_sym_tables,
     nonbonded_params=nonbonded_params,
     nonbonded_types=nonbonded_types,
     nonbonded_function=nonbonded_function,
     nonbonded_distance_cutoff=nonbonded_distance_cutoff,
     nonbonded_buffer=nonbonded_buffer,
     max_reasonable_bond_distance=100)
   minimized = None
   for i_trial in xrange(n_trials):
     for i_exceptions_handled in xrange(max_exceptions_handled+1):
       trial_structure = si_o.structure.deep_copy_scatterers()
       if (i_trial > 0):
         n_scatterers = trial_structure.scatterers().size()
         trial_structure.set_sites_cart(flex.vec3_double(flex.random_double(
           size=n_scatterers*3)*10-5))
         trial_structure.apply_symmetry_sites()
       trial_minimized = []
       trial_sites_cart = None
       for i_macro_cycle in xrange(n_macro_cycles):
         if (trial_sites_cart is not None):
           trial_structure.set_sites_cart(sites_cart=trial_sites_cart)
           trial_structure = trial_structure.random_shift_sites(
             max_shift_cart=0.2)
           trial_structure.apply_symmetry_sites()
         trial_sites_cart = trial_structure.sites_cart()
         geometry_restraints_flags = geometry_restraints.flags.flags(
           bond=True,
           nonbonded=((i_macro_cycle % 2) != (n_macro_cycles % 2)))
         if (not dev):
           try:
             m = geometry_restraints.lbfgs.lbfgs(
               sites_cart=trial_sites_cart,
               correct_special_position_tolerance=1.0,
               geometry_restraints_manager=geometry_restraints_manager,
               geometry_restraints_flags=geometry_restraints_flags,
               lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
                 max_iterations=100),
               lbfgs_exception_handling_params=
                 scitbx.lbfgs.exception_handling_parameters(
                   ignore_line_search_failed_step_at_lower_bound=True))
           except RuntimeError, lbfgs_error:
             if (i_trial == 0): raise
             if (not str(lbfgs_error).startswith(
                   "Bond distance > max_reasonable_bond_distance: ")): raise
             m = None
             break
           else:
             trial_minimized.append(m)
             trial_structure.set_sites_cart(sites_cart=trial_sites_cart)
         else:
           m = dev_lbfgs(
             sites_cart=trial_sites_cart,
             geometry_restraints_manager=geometry_restraints_manager,
             geometry_restraints_flags=geometry_restraints_flags,
             lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
               max_iterations=100),
             lbfgs_exception_handling_params=
               scitbx.lbfgs.exception_handling_parameters(
                 ignore_line_search_failed_step_at_lower_bound=True))
           trial_minimized.append(m)
           trial_structure.set_sites_cart(sites_cart=trial_sites_cart)
       if (m is not None):
         break
     else:
       raise RuntimeError(
         "max_exceptions_handled=%d exceeded: %s" % (
           max_exceptions_handled, str(lbfgs_error)))
     ftr = trial_minimized[-1].final_target_result
     pair_proxies = geometry_restraints_manager.pair_proxies(
       sites_cart=trial_sites_cart)
     min_nonbonded_distance = flex.min_default(
       pair_proxies.nonbonded_proxies.deltas(sites_cart=trial_sites_cart),
       None)
     print >> out, \
       "i_trial, bond, nonbonded, min distance: %d, %.6g, %.6g, %s" % (
         i_trial,
         ftr.bond_residual_sum,
         ftr.nonbonded_residual_sum,
         format_value(format="%.4g", value=min_nonbonded_distance))
     out.flush()
     if (minimized is None or       minimized[-1].final_target_result.target
                            > trial_minimized[-1].final_target_result.target):
       minimized = trial_minimized
       minimized_structure = trial_structure
       best_i_trial = i_trial
コード例 #41
0
 def collect(self,
             model,
             fmodel,
             step,
             wilson_b=None,
             rigid_body_shift_accumulator=None):
     global time_collect_and_process
     t1 = time.time()
     if (self.sites_cart_start is None):
         self.sites_cart_start = model.xray_structure.sites_cart()
     sites_cart_curr = model.xray_structure.sites_cart()
     if (sites_cart_curr.size() == self.sites_cart_start.size()):
         self.shifts.append(
             flex.mean(
                 flex.sqrt(
                     (self.sites_cart_start - sites_cart_curr).dot())))
     else:
         self.shifts.append("n/a")
     if (wilson_b is not None): self.wilson_b = wilson_b
     self.steps.append(step)
     self.r_works.append(fmodel.r_work())
     self.r_frees.append(fmodel.r_free())
     use_amber = False
     if hasattr(self.params, "amber"):  # loaded amber scope
         use_amber = self.params.amber.use_amber
         self.is_amber_monitor = use_amber
     ignore_hd = True
     if self.neutron_refinement or use_amber:
         ignore_hd = False
     use_afitt = False
     if hasattr(self.params, "afitt"):  # loaded amber scope
         use_afitt = self.params.afitt.use_afitt
     general_selection = None
     if use_afitt:
         from mmtbx.geometry_restraints import afitt
         if 0:
             general_selection = afitt.get_afitt_selection(
                 model.restraints_manager, model.xray_structure, ignore_hd)
             afitt_geom = model.geometry_statistics(
                 ignore_hd=ignore_hd,
                 cdl_restraints=self.params.pdb_interpretation.
                 restraints_library.cdl,
                 general_selection=general_selection,
             )
             afitt_geom.show()
         general_selection = afitt.get_non_afitt_selection(
             model.restraints_manager, model.xray_structure.sites_cart(),
             model.xray_structure.hd_selection(), ignore_hd)
     geom = model.geometry_statistics(
         ignore_hd=ignore_hd,
         cdl_restraints=self.params.pdb_interpretation.restraints_library.
         cdl,
         general_selection=general_selection,
     )
     if (geom is not None): self.geom.append(geom)
     hd_sel = None
     if (not self.neutron_refinement and not self.is_neutron_monitor):
         hd_sel = model.xray_structure.hd_selection()
     b_isos = model.xray_structure.extract_u_iso_or_u_equiv(
     ) * math.pi**2 * 8
     if (hd_sel is not None): b_isos = b_isos.select(~hd_sel)
     self.bs_iso_max_a.append(flex.max_default(b_isos, 0))
     self.bs_iso_min_a.append(flex.min_default(b_isos, 0))
     self.bs_iso_ave_a.append(flex.mean_default(b_isos, 0))
     self.n_solv.append(model.number_of_ordered_solvent_molecules())
     if (len(self.geom) > 0 and getattr(self.geom[0], "b", None)
             and getattr(self.geom[0], "a", None)):
         if ([self.bond_start, self.angle_start].count(None) == 2):
             if (len(self.geom) > 0):
                 self.bond_start = self.geom[0].b[2]
                 self.angle_start = self.geom[0].a[2]
         if (len(self.geom) > 0):
             self.bond_final = self.geom[len(self.geom) - 1].b[2]
             self.angle_final = self.geom[len(self.geom) - 1].a[2]
         elif (len(self.geom) == 1):
             self.bond_final = self.geom[0].b[2]
             self.angle_final = self.geom[0].a[2]
     if (rigid_body_shift_accumulator is not None):
         self.rigid_body_shift_accumulator = rigid_body_shift_accumulator
     t2 = time.time()
     time_collect_and_process += (t2 - t1)
     self.call_back(model, fmodel, method=step)
コード例 #42
0
 def mmmd(self, values, eps = None):
   if(eps is not None): values = values * eps
   return flex.min_default(values, None), \
          flex.max_default(values, None), \
          flex.mean_default(values, None)
コード例 #43
0
 def collect(self, model,
                   fmodel,
                   step,
                   wilson_b = None,
                   rigid_body_shift_accumulator = None):
   global time_collect_and_process
   t1 = time.time()
   if(self.sites_cart_start is None):
     self.sites_cart_start = model.xray_structure.sites_cart()
   sites_cart_curr = model.xray_structure.sites_cart()
   if(sites_cart_curr.size()==self.sites_cart_start.size()):
     self.shifts.append(
       flex.mean(flex.sqrt((self.sites_cart_start-sites_cart_curr).dot())))
   else: self.shifts.append("n/a")
   if(wilson_b is not None): self.wilson_b = wilson_b
   self.steps.append(step)
   self.r_works.append(fmodel.r_work())
   self.r_frees.append(fmodel.r_free())
   use_amber = False
   if hasattr(self.params, "amber"): # loaded amber scope
     use_amber = self.params.amber.use_amber
     self.is_amber_monitor=use_amber
   ignore_hd = True
   if self.neutron_refinement or use_amber:
     ignore_hd = False
   use_afitt = False
   if hasattr(self.params, "afitt"): # loaded amber scope
     use_afitt = self.params.afitt.use_afitt
   general_selection = None
   if use_afitt:
     from mmtbx.geometry_restraints import afitt
     if 0:
       general_selection = afitt.get_afitt_selection(model.restraints_manager,
                                                     model.xray_structure,
                                                     ignore_hd)
       afitt_geom = model.geometry_statistics(
         ignore_hd = ignore_hd,
         cdl_restraints=self.params.pdb_interpretation.restraints_library.cdl,
         general_selection=general_selection,
         )
       afitt_geom.show()
     general_selection = afitt.get_non_afitt_selection(
       model.restraints_manager,
       model.xray_structure.sites_cart(),
       model.xray_structure.hd_selection(),
       ignore_hd)
   geom = model.geometry_statistics(
     ignore_hd = ignore_hd,
     cdl_restraints=self.params.pdb_interpretation.restraints_library.cdl,
     general_selection=general_selection,
     )
   if(geom is not None): self.geom.append(geom)
   hd_sel = None
   if(not self.neutron_refinement and not self.is_neutron_monitor):
     hd_sel = model.xray_structure.hd_selection()
   b_isos = model.xray_structure.extract_u_iso_or_u_equiv() * math.pi**2*8
   if(hd_sel is not None): b_isos = b_isos.select(~hd_sel)
   self.bs_iso_max_a.append(flex.max_default( b_isos, 0))
   self.bs_iso_min_a.append(flex.min_default( b_isos, 0))
   self.bs_iso_ave_a.append(flex.mean_default(b_isos, 0))
   self.n_solv.append(model.number_of_ordered_solvent_molecules())
   if (len(self.geom)>0 and
       getattr(self.geom[0], "b", None) and
       getattr(self.geom[0], "a", None)
       ):
     if([self.bond_start,self.angle_start].count(None) == 2):
       if(len(self.geom)>0):
         self.bond_start  = self.geom[0].b[2]
         self.angle_start = self.geom[0].a[2]
     if(len(self.geom)>0):
       self.bond_final  = self.geom[len(self.geom)-1].b[2]
       self.angle_final = self.geom[len(self.geom)-1].a[2]
     elif(len(self.geom)==1):
       self.bond_final  = self.geom[0].b[2]
       self.angle_final = self.geom[0].a[2]
   if(rigid_body_shift_accumulator is not None):
     self.rigid_body_shift_accumulator = rigid_body_shift_accumulator
   t2 = time.time()
   time_collect_and_process += (t2 - t1)
   self.call_back(model, fmodel, method=step)