def __init__(
       self,
       map_data,
       xray_structure,
       ncs_restraints_group_list,
       real_space_gradients_delta,
       refine_selection=None,
       use_ncs_constraints=True,
       restraints_manager=None,
       data_weight=None,
       refine_sites=False,
       refine_transformations=False):
   adopt_init_args(self, locals())
   self.refine_selection = nu.get_refine_selection(
     refine_selection=self.refine_selection,
     number_of_atoms=self.xray_structure.sites_cart().size())
   self.extended_ncs_selection = nu.get_extended_ncs_selection(
     ncs_restraints_group_list=ncs_restraints_group_list,
     refine_selection=self.refine_selection)
   self.unit_cell = self.xray_structure.unit_cell()
   # get selection to refine
   asu_size = xray_structure.scatterers().size()
   if refine_sites:
     # Use all atoms to refine
     self.selection = flex.bool(asu_size, refine_selection)
   elif refine_transformations:
     # use only NCS related atoms (Without the Master NCS copy)
     self.selection = nu.get_ncs_related_selection(
       ncs_restraints_group_list=ncs_restraints_group_list,
       asu_size=asu_size)
 def __init__(self, individual_sites       = False,
                    torsion_angles         = False,
                    rigid_body             = False,
                    individual_adp         = False,
                    group_adp              = False,
                    tls                    = False,
                    occupancies            = False,
                    group_anomalous        = False,
                    sites_individual       = None,
                    sites_torsion_angles   = None,
                    sites_rigid_body       = None,
                    adp_individual_iso     = None,
                    adp_individual_aniso   = None,
                    adp_group              = None,
                    group_h                = None,
                    adp_tls                = None,
                    s_occupancies          = None):
                    # XXX group_anomalous should be here
   adopt_init_args(self, locals())
   self.sites_individual       = self._deep_copy(self.sites_individual)
   self.sites_torsion_angles   = self._deep_copy(self.sites_torsion_angles)
   self.sites_rigid_body       = self._deep_copy(self.sites_rigid_body)
   self.adp_individual_iso     = self._deep_copy(self.adp_individual_iso)
   self.adp_individual_aniso   = self._deep_copy(self.adp_individual_aniso)
   self.adp_group              = self._deep_copy(self.adp_group)
   self.group_h                = self._deep_copy(self.group_h)
   self.adp_tls                = self._deep_copy(self.adp_tls)
   self.s_occupancies          = self._deep_copy(self.s_occupancies)
   self.check_all()
 def __init__(self, miller_array,
                    xray_structure = None,
                    miller_array_twin = None,
                    mask_params = None,
                    compute_mask = True):
   adopt_init_args(self, locals())
   if(self.mask_params is not None): self.mask_params = mask_params
   else: self.mask_params = mask_master_params.extract()
   self.grid_step = self._get_grid_step()
   self.atom_radii = None
   self._f_mask = None
   self._f_mask_twin = None
   self.solvent_content_via_mask = None
   self.layer_volume_fractions = None
   self.sites_cart = None
   if(xray_structure is not None):
     self.atom_radii = vdw_radii_from_xray_structure(xray_structure =
      self.xray_structure)
     self.xray_structure = self.xray_structure.deep_copy_scatterers()
     self.sites_cart = self.xray_structure.sites_cart()
     twin=False
     if(self.miller_array_twin is not None): twin=True
     if(compute_mask): self.compute_f_mask()
   if( not (self._f_mask is None) ):
     assert self._f_mask[0].data().size() == self.miller_array.indices().size()
Example #4
0
  def __init__(self, f_obs, ncs_pairs, reflections_per_bin):
    adopt_init_args(self, locals())
    # Create bins
    f_obs.setup_binner(reflections_per_bin = reflections_per_bin)
    self.binner = f_obs.binner()
    n_bins = self.binner.n_bins_used()
    self.n_bins = n_bins
    self.SigmaN = None
    self.update_SigmaN()
    #
    self.rbin = flex.int(f_obs.data().size(), -1)
    for i_bin in self.binner.range_used():
      for i_seq in self.binner.array_indices(i_bin):
        self.rbin[i_seq] = i_bin-1 # i_bin starts with 1, not 0 !
    assert flex.min(self.rbin)==0
    assert flex.max(self.rbin)==n_bins-1
    # Extract symmetry matrices
    self.sym_matrices = []
    for m_as_string in f_obs.space_group().smx():
      o = sgtbx.rt_mx(symbol=str(m_as_string), t_den=f_obs.space_group().t_den())
      m_as_double = o.r().as_double()
      self.sym_matrices.append(m_as_double)
    self.gradient_evaluator = None
    self.target_and_grads = ext.tncs_eps_factor_refinery(
        tncs_pairs               = self.ncs_pairs,
        f_obs                    = self.f_obs.data(),
        sigma_f_obs              = self.f_obs.sigmas(),
        rbin                     = self.rbin,
        SigmaN                   = self.SigmaN,
        space_group              = self.f_obs.space_group(),
        miller_indices           = self.f_obs.indices(),
        fractionalization_matrix = self.f_obs.unit_cell().fractionalization_matrix(),
        sym_matrices             = self.sym_matrices)

    self.update()
Example #5
0
 def __init__(self,
              target_map,
              residue,
              mon_lib_srv,
              rotamer_manager,
              unit_cell,
              torsion_search_start = -20,
              torsion_search_stop  = 20,
              torsion_search_step  = 2):
   adopt_init_args(self, locals())
   self.clusters = None
   self.axes_and_atoms_aa_specific = None
   self.clusters = mmtbx.refinement.real_space.aa_residue_axes_and_clusters(
     residue         = self.residue,
     mon_lib_srv     = self.mon_lib_srv,
     backbone_sample = False).clusters
   score_residue = mmtbx.refinement.real_space.score3(
     unit_cell    = self.unit_cell,
     target_map   = self.target_map,
     residue      = self.residue,
     rotamer_eval = self.rotamer_manager)
   mmtbx.refinement.real_space.torsion_search(
     clusters   = self.clusters,
     sites_cart = self.residue.atoms().extract_xyz(),
     scorer     = score_residue,
     start      = self.torsion_search_start,
     stop       = self.torsion_search_stop,
     step       = self.torsion_search_step)
   self.residue.atoms().set_xyz(new_xyz=score_residue.sites_cart)
Example #6
0
 def __init__ (self, file_name, log_out,
               file_error=False,
               low_signal=False,
               wrong_bravais=False,
               wrong_cell=False,
               reason=None) :
   adopt_init_args(self, locals())
Example #7
0
 def __init__ (self, command_args, program_id, log=None,
     intercept_output=True) :
   adopt_init_args(self, locals())
   if self.log is None :
     self.log = sys.stdout
   threading.Thread.__init__(self)
   self._alive = True
Example #8
0
  def __init__(self,imgobj,phil,inputpd,verbose=False):
    adopt_init_args(self,locals())
    self.active_areas = imgobj.get_tile_manager(phil).effective_tiling_as_flex_int()
    B = self.active_areas

    #figure out which asics are on the central four sensors
    assert len(self.active_areas)%4 == 0
    # apply an additional margin of 1 pixel, since we don't seem to be
    # registering the global margin.
    asics = [(B[i]+1,B[i+1]+1,B[i+2]-1,B[i+3]-1) for i in xrange(0,len(B),4)]

    from scitbx.matrix import col
    centre_mm = col((float(inputpd["xbeam"]),float(inputpd["ybeam"])))
    centre = centre_mm / float(inputpd["pixel_size"])
    distances = flex.double()
    cenasics = flex.vec2_double()
    self.corners = []
    for iasic in xrange(len(asics)):
      cenasic = ((asics[iasic][2] + asics[iasic][0])/2. ,
                 (asics[iasic][3] + asics[iasic][1])/2. )
      cenasics.append(cenasic)
      distances.append(math.hypot(cenasic[0]-centre[0], cenasic[1]-centre[1]))
    orders = flex.sort_permutation(distances)

    self.flags = flex.int(len(asics),0)
    #Use the central 8 asics (central 4 sensors)
    self.green = []
    for i in xrange(32):
      #self.green.append( cenasics[orders[i]] )
      self.corners.append (asics[orders[i]])
      #self.green.append((self.corners[-1][0],self.corners[-1][1]))
      self.flags[orders[i]]=1
    self.asic_filter = "distl.tile_flags="+",".join(["%1d"%b for b in self.flags])
Example #9
0
 def __init__(
       self,
       map_data,
       pdb_hierarchy,  # XXX redundant inputs
       xray_structure, # XXX redundant inputs
       d_min,
       use_mask=False,
       masking_atom_radius=5,
       max_iterations=50,
       macro_cycles=1,
       prefix="",
       log=None):
   adopt_init_args(self, locals())
   self.cc_best = None
   self.sites_cart_best = None
   if(self.log is None): self.log = sys.stdout
   self.sites_cart_start = self.xray_structure.sites_cart()
   assert approx_equal(self.pdb_hierarchy.atoms().extract_xyz(),
     self.sites_cart_start, 1.e-3)
   self.crystal_gridding = maptbx.crystal_gridding(
     unit_cell             = self.xray_structure.unit_cell(),
     space_group_info      = self.xray_structure.space_group_info(),
     pre_determined_n_real = self.map_data.all())
   self.complete_set = miller.build_set(
     crystal_symmetry = self.xray_structure.crystal_symmetry(),
     anomalous_flag   = False,
     d_min            = self.d_min)
   self._show_and_track()
   self.d_mins = self._get_mz_resolution_limits()
   for macro_cycle in xrange(self.macro_cycles):
     self._refine()
   self.xray_structure.set_sites_cart(self.sites_cart_best)
   self.pdb_hierarchy.adopt_xray_structure(self.xray_structure)
Example #10
0
 def __init__(self,
              pdb_hierarchy,
              rotamer_manager,
              target_map,
              unit_cell,
              mon_lib_srv,
              log = None):
   adopt_init_args(self, locals())
   if(self.log is None): self.log = sys.stdout
   get_class = iotbx.pdb.common_residue_names_get_class
   for model in self.pdb_hierarchy.models():
     for chain in model.chains():
       for residue_group in chain.residue_groups():
         conformers = residue_group.conformers()
         if(len(conformers)>1): continue
         for conformer in residue_group.conformers():
           residue = conformer.only_residue()
           id_str="%s%s%s"%(chain.id,residue.resname,residue.resseq.strip())
           if(get_class(residue.resname) == "common_amino_acid"):
             re = self.rotamer_manager
             if(re.evaluate_residue(residue)=="OUTLIER"):
               mmtbx.refinement.real_space.fit_residue.tune_up(
                 residue         = residue,
                 unit_cell       = self.unit_cell,
                 target_map      = target_map,
                 mon_lib_srv     = self.mon_lib_srv,
                 rotamer_manager = self.rotamer_manager)
Example #11
0
 def __init__(self,
              structure_monitor,
              rotamer_manager,
              sin_cos_table,
              mon_lib_srv,
              backbone_sample=True,
              log = None):
   adopt_init_args(self, locals())
   self.unit_cell = self.structure_monitor.xray_structure.unit_cell()
   if(self.log is None): self.log = sys.stdout
   assert approx_equal(
     self.structure_monitor.xray_structure.sites_cart(),
     self.structure_monitor.pdb_hierarchy.atoms().extract_xyz())
   self.special_position_indices = \
     self.structure_monitor.xray_structure.special_position_indices()
   self.atom_radius_to_negate_map_within = None
   if(self.structure_monitor.target_map_object.miller_array.d_min()>3.5):
     self.atom_radius_to_negate_map_within = 2.0
   else:
     self.atom_radius_to_negate_map_within = 1.5
   #
   self.selection_good = self.structure_monitor.map_cc_per_atom > 0.8
   self.selection_water = self.structure_monitor.pdb_hierarchy.\
     atom_selection_cache().selection(string = "water")
   self.iselection_backbone=flex.size_t()
   for r in self.structure_monitor.residue_monitors:
     if(r.selection_backbone is not None):
       self.iselection_backbone.extend(r.selection_backbone)
   self.loop_over_residues()
Example #12
0
 def __init__(self,
              uiso,
              T_initial,
              L_initial,
              S_initial,
              refine_T,
              refine_L,
              refine_S,
              origin,
              sites,
              max_iterations):
   adopt_init_args(self, locals())
   assert uiso.size() == sites.size()
   self.dim_T = len(self.T_initial)
   self.dim_L = len(self.L_initial)
   self.dim_S = len(self.S_initial)
   assert self.dim_T == 1 and self.dim_S == 3 and self.dim_L == 6
   self.T_min = self.T_initial
   self.L_min = self.L_initial
   self.S_min = self.S_initial
   self.x = self.pack(self.T_min, self.L_min, self.S_min)
   self.n = self.x.size()
   self.minimizer = lbfgs.run(
     target_evaluator = self,
     termination_params = lbfgs.termination_parameters(
       max_iterations = max_iterations,
       max_calls      = int(max_iterations*1.5)),
       exception_handling_params =
       lbfgs.exception_handling_parameters(
         ignore_line_search_failed_step_at_lower_bound = True,
         ignore_line_search_failed_step_at_upper_bound = True,
         ignore_line_search_failed_maxfev              = True)
       )
   self.compute_functional_and_gradients()
   del self.x
Example #13
0
 def __init__(self,
       bond=None,
       nonbonded=None,
       angle=None,
       dihedral=None,
       reference_coordinate=None,
       reference_dihedral=None,
       ncs_dihedral=None,
       den_restraints=None,
       chirality=None,
       planarity=None,
       parallelity=None,
       bond_similarity=None,
       ramachandran_restraints=None,
       default=False):
   if (bond is None): bond = default
   if (nonbonded is None): nonbonded = default
   if (angle is None): angle = default
   if (dihedral is None): dihedral = default
   if (reference_coordinate is None): reference_coordinate = default
   if (reference_dihedral is None): reference_dihedral = default
   if (ncs_dihedral is None): ncs_dihedral = default
   if den_restraints is None: den_restraints = default
   if (chirality is None): chirality = default
   if (planarity is None): planarity = default
   if (parallelity is None): parallelity = default
   if (bond_similarity is None): bond_similarity = default
   if ramachandran_restraints is None: ramachandran_restraints = default
   adopt_init_args(self, locals())
 def __init__(self,
              unit_cell,
              map_target,
              real_space_gradients_delta,
              sites_frac,
              map_current = None,
              geometry_restraints_manager = None,
              real_space_target_weight = None,
              restraints_target_weight = None,
              sites_cart = None,
              target_type = "diff_map"):
   adopt_init_args(self, locals())
   assert target_type in ["simple", "diff_map"]
   if(geometry_restraints_manager is not None):
     assert [real_space_target_weight, restraints_target_weight, sites_cart
            ].count(None)==0
     self.geom_tg_obj = geometry_restraints_manager.energies_sites(
       sites_cart = sites_cart, compute_gradients = True)
   if(target_type == "diff_map"):
     assert map_current is not None
     self.rsr_tg_obj = maptbx.target_and_gradients(
       unit_cell   = unit_cell,
       map_target  = map_target,
       map_current = map_current,
       step        = real_space_gradients_delta,
       sites_frac  = sites_frac)
   if(target_type == "simple"):
     assert sites_cart is not None
     self.rsr_tg_obj = real_space_refinement_simple.target_and_gradients(
       unit_cell                  = unit_cell,
       density_map                = map_target,
       sites_cart                 = sites_cart,
       real_space_gradients_delta = real_space_gradients_delta)
Example #15
0
 def __init__(self,
              fmodels,
              constrained_groups_selections,
              selections,
              par_initial,
              max_number_of_iterations):
   adopt_init_args(self, locals())
   self.fmodels.create_target_functors()
   self.fmodels.prepare_target_functors_for_minimization()
   from phenix.refinement import weight_xray_chem
   self.weights = weight_xray_chem.weights(wx       = 1,
                                           wx_scale = 1,
                                           angle_x  = None,
                                           wn       = 1,
                                           wn_scale = 1,
                                           angle_n  = None,
                                           w        = 0,
                                           wxn      = 1) # XXX
   self.par_min = self.par_initial.deep_copy()
   self.x = self.pack(self.par_min)
   self.n = self.x.size()
   self.minimizer = lbfgs.run(
   target_evaluator = self,
   termination_params = lbfgs.termination_parameters(
     max_iterations = max_number_of_iterations),
   exception_handling_params = lbfgs.exception_handling_parameters(
     ignore_line_search_failed_step_at_lower_bound = True,
     ignore_line_search_failed_step_at_upper_bound = True))
   self.compute_functional_and_gradients()
   del self.x
Example #16
0
 def __init__ (self, ncs_object, params=None, log=None, verbose=False) :
   if (params is None) :
     params = libtbx.phil.parse(ncs_averaging_params).extract()
   if (log is None) :
     log = null_out()
   adopt_init_args(self, locals())
   self.mask = None
 def __init__ (self, pdb_hierarchy, atom_selection=None, params=None,
     log=sys.stdout, proxies=None, tables=None, initialize=True):
   assert pdb_hierarchy is not None
   assert not pdb_hierarchy.atoms().extract_i_seq().all_eq(0), ""+\
       "Probably all atoms have i_seq = 0 which is wrong"
   adopt_init_args(self, locals())
   self.bool_atom_selection = None
   if self.atom_selection is None:
     self.bool_atom_selection = flex.bool(pdb_hierarchy.atoms().size(), True)
   else:
     cache = pdb_hierarchy.atom_selection_cache()
     self.bool_atom_selection = cache.selection(atom_selection)
   if params is None:
     params = master_phil.fetch().extract()
   self.params = params
   if initialize:
     if(self.params.rama_potential == "oldfield"):
       self.tables = ramachandran_plot_data(
           plot_cutoff=self.params.oldfield.plot_cutoff)
     else :
       self.tables = load_tables(params)
     # get proxies
     self.extract_proxies()
   else:
     assert proxies is not None
   if(self.params.rama_potential == "oldfield"):
     self.target_phi_psi = self.update_phi_psi_targets(
       sites_cart = self.pdb_hierarchy.atoms().extract_xyz())
Example #18
0
 def __init__(self, target_functor,
                    xray_structure,
                    reparametrisation,
                    lbfgs_termination_params=None,
                    lbfgs_core_params=None,
                    cos_sin_table=True,
                    structure_factor_algorithm=None,
                    verbose=0,
                    reference_structure=None):
   adopt_init_args(self, locals())
   self.scatterer_grad_flags_counts = xray.minimization.ext.scatterer_grad_flags_counts(
                                             self.xray_structure.scatterers())
   self.grad_flags_counts = \
     xray.minimization.ext.scatterer_grad_flags_counts(self.xray_structure.scatterers())
   self.structure_factors_from_scatterers = \
     xray.structure_factors.from_scatterers(
       miller_set=self.target_functor.f_obs(),
       cos_sin_table=cos_sin_table)
   self.structure_factor_gradients = \
     xray.structure_factors.gradients(
       miller_set=self.target_functor.f_obs(),
       cos_sin_table=cos_sin_table)
   self.x = flex.double(reparametrisation.n_independents, 0)
   xray_structure.tidy_us(u_min=1.e-6)
   self.last_shift = None
   import sys
   self.minimizer = scitbx.lbfgs.run(
     target_evaluator=self,
     termination_params=lbfgs_termination_params,
     core_params=lbfgs_core_params,
     #log=sys.stdout
   )
   self.apply_shifts()
   self.compute_target(compute_gradients=False)
   self.final_target_value = self.target_result.target()
Example #19
0
 def __init__(self,
              f_obs,
              f_calc,
              f_masks,
              ss,
              k_sols=None,
              b_sols=None,
              ps=None,
              u_star=[0,0,0,0,0,0], b_max=300, b_min=0, k_min=0.001, k_max=50):
   if(ps is not None): assert [k_sols, b_sols].count(None) == 2
   else:               assert [k_sols, b_sols].count(None) == 0
   adopt_init_args(self, locals())
   self.kbu = mmtbx.f_model.manager_kbu(
     f_obs   = self.f_obs,
     f_calc  = self.f_calc,
     f_masks = self.f_masks,
     ss      = self.ss,
     k_sols  = self.k_sols,
     b_sols  = self.b_sols,
     u_star  = self.u_star)
   self.t_g_c = None
   self.use_scale=None
   self.refine_kb=False
   self.refine_k=False
   self.refine_b=False
   self.refine_u=False
   self.refine_p=False
   self.space_group = self.f_obs.space_group()
   self.adp_constraints = self.space_group.adp_constraints()
 def __init__(
       self,
       pdb_hierarchy,
       ensemble_xrs,
       restraints_manager,
       target_bond_rmsd,
       target_angle_rmsd,
       map_data,
       weight,
       nproc):
   adopt_init_args(self, locals())
   self.crystal_symmetry = self.ensemble_xrs[0].crystal_symmetry()
   # initialize states collector
   self.states = mmtbx.utils.states(
     pdb_hierarchy  = self.pdb_hierarchy.deep_copy())
   # run minimization
   if(self.nproc>1):
     from libtbx import easy_mp
     stdout_and_results = easy_mp.pool_map(
       processes    = self.nproc,
       fixed_func   = self.run,
       args         = self.ensemble_xrs,
       func_wrapper = "buffer_stdout_stderr")
     for so, sites_cart in stdout_and_results :
       self.states.add(sites_cart = sites_cart)
   else:
     for xrs in self.ensemble_xrs:
       sites_cart = self.run(xray_structure=xrs)
       self.states.add(sites_cart = sites_cart)
Example #21
0
 def __init__(self,
              starting_frame,
              starting_angle,
              oscillation_range,
              rotation_axis,
              wavelength,
              beam_vector,
              space_group,
              unit_cell,
              unit_cell_a_axis,
              unit_cell_b_axis,
              unit_cell_c_axis,
              num_segments,
              detector_size,
              pixel_size,
              detector_origin,
              detector_distance,
              detector_x_axis,
              detector_y_axis,
              detector_normal,
              segments=None,
              orientation=None):
   adopt_init_args(self, locals())
   if [num_segments, segments, orientation].count(None) == 3:
     self.num_segments = 1
     self.segments = []
     self.orientation = []
     for i in range(self.num_segments):
       self.segments.append(
         (i+1, 1, self.detector_size[0], 1, self.detector_size[1]))
       self.orientation.append((0, 0, 0, 1, 0, 0, 0, 1, 0))
 def __init__(self, miller_set=None,
                    crystal_symmetry=None,
                    d_min=None,
                    grid_resolution_factor=1/3.,
                    symmetry_flags=maptbx.use_space_group_symmetry,
                    mandatory_grid_factors=None,
                    quality_factor=1000000, u_base=None, b_base=None,
                    wing_cutoff=1.e-10,
                    exp_table_one_over_step_size=-100,
                    max_prime=5):
   assert miller_set is None or crystal_symmetry is None
   assert [quality_factor, u_base, b_base].count(None) == 2
   if (miller_set is None):
     assert crystal_symmetry is not None and d_min is not None
   else:
     crystal_symmetry = miller_set
     if (d_min is None):
       d_min = miller_set.d_min()
     else:
       assert d_min <= miller_set.d_min()
   crystal.symmetry._copy_constructor(self, crystal_symmetry)
   quality_factor = xray.structure_factors.quality_factor_from_any(
     d_min, grid_resolution_factor, quality_factor, u_base, b_base)
   del miller_set
   del u_base
   del b_base
   adopt_init_args(self, locals(), hide=True)
   self._crystal_gridding = None
   self._crystal_gridding_tags = None
   self._rfft = None
   self._u_base = None
Example #23
0
 def __init__(self, m=5,
                    maxfev=20,
                    gtol=0.9,
                    xtol=1.e-16,
                    stpmin=1.e-20,
                    stpmax=1.e20):
   adopt_init_args(self, locals())
Example #24
0
  def __init__(self,
               target_map,
               pdb_hierarchy,
               atom_radius,
               use_adp_restraints,
               nproc,
               log=None):
    adopt_init_args(self, locals())
    self.xray_structure = self.pdb_hierarchy.extract_xray_structure(
      crystal_symmetry = self.target_map.miller_array.crystal_symmetry())
    b_isos = self.xray_structure.extract_u_iso_or_u_equiv()*adptbx.u_as_b(1.)

    self.xray_structure = self.xray_structure.set_b_iso(
      value = flex.mean(b_isos))

    #for rg in self.pdb_hierarchy.residue_groups():
    #  sel = rg.atoms().extract_i_seq()
    #  sel = flex.bool(b_isos.size(), sel)
    #  self.xray_structure = self.xray_structure.set_b_iso(
    #    value     = flex.mean(b_isos.select(sel)),
    #    selection = sel)
    self.pdb_hierarchy.adopt_xray_structure(self.xray_structure)
    self.chain_selections = []
    for chain in self.pdb_hierarchy.chains():
      self.chain_selections.append(chain.atoms().extract_i_seq())
Example #25
0
 def __init__(self, ignore_line_search_failed_rounding_errors=True,
                    ignore_line_search_failed_step_at_lower_bound=False,
                    ignore_line_search_failed_step_at_upper_bound=False,
                    ignore_line_search_failed_maxfev=False,
                    ignore_line_search_failed_xtol=False,
                    ignore_search_direction_not_descent=False):
   adopt_init_args(self, locals())
Example #26
0
 def __init__ (self,
     title,
     column_names=None,
     column_types=None,
     column_labels=None,
     column_formats=None,
     graph_names=None,
     graph_types=None,
     graph_labels=None,
     graph_columns=None,
     data=None,
     comments=None,
     x_is_inverse_d_min=False,
     first_two_columns_are_resolution=False,
     force_exact_x_labels=False,
     reference_marks=None) :
   adopt_init_args(self, locals())
   if (reference_marks is not None) :
     assert (len(reference_marks) == len(graph_columns) == 1)
   if (data is not None) : # check column size consistency
     lengths = set([ len(column) for column in data ])
     assert len(lengths) == 1
   self._is_complete = False
   self._graphs = {}
   self._column_width = 10
   self.plot_type = "GRAPH"
Example #27
0
 def __init__(self, pdb_file_name, probabilities):
   adopt_init_args(self, locals())
   pdb_inp = iotbx.pdb.input(file_name=pdb_file_name)
   self.hierarchy = pdb_inp.construct_hierarchy()
   self.symmetry = pdb_inp.crystal_symmetry_from_cryst1()
   self.xray_structures_p1 = [xrs.expand_to_p1() for xrs in
     pdb_inp.xray_structures_simple(crystal_symmetry=self.symmetry)]
Example #28
0
 def __init__ (self,
               pdb_sequences,
               pdb_names,
               pdb_offsets=None,
               pdb_resids=None,
               reference_sequence=None,
               reference_sequence_name="reference_seq",
               reference_sequence_offset=0,
               reference_sequence_resids=None,
               reference_index=None,
               substitute_names=False,
               out=None) :
   adopt_init_args(self, locals())
   n_models = len(pdb_sequences)
   assert (pdb_resids is not None) or (pdb_offsets is not None)
   assert ((n_models >= 1) and (n_models==len(pdb_names)))
   if (pdb_offsets is not None) :
     assert (pdb_resids is None)
     assert (len(pdb_names) == len(pdb_offsets))
     assert (reference_sequence is None) or (reference_sequence_resids is None)
   else :
     assert (len(pdb_names) == len(pdb_resids))
     assert ((reference_sequence is None) or
             (reference_sequence_resids is not None))
   self.fasta_names = []
   self._name_lookup = None
   self.run_alignment(out=out)
   self.build_lookup_table()
   self.out = None # XXX required for pickling
Example #29
0
    def __init__(self,
                 uaniso,
                 x_initial,
                 adp_nma,
#                 weights,
                 n_modes,
                 zero_mode_flag,
                 max_iterations):
        adopt_init_args(self, locals())
#        assert self.uaniso.size() == self.weights.size()
        self.x     = self.x_initial
        self.x_min = self.x_initial
        self.n = self.x.size()
        t1 = time.time()
        self.minimizer = lbfgs.run(
                                  target_evaluator = self,
                                  termination_params = lbfgs.termination_parameters(
                                      max_iterations = max_iterations,
                                      max_calls = int(max_iterations*1.5)),
                                  exception_handling_params = 
                                  lbfgs.exception_handling_parameters(
                                      ignore_line_search_failed_step_at_lower_bound = False,
                                      ignore_line_search_failed_step_at_upper_bound = True,
                                      ignore_line_search_failed_maxfev              = False)
                                  )
        self.compute_functional_and_gradients()
        t2 = time.time()
        print t2 - t1
Example #30
0
 def __init__ (self, command_args, program_id, timeout, cache_requests=False,
               local_port=None, log=None, intercept_output=False) :
   adopt_init_args(self, locals())
   assert isinstance(command_args, list) or isinstance(command_args, tuple)
   self._process = None
   self._server = None
   self.initialize_server()
 def __init__(self, element, atomic_number, method, table_y, table_sigmas):
     assert table_y.size() == table_sigmas.size()
     adopt_init_args(self, locals())
     self.atomic_symbol = element
     if (element == "Cval"):
         self.atomic_symbol = "C"
     elif (element == "Sival"):
         self.atomic_symbol = "Si"
     else:
         for sign in ["+", "-"]:
             i = element.find(sign)
             if (i > 0):
                 self.element = element.replace(sign, "") + sign
                 self.atomic_symbol = element[:i]
                 break
Example #32
0
 def __init__(self,
       anomalous_plus_suffix="(+)",
       anomalous_minus_suffix="(-)",
       sigmas_prefix="SIG",
       sigmas_suffix="",
       delta_anomalous_prefix="DANO",
       delta_anomalous_suffix="",
       delta_anomalous_isym_prefix="ISYM",
       delta_anomalous_isym_suffix="",
       phases_prefix="PHI",
       phases_suffix="",
       hendrickson_lattman_suffix_list=["A","B","C","D"]):
   assert len(hendrickson_lattman_suffix_list) == 4
   adopt_init_args(self, locals())
   self.maximum_characters=30
Example #33
0
 def __init__(
     self,
     htype=None,  # type of hydrogen environment
     a0=None,  # parent atom index
     a1=None,  # 1-3 neighbor index
     a2=None,  # 1-3 or 1-4 neighbor index
     a3=None,  # 1-3 or 1-4 neighbor index
     a=None,  # coefficient for reconstruction
     b=None,  # coefficient for reconstruction
     h=None,  # coefficient for reconstruction
     phi=None,  # angle
     alpha=None,  # angle
     n=None,  # parameter for propeller and H2 groups
     dist_h=None):  # measured or ideal distance
     adopt_init_args(self, locals())
Example #34
0
 def __init__(self,
              id,
              angle_current,
              densities,
              sampling,
              fofc_densities=None):
     adopt_init_args(self, locals())
     assert len(densities) > 0
     if (angle_current < 0):
         self.angle_current = 360 + angle_current
     self.peak_chi, self.peak_rho = self.find_peaks(densities)
     self.deviation = self.deviate(self.peak_chi)
     self.rho_mean = sum(densities) / len(densities)
     # Add a tiny number to avoid dividing by 0 (which shouldn't happen anyway)
     self.rho_rel = self.peak_rho / (self.rho_mean + .000000000000000001)
Example #35
0
 def __init__ (self,
               program_name,
               job_title,
               directory=None,
               log_file=None,
               input_files=(),
               pdb_files=(),
               map_file=None,
               data_file=None,
               cif_files=(),
               phil_files=(),
               other_files=(),
               statistics={},
               other_result=None) :
   adopt_init_args(self, locals())
Example #36
0
 def __init__(
         self,
         target_map,
         residue,
         vdw_radii,
         xray_structure,
         mon_lib_srv,
         rotamer_manager,
         # This is cctbx.geometry_restraints.manager.manager
         geometry_restraints_manager,
         real_space_gradients_delta,
         selection_radius=5,
         rms_bonds_limit=0.03,  # XXX probably needs to be much lower
         rms_angles_limit=3.0,  # XXX
         backbone_sample_angle=None,
         allow_modified_residues=False):
     adopt_init_args(self, locals())
     # load rotamer manager
     self.rotamer_manager = mmtbx.idealized_aa_residues.rotamer_manager.load(
     )
     # pre-compute sin and cos tables
     self.sin_cos_table = scitbx.math.sin_cos_table(n=10000)
     self.backbone_atom_names = ["N", "CA", "O", "CB", "C"]
     self.residue_iselection = self.residue.atoms().extract_i_seq()
     assert (not self.residue_iselection.all_eq(0))
     self.residue_selection = flex.bool(xray_structure.scatterers().size(),
                                        self.residue_iselection)
     self.residue_backbone_selection = flex.size_t()
     for atom in self.residue.atoms():
         if (atom.name.strip() in self.backbone_atom_names):
             self.residue_backbone_selection.append(atom.i_seq)
     self.residue_backbone_selection = flex.bool(
         xray_structure.scatterers().size(),
         self.residue_backbone_selection)
     self.target_map_work = target_map
     self.target_map_orig = target_map.deep_copy()
     self.fit_backbone()
     negate_selection = mmtbx.refinement.real_space.selection_around_to_negate(
         xray_structure=self.xray_structure,
         selection_within_radius=self.selection_radius,
         iselection=self.residue.atoms().extract_i_seq())
     self.target_map_work = mmtbx.refinement.real_space.\
       negate_map_around_selected_atoms_except_selected_atoms(
         xray_structure   = self.xray_structure,
         map_data         = target_map,
         negate_selection = negate_selection,
         atom_radius      = 1.5)
     self.fit_rotamers()
Example #37
0
 def __init__(self,
              pdb_hierarchy,
              rotamer_manager,
              sin_cos_table,
              mon_lib_srv,
              f_map=None,
              fdiff_map=None,
              unit_cell=None,
              accept_only_if_max_shift_is_smaller_than=None,
              log=None):
     adopt_init_args(self, locals())
     assert [f_map, fdiff_map, unit_cell].count(None) in [0, 3]
     ac = accept_only_if_max_shift_is_smaller_than
     if (self.log is None): self.log = sys.stdout
     get_class = iotbx.pdb.common_residue_names_get_class
     for model in self.pdb_hierarchy.models():
         for chain in model.chains():
             for residue_group in chain.residue_groups():
                 conformers = residue_group.conformers()
                 if (len(conformers) > 1): continue
                 for conformer in residue_group.conformers():
                     residue = conformer.only_residue()
                     id_str = "%s%s%s" % (chain.id, residue.resname,
                                          residue.resseq.strip())
                     if (get_class(residue.resname) == "common_amino_acid"):
                         # Idealize rotamer: move to nearest rotameric state
                         re = self.rotamer_manager.rotamer_evaluator
                         if (re.evaluate_residue(residue) == "OUTLIER"):
                             go = True
                             if ([f_map, fdiff_map,
                                  unit_cell].count(None) == 0):
                                 go = mmtbx.refinement.real_space.need_sidechain_fit(
                                     residue=residue,
                                     rotamer_evaluator=self.rotamer_manager.
                                     rotamer_evaluator,
                                     mon_lib_srv=self.mon_lib_srv,
                                     unit_cell=self.unit_cell,
                                     f_map=f_map,
                                     fdiff_map=fdiff_map)
                             if (go):
                                 mmtbx.refinement.real_space.fit_residue.run(
                                     residue=residue,
                                     backbone_sample=False,
                                     mon_lib_srv=self.mon_lib_srv,
                                     rotamer_manager=self.rotamer_manager,
                                     sin_cos_table=self.sin_cos_table,
                                     accept_only_if_max_shift_is_smaller_than
                                     =ac)
Example #38
0
 def __init__(self,
              map_data,
              xray_structure,
              pdb_hierarchy,
              geometry_restraints_manager,
              gradients_method="fd",
              selection=None,
              selection_real_space=None,
              rms_bonds_limit=0.015,
              rms_angles_limit=2.0,
              max_iterations=150,
              w=None,
              states_accumulator=None,
              log=None):
     assert gradients_method in ["fd", "linear", "quadratic", "tricubic"]
     adopt_init_args(self, locals())
     es = geometry_restraints_manager.geometry.energies_sites(
         sites_cart=xray_structure.sites_cart())
     self.rmsd_angles_start = es.angle_deviations()[2]
     self.rmsd_bonds_start = es.bond_deviations()[2]
     self.w = w
     if (self.w is None):
         import mmtbx.refinement.real_space.weight
         self.weight = mmtbx.refinement.real_space.weight.run(
             map_data=map_data,
             xray_structure=self.xray_structure,
             pdb_hierarchy=self.pdb_hierarchy,
             geometry_restraints_manager=geometry_restraints_manager,
             rms_bonds_limit=rms_bonds_limit,
             rms_angles_limit=rms_angles_limit,
             gradients_method=gradients_method)
         self.w = self.weight.weight
     if (selection is None):
         selection = flex.bool(self.xray_structure.scatterers().size(),
                               True)
     refine_object = simple(
         target_map=map_data,
         selection=selection,
         selection_real_space=selection_real_space,
         max_iterations=max_iterations,
         geometry_restraints_manager=geometry_restraints_manager.geometry,
         states_accumulator=states_accumulator,
         gradients_method=gradients_method)
     refine_object.refine(weight=self.w, xray_structure=self.xray_structure)
     self.rmsd_bonds_final, self.rmsd_angles_final = refine_object.rmsds()
     self.xray_structure = self.xray_structure.replace_sites_cart(
         new_sites=refine_object.sites_cart(), selection=None)
     self.pdb_hierarchy.adopt_xray_structure(self.xray_structure)
Example #39
0
  def __init__(self, filename, experiment, HKL, i_sigi, measurements, params):
    from libtbx import adopt_init_args
    adopt_init_args(self, locals())
    self.stash_type = None
    self.stash_res_filter = None

    from dxtbx.model import DetectorFactory
    self.dummy_detector = DetectorFactory.simple(
      sensor = DetectorFactory.sensor("PAD"),
      distance = 100,
      beam_centre = [1000, 1000],
      fast_direction = "+x",
      slow_direction = "+y",
      pixel_size = [0.2,0.2],
      image_size = [2000,2000],
      )
 def __init__(self, gaussian_fit, target_power,
                    use_sigmas,
                    shift_sqrt_b,
                    lbfgs_termination_params=None,
                    lbfgs_core_params=lbfgs.core_parameters(m=20),
                    hard_b_min=-1):
   adopt_init_args(self, locals())
   minimize_multi_histogram.setdefault(str(self), 0)
   assert target_power in [2,4]
   self.x = flex.double(gaussian_fit.n_parameters(), 0)
   self.first_target_value = None
   self.minimizer = lbfgs.run(
     target_evaluator=self,
     termination_params=lbfgs_termination_params,
     core_params=lbfgs_core_params)
   self.finalize()
Example #41
0
 def __init__(self,
     sources_and_models,
     sequence,
     first_chain_only=False,
     reset_chain_id=None,
     min_identity=0.95,
     nproc=Auto,
     log=null_out()):
   adopt_init_args(self, locals())
   self._results = easy_mp.pool_map(
     fixed_func=self.examine_model,
     iterable=range(len(self.sources_and_models)),
     processes=self.nproc)
   for k, results in enumerate(self._results):
     if (len(results) == 0):
       print("  no matches for %s" % self.sources_and_models[k][0], file=log)
Example #42
0
 def __init__(self,
              bonds,
              points,
              b_iso,
              b_aniso,
              atom_colors,
              atom_labels,
              atom_radii,
              visibility,
              noncovalent_bonds,
              atomic_bonds,
              ribbon=None):
     adopt_init_args(self, locals())
     self.clear_lists()
     self.clear_labels()
     self.update_visibility(visibility)
Example #43
0
 def __init__(self,
              orient,
              constraint='triclinic',
              min_iterations=25,
              max_calls=1000):
     self.constraint = constraint
     adopt_init_args(self, locals())
     self.n = 9
     self.x = flex.double(orient.direct_matrix())
     self.minimizer = lbfgs.run(
         target_evaluator=self,
         termination_params=lbfgs.termination_parameters(
             traditional_convergence_test=00000,
             min_iterations=min_iterations,
             max_calls=max_calls))
     del self.g
Example #44
0
 def __init__(self,
              xray_structure,
              ncs_restraints_group_list,
              refine_selection=None,
              use_ncs_constraints=True,
              restraints_manager=None,
              refine_sites=False,
              refine_transformations=False):
     adopt_init_args(self, locals())
     self.refine_selection = nu.get_refine_selection(
         refine_selection=self.refine_selection,
         number_of_atoms=self.xray_structure.sites_cart().size())
     self.extended_ncs_selection = nu.get_extended_ncs_selection(
         ncs_restraints_group_list=ncs_restraints_group_list,
         refine_selection=self.refine_selection)
     self.unit_cell = self.xray_structure.unit_cell()
Example #45
0
  def __init__(self,options,image,pd,report_overloads=False,params=None):
    w_Distl.__init__(self,options,report_overloads)
    adopt_init_args(self, locals())

    try:    saturation = image.saturation
    except Exception: saturation = 65535
    try:    peripheral_margin = params.distl.peripheral_margin
    except Exception: peripheral_margin = 20
    self.setspotimg(pixel_size = image.pixel_size, distance = image.distance,
                    wavelength = image.wavelength, xbeam = float(pd['xbeam']),
                    ybeam = float(pd['ybeam']), rawdata = image.rawdata,
                    peripheral_margin = peripheral_margin,
                    saturation = saturation)
    #Fixes a longstanding gremlin:  my corrected xy must be propagated
    # to zepu's code; or else ice rings are treated incorrectly.

    #Setup tiling, if any.
    self.set_tiling(image.vendortype)

    self.deprecation_warnings()
    if params!=None:
        if params.distl.minimum_spot_area != None:
          self.set_minimum_spot_area(params.distl.minimum_spot_area)
        if params.distl.minimum_signal_height != None:
          self.set_minimum_signal_height(params.distl.minimum_signal_height)
        if params.distl.minimum_spot_height != None:
          self.set_minimum_spot_height(params.distl.minimum_spot_height)
        if params.distl.spot_area_maximum_factor != None:
          self.set_spot_area_maximum_factor(params.distl.spot_area_maximum_factor)
        if params.distl.peak_intensity_maximum_factor != None:
          self.set_peak_intensity_maximum_factor(params.distl.peak_intensity_maximum_factor)
        self.set_scanbox_windows(params.distl.scanbox_windows)
        if params.distl.detector_tiling != None:
          IT = image.get_tile_manager(params
               ).effective_tiling_as_flex_int()

          self.set_tiling(detector_tiling = IT,
                          peripheral_margin = peripheral_margin)

    self.parameter_guarantees()

    self.get_underload()
    try:
      self.pxlclassify()
    except Exception, e:
      if str(e).find("cannot distinguish signal")>0: print e
      else: raise e
Example #46
0
 def __init__(self, xray_structure, d_min=None, n_real=None, mask_params = None,
              atom_radius = None):
   adopt_init_args(self, locals())
   assert [d_min, n_real].count(None) == 1
   if(self.mask_params is None):
     self.mask_params = mask_master_params.extract()
   if(atom_radius is None):
     self.atom_radii = vdw_radii_from_xray_structure(xray_structure =
       self.xray_structure)
   else:
     self.atom_radii = flex.double(self.xray_structure.scatterers().size(),
       atom_radius)
   if(d_min is not None):
     self.asu_mask = atom_mask(
       unit_cell                = self.xray_structure.unit_cell(),
       group                    = self.xray_structure.space_group(),
       resolution               = self.d_min,
       grid_step_factor         = self.mask_params.grid_step_factor,
       solvent_radius           = self.mask_params.solvent_radius,
       shrink_truncation_radius = self.mask_params.shrink_truncation_radius)
   else:
     self.asu_mask = atom_mask(
       unit_cell                = self.xray_structure.unit_cell(),
       space_group              = self.xray_structure.space_group(),
       gridding_n_real          = self.n_real,
       solvent_radius           = self.mask_params.solvent_radius,
       shrink_truncation_radius = self.mask_params.shrink_truncation_radius)
   selection = flex.bool(self.xray_structure.scatterers().size(), True)
   if(self.mask_params.ignore_zero_occupancy_atoms):
     selection &= self.xray_structure.scatterers().extract_occupancies() > 0
   if(self.mask_params.ignore_hydrogens):
     selection &= (~self.xray_structure.hd_selection())
   sites_frac = self.xray_structure.sites_frac()
   sites_frac = sites_frac.select(selection)
   atom_radii = self.atom_radii.select(selection)
   if(self.mask_params.n_radial_shells > 1):
     # number of shell radii is one less than number of shells
     # last shell is of unknown radius
     shell_rads = [self.mask_params.radial_shell_width] * \
       (self.mask_params.n_radial_shells-1)
     # TODO: Should first shell width be:
     shell_rads[0] -= self.mask_params.solvent_radius
     if( shell_rads[0]<0. ):
       shell_rads[0] = 0.
     self.asu_mask.compute(sites_frac, atom_radii, shell_rads)
   else:
     self.asu_mask.compute(sites_frac, atom_radii)
Example #47
0
    def __init__(self, map_manager, model, cushion, wrapping, log=sys.stdout):
        adopt_init_args(self, locals())
        self.basis_for_boxing_string = 'using model, wrapping=%s' % (wrapping)
        # safeguards
        assert isinstance(wrapping, bool)
        assert isinstance(map_manager, iotbx.map_manager.map_manager)
        assert isinstance(model, mmtbx.model.manager)
        assert self.map_manager.map_data().accessor().origin() == (0, 0, 0)

        # Make sure original map_manager symmetry matches model or original model
        original_uc_symmetry = map_manager.original_unit_cell_crystal_symmetry
        assert (original_uc_symmetry.is_similar_symmetry(
            model.crystal_symmetry())
                or (model.get_shift_manager()
                    and original_uc_symmetry.is_similar_symmetry(
                        model.get_shift_manager().get_original_cs())))

        assert cushion >= 0
        if wrapping:
            assert map_manager.unit_cell_grid == map_manager.map_data().all()
        # get items needed to do the shift
        cs = map_manager.crystal_symmetry()
        uc = cs.unit_cell()
        sites_frac = model.get_sites_frac()
        map_data = map_manager.map_data()
        # convert cushion into fractional vector
        cushion_frac = flex.double(uc.fractionalize((cushion, ) * 3))
        # find fractional corners
        frac_min = sites_frac.min()
        frac_max = sites_frac.max()
        frac_max = list(flex.double(frac_max) + cushion_frac)
        frac_min = list(flex.double(frac_min) - cushion_frac)
        # find corner grid nodes
        all_orig = map_data.all()
        self.gridding_first = [
            ifloor(f * n) for f, n in zip(frac_min, all_orig)
        ]
        self.gridding_last = [iceil(f * n) for f, n in zip(frac_max, all_orig)]

        # Ready with gridding...set up shifts and box crystal_symmetry
        self.set_shifts_and_crystal_symmetry()

        # Apply to model and to map_manager so that self.model()
        #  and self.map_manager are boxed versions

        self.map_manager = self.apply_to_map(self.map_manager)
        self.model = self.apply_to_model(self.model)
Example #48
0
 def __init__(self,
               parent,
               tables,
               size=(640,480),
               **kwds):
   adopt_init_args(self, locals())
   (x, y, w, h) = tuple(wx.GetClientDisplayRect())
   (width, height) = size
   fig_w = float(width) / 72.0
   fig_h = float(height) / 72.0
   if (fig_w * 72) > (w - 20):
     fig_w = int(math.floor((w-40) / 72))
   if (fig_h * 72) > (h - 120):
     fig_h = int(math.floor((h-160) / 72))
   plot_container.__init__(self, parent, (fig_w, fig_h), **kwds)
   self.p = self.figure.add_subplot(111)
   self.plot_type = None
Example #49
0
 def reinitialize(self, logical_rank, comm_size, per_rank_items, per_rank_keys, per_rank_G,
                  HKL_lookup, static_fcalcs, model_intensities,force_recompute=False):
   from libtbx import adopt_init_args
   adopt_init_args(self, locals())
   self.model_intensities_reinitialized_for_debug_iteration_1 = (
      self.params.starting_model.preset.FE1 == "Fe_oxidized_model" and
      self.params.starting_model.preset.FE2 == "Fe_reduced_model"
   )
   if force_recompute: self.model_intensities_reinitialized_for_debug_iteration_1=False
   self.plot_plt_imported = False
   self.starting_params_cached = False
   if not self.starting_params_cached:
     self.starting_params_FE1 = self.x[0:200]
     self.starting_params_FE2 = self.x[200:400]
     self.starting_params_cached = True
   self.iteration = 0
   self.macrocycle = None
Example #50
0
 def __init__(self,
              unit_cell,
              target_map,
              residue,
              rotamer_eval = None,
              vector = None):
   adopt_init_args(self, locals())
   self.target = None
   self.sites_cart = None
   self.i_seqs = []
   self.weights = flex.double()
   for el in self.residue.atoms().extract_element():
     std_lbl = eltbx.xray_scattering.get_standard_label(
       label=el, exact=True, optional=True)
     self.weights.append(tiny_pse.table(std_lbl).weight())
   self.occ = self.residue.atoms().extract_occ()
   self.vector_flat = flatten(self.vector)
Example #51
0
 def __init__(self, peaks, holes, map_cutoff=3.0, anom_peaks=None,
     anom_map_cutoff=3.0, water_peaks=None, water_anom_peaks=None,
     non_water_anom_peaks=None):
   adopt_init_args(self, locals())
   # XXX pre-sort all lists
   self.peaks.sort(reverse=True)
   self.holes.sort()
   if (self.anom_peaks is not None):
     self.anom_peaks.sort(reverse=True)
   if (self.water_peaks is not None):
     self.water_peaks = sorted(self.water_peaks, key=operator.attrgetter("peak_height"), reverse=True)
   if (self.water_anom_peaks is not None):
     self.water_anom_peaks = sorted(self.water_anom_peaks,
                                    key=operator.attrgetter("peak_height"),
                                    reverse=True)
   self.pdb_file = None
   self.map_file = None
Example #52
0
    def __init__(self,
                 xray_structure,
                 obs_,
                 exti=None,
                 connectivity_table=None):
        if exti is None:
            exti = xray.dummy_extinction_correction()
        adopt_init_args(self, locals())
        assert obs_.fo_sq.anomalous_flag()
        assert not (obs_.twin_fractions and obs_.merohedral_components)

        xray_structure = xray_structure.deep_copy_scatterers()
        for sc in xray_structure.scatterers():
            f = xray.scatterer_flags()
            f.set_use_u_aniso(sc.flags.use_u_aniso())
            f.set_use_u_iso(sc.flags.use_u_iso())
            f.set_use_fp_fdp(True)
            sc.flags = f

        twin_fractions = ()
        it = xray.twin_component(sgtbx.rot_mx((-1, 0, 0, 0, -1, 0, 0, 0, -1)),
                                 0.2, True)
        twin_components = (it, )
        obs = observations.customized_copy(obs_, twin_fractions,
                                           twin_components)
        # reparameterisation needs all fractions
        twin_fractions += twin_components
        if connectivity_table is None:
            connectivity_table = smtbx.utils.connectivity_table(xray_structure)
        reparametrisation = constraints.reparametrisation(
            xray_structure, [],
            connectivity_table,
            twin_fractions=twin_fractions,
            extinction=exti)
        normal_eqns = least_squares.crystallographic_ls(obs, reparametrisation)
        cycles = normal_eqns_solving.naive_iterations(normal_eqns,
                                                      n_max_iterations=10,
                                                      gradient_threshold=1e-7,
                                                      step_threshold=1e-4)
        self.flack_x = it.value
        self.sigma_x = math.sqrt(
            normal_eqns.covariance_matrix(
                jacobian_transpose=reparametrisation.
                jacobian_transpose_matching(
                    reparametrisation.mapping_to_grad_fc_independent_scalars))
            [0])
 def __init__(self,
              restraints_manager=None,
              fmodel=None,
              sites_cart=None,
              wx=None,
              wc=None,
              update_gradient_threshold=0):
     adopt_init_args(self, locals())
     assert [self.fmodel, self.wx].count(None) in [0, 2]
     assert [self.restraints_manager, self.wc].count(None) in [0, 2]
     self.gx, self.gc = 0, 0
     if (self.fmodel is not None):
         self.x_target_functor = self.fmodel.target_functor()
         xray.set_scatterer_grad_flags(
             scatterers=self.fmodel.xray_structure.scatterers(), site=True)
         self.gx = flex.vec3_double(self.x_target_functor(compute_gradients=True).\
           gradients_wrt_atomic_parameters(site=True).packed())
 def __init__(self, peaks, holes, map_cutoff=3.0, anom_peaks=None,
     anom_map_cutoff=3.0, water_peaks=None, water_anom_peaks=None,
     non_water_anom_peaks=None):
   adopt_init_args(self, locals())
   # XXX pre-sort all lists
   self.peaks.sort(reverse=True)
   self.holes.sort()
   if (self.anom_peaks is not None):
     self.anom_peaks.sort(reverse=True)
   if (self.water_peaks is not None):
     self.water_peaks = sorted(self.water_peaks,
       lambda x,y: cmp(y.peak_height, x.peak_height))
   if (self.water_anom_peaks is not None):
     self.water_anom_peaks = sorted(self.water_anom_peaks,
       lambda x,y: cmp(y.peak_height, x.peak_height))
   self.pdb_file = None
   self.map_file = None
Example #55
0
 def __init__(self,
              i_bin=None,
              d_range=None,
              d_min=None,
              redundancy_asu=None,
              redundancy_obs=None,
              frames=None,
              absent=None,
              complete_tag=None,
              completeness=None,
              measurements=None,
              negative=None,
              percent_neg=None,
              mean_I=None,
              mean_I_sigI=None,
              sigmaa=None):
   adopt_init_args(self, locals())
Example #56
0
 def __init__(
         self,
         ma,  # message_accumulator
         map_model_manager,
         dist_min=2.0,
         dist_max=3.2,
         step=0.3,
         map_threshold=1.5,
         sphericity_filter=True,
         scc05=0.97,
         scc1=0.9,
         debug=False,
         log=None,
         total_time=0,
         prefix=""):
     # Common parameters / variables
     self.model = map_model_manager.model()
     map_data = map_model_manager.map_manager().map_data()
     adopt_init_args(self, locals())
     self.total_time = total_time
     if (map_data.accessor().origin() != (0, 0, 0)):
         raise Sorry("Map origin must be zero.")
     self.ma = ma
     self.map_data = self.map_data.deep_copy()  # will be changed in-place!
     self.unit_cell = self.model.crystal_symmetry().unit_cell()
     self.sites_frac = self.model.get_xray_structure().sites_frac()
     self.interaction_selection = self.model.selection(
         selection_string_interaction)
     self.sites_frac_interaction = self.sites_frac.select(
         self.interaction_selection)
     self.sites_frac_water = None
     self.cutoff = None
     self._wrote_file = 0
     # Calculations
     self._call(self._massage_map, "Normalize and re-sample input map")
     self._call(self._get_cutoff, "Get cutoff")
     self._call(self._mask_out, "Mask out molecule/solvent regions")
     self._call(self._find_peaks, "Find peaks")
     self._call(self._filter_by_distance, "Filter peaks by distance")
     if (self.sphericity_filter):
         self._call(self._filter_by_sphericity,
                    "Filter peaks by sphericity")
     self._call(self._filter_by_distance, "Filter peaks by distance")
     self._call(self._append_to_model, "Add to model and reset internals")
     if (self.debug):
         self._call(self._show_peak_profiles, "Show peak profiles")
 def __init__(self,
              i_bin=None,
              d_range=None,
              d_min=None,
              redundancy_asu=None,
              redundancy_obs=None,
              redundancy_to_edge=None,
              absent=None,
              complete_tag=None,
              completeness=None,
              measurements=None,
              multiply_measured_asu=None,
              predictions=None,
              mean_I=None,
              mean_I_sigI=None,
              sigmaa=None):
   adopt_init_args(self, locals())
Example #58
0
    def __init__(self,
                 params=None,
                 map_data=None,
                 crystal_symmetry=None,
                 ncs_object=None,
                 log=sys.stdout):
        adopt_init_args(self, locals())
        self.cc = None
        self.original_ncs_object = None
        if ncs_object:
            self.original_ncs_object = ncs_object.deep_copy()
        self.ncs_object = ncs_object

        if self.params and self.params.control.verbose:
            self.local_log = log
        else:
            self.local_log = null_out()
Example #59
0
 def __init__(self,
       map_data,
       map_data_1,
       map_data_2,
       xray_structure,
       crystal_symmetry,
       caller,
       params):
   adopt_init_args(self, locals())
   if(self.crystal_symmetry is None):
     self.crystal_symmetry = self.xray_structure.crystal_symmetry()
   self.call = self.caller.call
   self.resolution = self.params.resolution
   # Results
   self.d99              = None
   self.d999             = None
   self.d9999            = None
   self.d99999           = None
   self.d99_1            = None
   self.d99_2            = None
   self.d_model          = None
   self.d_model_b0       = None
   self.b_iso_overall    = None
   self.d_fsc            = None
   self.d_fsc_05         = None
   self.d_fsc_model_05   = None
   self.d_fsc_model_0    = None
   self.d_fsc_model_0143 = None
   self.fsc_curve        = None
   self.fsc_curve_model  = None
   self.mask_smooth      = None
   self.radius_smooth    = self.params.radius_smooth
   self.n_bins    = self.params.n_bins
   self.d_corner         = None
   self.d9999            = None
   # Info (results)
   self.map_counts        = None
   self.half_map_1_counts = None
   self.half_map_2_counts = None
   self.map_histograms    = None
   # Internal work objects
   self.f_map    = None
   self.f_map_1  = None
   self.f_map_2  = None
   self.f_calc   = None
Example #60
0
 def __init__(self,
              params,
              out=None,
              neutron_refinement=None,
              call_back_handler=None,
              is_neutron_monitor=False):
     adopt_init_args(self, locals())
     if (self.out is None): self.out = sys.stdout
     self.wilson_b = None
     self.bond_start = None
     self.angle_start = None
     self.bond_final = None
     self.angle_final = None
     self.rigid_body_shift_accumulator = None
     self.sites_cart_start = None
     for name in self.__arrays__:
         setattr(self, name, [])
     self.is_amber_monitor = False