ó
È™xTc           @   sO  d  d l  m Z d  d l m Z d  d l m Z d  d l Z d  d l Z d  d l m	 Z	 d  d l m
 Z
 d  d l Z d  d l Z d  d l m Z d  d l m Z d  d	 l m Z d  d l Z d  d l Z d  d
 l m Z d  d l m Z d  d l m Z d Z d Z d Z d e e e f Z d „  Z d e  f d „  ƒ  YZ! e" d d „ Z# d S(   iÿÿÿÿ(   t   division(   t   flex(   t   xrayN(   t   adopt_init_args(   t   adptbx(   t   format_value(   t
   find_peaks(   t   minimization(   t   miller(   t   maptbx(   t   approx_equals>  
  output_residue_name = HOH
    .type=str
    .input_size = 50
  output_chain_id = S
    .type=str
    .input_size = 50
  output_atom_name = O
    .type=str
    .input_size = 50
  scattering_type = O
    .type=str
    .help = Defines scattering factors for newly added waters
    .expert_level=2
    .input_size = 50
sS  
  h_bond_min_mac = 1.8
    .type = float
    .short_caption = H-bond minimum for solvent-model
    .expert_level = 1
  h_bond_min_sol = 1.8
    .type = float
    .short_caption = H-bond minimum for solvent-solvent
    .expert_level = 1
  h_bond_max = 3.2
    .type = float
    .short_caption = Maximum H-bond length
    .expert_level = 1
sY  
  new_solvent = *isotropic anisotropic
    .type = choice
    .help = Based on the choice, added solvent will have isotropic or             anisotropic b-factors
    .short_caption = New solvent ADP type
    .expert_level = 1
  b_iso_min = 1.0
    .type=float
    .help = Minimum B-factor value, waters with smaller value will be rejected
    .short_caption = Minimum B-factor
    .expert_level = 1
  b_iso_max = 80.0
    .type=float
    .help = Maximum B-factor value, waters with bigger value will be rejected
    .short_caption = Maximum B-factor
    .expert_level = 1
  anisotropy_min = 0.1
    .type = float
    .help = For solvent refined as anisotropic: remove is less than this value
    .short_caption = Minimum anisotropic B-factor
    .expert_level = 1
  b_iso = None
    .type=float
    .help = Initial B-factor value for newly added water
    .short_caption = Initial B-factor value
    .expert_level = 1
  occupancy_min = 0.1
    .type=float
    .help = Minimum occupancy value, waters with smaller value will be rejected
    .short_caption = Minimum occupancy
  occupancy_max = 1.0
    .type=float
    .help = Maximum occupancy value, waters with bigger value will be rejected
    .short_caption = Maximum occupancy
  occupancy = 1.0
    .type=float
    .help = Initial occupancy value for newly added water
    .short_caption = Initial occupancy value
sY    low_resolution = 2.8
    .type = float
    .help = Low resolution limit for water picking (at lower resolution water             will not be picked even if requessted)
    .short_caption = Minimum resolution
  mode = *second_half filter_only every_macro_cycle every_macro_cycle_after_first
    .type=choice
    .help = Choices for water picking strategy: auto - start water picking             after ferst few macro-cycles, filter_only - remove water only,             every_macro_cycle - do water update every macro-cycle
    .short_caption = Mode
  n_cycles = 1
    .type = int
    .short_caption = Number of cycles
  %s
  primary_map_type = mFobs-DFmodel
    .type=str
    .help = Map used to identify candidate water sites - by default this is       the standard difference map.
  primary_map_cutoff = 3.0
    .type=float
    .short_caption = Primary map cutoff (sigma)
  secondary_map_and_map_cc_filter
    .short_caption = Secondary map filter
    .style = auto_align box
  {
    cc_map_1_type = "Fc"
      .type = str
      .short_caption = Model map type for CC calculation
    cc_map_2_type = 2mFo-DFmodel
      .type = str
      .short_caption = Experimental map type for CC calculation
    poor_cc_threshold = 0.7
      .type = float
      .short_caption = Minimum map correlation
    poor_map_value_threshold = 1.0
      .type = float
      .short_caption = Minimum map value (sigma)
  }
  %s
  refine_adp = True
    .type = bool
    .help = Refine ADP for newly placed solvent.
    .short_caption = Refine new solvent ADPs
    .expert_level = 1
  refine_occupancies = False
    .type = bool
    .help = Refine solvent occupancies.
    .expert_level = 1
  %s
  filter_at_start = True
    .type = bool
    .expert_level = 1
  ignore_final_filtering_step = False
    .type = bool
    .expert_level=2
  correct_drifted_waters = True
    .type = bool
    .expert_level=2
c           C   s   t  j j t ƒ S(   N(   t   iotbxt   philt   parset   master_params_str(    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyt   master_params™   s    t   managerc           B   s�   e  Z e ƒ  j ƒ  d d d  „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z RS(   c   
      C   sG  t  |  t ƒ  ƒ d t |  j j ƒ k  o3 d k n s> t ‚ t |  j j ƒ d k s\ t ‚ d t |  j j ƒ k  o d k n sŠ t ‚ |  j j	 |  j
 j	 k s¨ t ‚ |  j d  k rÌ t ƒ  j ƒ  |  _ n  |  j d  k rð t j j ƒ  |  _ n  |  j j d k rt |  _ n	 t |  _ |  j d  k r5t j |  _ n  |  j
 j	 |  j j	 k sSt ‚ d  |  _ d  |  _ |  j j	 |  j
 j	 k sƒt ‚ |  j j d  k rõ|  j
 j ƒ  j t ƒ d k rÔ|  j
 j ƒ  j t ƒ |  j _ qõ|  j
 j	 j ƒ  j ƒ  |  j _ n  |  j j	 |  j
 j	 k st ‚ |  j ƒ  |  j ƒ  s8t  d ƒ ‚ n  |  j! d d ƒ |  j j	 |  j
 j	 k sft ‚ |  j j" r�|  j# ƒ  |  j! d d	 ƒ n  |  j j	 |  j
 j	 k s­t ‚ |  j s„|  j j$ d  k	 sÎt ‚ |  j d
 |  j j$ d |  j j% ƒ j& ƒ  } | d  k	 r„| j | j |  _ |  _ |  j' ƒ  |  j j	 |  j
 j	 k sEt ‚ |  j! d d ƒ |  j j" r�|  j# ƒ  |  j! d d	 ƒ q�q„n  |  j j	 |  j
 j	 k s¢t ‚ |  j rÇ|  j( d |  j j) j* ƒ n  |  j |  j g j d  ƒ d k rN|  j r|  j j( r|  j( d |  j j) j* ƒ n  x1 t+ |  j j, ƒ D] }	 |  j- ƒ  |  j. ƒ  q-Wn  |  j! d d ƒ |  j j	 |  j
 j	 k s|t ‚ |  j# ƒ  |  j j	 |  j
 j	 k s¤t ‚ |  j j) j/ d  k	 rã|  j0 ƒ  |  j! d d |  j j) j/ ƒ n  |  j j	 |  j
 j	 k st ‚ |  j! d d ƒ |  j ƒ  |  j1 ƒ  |  j j	 |  j
 j	 k sCt ‚ d  S(   Ni    i   i   i   t   filter_onlys+   Water picking failed: solvent must be last.t   messages   Start model:s	   Filtered:t   map_typet
   map_cutoffs   Just added new:s   Before filtering:s   %s map selection:s   Final:(2   R   t   localst   lent   paramst   output_atom_namet   AssertionErrort   output_chain_idt   output_residue_namet   fmodelt   xray_structuret   modelt   NoneR   t   extractt   find_peaks_paramsR   t   modet   TrueR   t   Falset   logt   syst   stdoutt   sitest   heightst   max_number_of_peakst   solvent_selectiont   countt
   scattererst   sizet$   move_solvent_to_the_end_of_atom_listt   is_water_lastt   RuntimeErrort   showt   filter_at_startt   filter_solventt   primary_map_typet   primary_map_cutofft   peaks_mappedt   add_new_solventt   correct_drifted_waterst   secondary_map_and_map_cc_filtert   poor_map_value_thresholdt   xranget   n_cyclest
   refine_adpt   refine_occupanciest   cc_map_2_typet   find_peaks_2fofct   convert_water_adp(
   t   selfR   t   fmodelsR   t   is_neutron_scat_tableR   R!   R%   t   peakst   i(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyt   __init__�   sŠ    ..  	 		!!

		

		!	




c         C   sE  |  j  j j ƒ  } | } |  j  j ƒ  } | } |  j  j j ƒ  j ƒ  } |  j j d k rl | j | t	 ƒ n  |  j  j j
 ƒ  j ƒ  } | j | t ƒ | j | t ƒ |  j sÐ | j | t ƒ | j | t ƒ n  | j | t ƒ | j | t ƒ |  j  j j d | ƒ |  j  j j d | j ƒ  ƒ |  j j d |  j  j d t	 ƒ d  S(   Nt   anisotropict	   selectionR   t   update_f_calc(   R   R   t   hd_selectionR+   t   use_u_anisot	   deep_copyR   t   new_solventt   set_selectedR#   t	   use_u_isoR$   RE   t   convert_to_anisotropict   convert_to_isotropict
   iselectionR   t   update_xray_structure(   RC   t   hd_selt
   not_hd_selt   sol_selt   not_sol_selt   selection_anisot   selection_iso(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyRB   î   s(    	c         C   sÄ   t  j |  j j ƒ  j t ƒ t ƒ } | j t  j |  j j ƒ  j t ƒ t ƒ ƒ |  j j j	 |  j j ƒ  ƒ } | j
 ƒ  j t ƒ d k r¡ |  j d | d | ƒ n  |  j j ƒ  |  j j |  j _ d  S(   Ni    R+   t   solvent_xray_structure(   R   t   boolR   R+   R,   R$   t   extendR#   R   t   selectRL   t   reset_solventt   renumber_waterR   (   RC   t   solselt   xrs_sol(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR/     s    $+	
c         C   sŠ   t  } |  j j ƒ  } | j ƒ  } | j ƒ  } | j ƒ  d k r† | j ƒ  d k r† t j | d ƒ t j | d ƒ d k r† t } q† n  | S(   Ni    i   (	   R#   R   R+   RT   R.   R   t   min_defaultt   max_defaultR$   (   RC   t   resultRX   t	   i_sol_selt	   i_mac_sel(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR0     s    $(c         C   sã  |  j  j ƒ  } |  j  j j ƒ  } |  j  j j ƒ  } |  j  j j ƒ  } | j ƒ  } | j |  j  j j ƒ  ƒ t	 j
 d d } | j d |  j  j j ƒ  ƒ } t j j d |  j  j j ƒ  d |  j  j j ƒ  d | j | t ƒ j ƒ  d |  j j d |  j j d	 |  j j d |  j  j j ƒ  ƒ } t j | j ƒ  | ƒ }	 | |	 M} | | |  j j k M} | | |  j j k M} | | |  j j k M} | | |  j j k M} | j | t ƒ | j | t ƒ | |  j j  k  }
 |
 j | t ƒ |
 j | t ƒ |  j  j j! d
 |
 j ƒ  ƒ |  j  j j" d
 |
 j ƒ  ƒ |  j  j# ƒ  } | d  k	 r�xO | D]D } | | d sgt | | d <n  | | d rBt | | d <qBqBWn  | j ƒ  | j% t ƒ k rß|  j  j& | ƒ |  _  |  j' j( d |  j  j d t ƒ n  d  S(   Ni   i   t	   unit_cellt   sites_frac_allt   element_symbols_allt   water_selection_ot   dist_maxt   dist_min_mact   dist_min_solRJ   i    i   R   RK   ()   R   R+   R   RL   t   all_selectionR-   t   extract_occupanciest   extract_u_iso_or_u_equivRi   t   matht   pit
   anisotropyt   mmtbxt   utilst   select_water_by_distancet
   sites_fract   scattering_typesRP   R$   RT   R   t
   h_bond_maxt   h_bond_min_mact   h_bond_min_solR   R]   R.   t	   b_iso_mint	   b_iso_maxt   occupancy_mint   occupancy_maxR#   t   anisotropy_minRS   RR   t   xh_connectivity_tableR   R,   R_   R   RU   (   RC   RX   RV   RJ   R-   t   occt   b_isosRu   t   distance_iselectiont   distance_selectiont   anisoselt   xhtt   ti(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR4     sV    *	
  c         C   sŒ   | j  t ƒ | j ƒ  j ƒ  k s' t ‚ |  j j ƒ  |  _ |  j j d | d |  j j	 d |  j j
 d |  j j d |  j j d |  j j ƒ d  S(   NR\   t   residue_namet	   atom_namet   chain_idR?   R>   (   R,   R#   R-   R.   R   R   t   remove_solventt   add_solventR   R   R   R   R?   RO   (   RC   R+   R\   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR`   J  s    c         C   s“  |  j  | IJ|  j j ƒ  } |  j j j | ƒ } |  j j j | ƒ } |  j j j ƒ  j | ƒ } |  j j j ƒ  j | ƒ } | j | ƒ } | j | ƒ } | j ƒ  }	 |	 j ƒ  }
 |	 j |  j j j	 ƒ  ƒ t
 j d d } | j d | j ƒ  d |  j j j ƒ j } t d |	 j ƒ  ƒ } t d t j | d  ƒ ƒ } t d t j | d  ƒ ƒ } t d t j | d  ƒ ƒ } t d |  j j ƒ j ƒ  } t d |  j j ƒ j ƒ  } t d t j |
 d  ƒ ƒ } t d t j |
 d  ƒ ƒ } t d |  j j ƒ j ƒ  } t d |  j j ƒ j ƒ  } t d t j | d  ƒ ƒ } t d t j | d  ƒ ƒ } t d |  j j j ƒ j ƒ  } t d |  j j j ƒ j ƒ  } t d t j |	 j  d | j	 ƒ  ƒ d  ƒ ƒ } t d |  j j! ƒ j ƒ  } |  j  d | IJ|  j  d	 | | f IJ|  j  d
 | | f IJ|  j  d | IJ|  j  d | | f IJ|  j  d | | f IJ|  j  d | | f IJ|  j  d | | f IJ|  j  d | | f IJd  S(   Ni   i   Ry   t   distance_cutoffs   %-7ds   %-7.2fRi   s     number           = %ss$     b_iso_min        = %s (limit = %s)s$     b_iso_max        = %s (limit = %s)s$     b_iso_mean       = %s             s$     anisotropy_min   = %s (limit = %s)s$     occupancy_min    = %s (limit = %s)s$     occupancy_max    = %s (limit = %s)s$     dist_sol_mol_min = %s (limit = %s)s$     dist_sol_mol_max = %s (limit = %s)("   R%   R   R+   R   R_   RL   R-   Rq   Rr   Ri   Rs   Rt   t   closest_distancesRy   R!   t   map_next_to_modelt   max_model_peak_distt   smallest_distancesR   R.   R   Rd   R   Re   t   mean_defaultR   R~   t   stripR   R€   R�   t   min_model_peak_distRu   R‚   (   RC   R   RX   t	   xrs_mac_ht	   xrs_sol_ht   hd_solt   hd_macRc   t   xrs_mact   scatR„   R…   R”   t   numbert   b_mint   b_maxt   b_avet   bl_mint   bl_maxt   o_mint   o_maxt   ol_mint   ol_maxt   d_mint   d_maxt   dl_mint   dl_maxt   ani_mint	   ani_min_l(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR2   V  sT    *	c         C   s\   |  j  j d |  j j d t ƒ t j d |  j  d | d | d |  j d t d d  d	 |  j
 ƒ S(
   NR   RK   R   R   R   R   t   use_kick_mapt   kick_map_paramsR%   (   R   RU   R   R   R#   R   R   R!   R$   R   R%   (   RC   R   R   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR   „  s    			c         C   se  |  j  j d |  j j d t ƒ t j j ƒ  } d | j _	 d | j _
 d | j _ d | j _ |  j j | _ t j d |  j  d d d | d	 | d
 |  j ƒ j ƒ  } | d  k	 ra|  j  j ƒ  d k ra| j | j } } |  j j j ƒ  } |  j j ƒ  } t j j d | d | d | d |  j j j ƒ  ƒ |  j j j d | ƒ |  j  j d |  j j d t ƒ n  d  S(   NR   RK   g{®Gáz„?g      à?R   R   s   2mFobs-DFmodelR   R   R%   Rj   t   sites_frac_peakst   water_selectionRi   Ry   (   R   RU   R   R   R#   R   R   R    R’   R—   t   min_peak_peak_distR“   t   peak_searcht   min_cross_distanceR!   t   resolution_factorR   R%   R7   R   t   r_workR(   R)   Ry   R+   Rv   Rw   R9   Ri   t   set_sites_frac(   RC   R   t   find_peaks_params_driftedRF   Ry   R)   t   model_sites_fracR+   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR9   ‘  s8    		!c         C   s  |  j  j r |  j d IJd  S|  j d I|  j j ƒ  j t ƒ IJ|  j  j |  j j k s` t ‚ t	 t
 |  j j ƒ  j ƒ  ƒ ƒ |  j j j ƒ  j ƒ  k sŸ t ‚ |  j j } |  j j ƒ  } |  j  j ƒ  } | j d | j d t d t ƒ } | j d | j d t d t ƒ } | j d d ƒ } | j ƒ  | j ƒ  } t j d	 | d
 | ƒ } | j ƒ  | j ƒ  }	 |  j  j j ƒ  }
 |  j  j j ƒ  } |  j j j ƒ  } t |  j j j ƒ  | ƒ s¸t ‚ |  j  j j ƒ  } x't | ƒ D]\ } } | r×t j  d | d | j! ƒ  d | j" ƒ  d t# j$ |
 | g ƒ d t# j% d g ƒ ƒ } t# j& d | j' | ƒ d |	 j' | ƒ ƒ j( ƒ  } | j) | | ƒ } |	 j) | | ƒ } | | j* k  s¾| | j+ k  s¾| | j+ k  rð| | j, ƒ  j- ƒ  j. ƒ  d k rðt | | <qðq×q×W|  j j ƒ  } |  j j j/ ƒ  } | j0 | t ƒ | j0 | t ƒ |  j j1 ƒ  } | d  k	 r£xO | D]D } | | d s}t | | d <n  | | d rXt | | d <qXqXWn  | j ƒ  | j t ƒ k rõ|  j j' | ƒ |  _ |  j  j3 d |  j j d t ƒ n  |  j d I|  j j ƒ  j t ƒ IJd  S(   NsE   Map CC and map value based filtering is disabled for twin refinement.s   Before RSCC filtering: R   t   fill_missingt
   isotropizeRµ   g      ð?i   t   crystal_griddingt   fourier_coefficientsRi   t
   fft_n_realt
   fft_m_realt
   sites_cartt
   site_radiig      ø?t   xt   yt   Ht   Di    i   R   RK   s   After RSCC filtering: g      Ð?(   RÄ   RÅ   (4   R   t   twinR%   R   R+   R,   R#   R   R   R   t   listt   pdb_hierarchyt   atoms_with_labelsR-   R.   R   R:   t   electron_density_mapt   map_coefficientst   cc_map_1_typeR$   R@   t   fft_mapt   apply_sigma_scalingt   real_map_unpaddedR   RÀ   Ry   R
   Ri   t	   enumerateR	   t   grid_indices_around_sitest   focust   allR   t   vec3_doublet   doublet   linear_correlationR_   t   coefficientt   eight_point_interpolationt   poor_cc_thresholdR;   t   element_symbolR–   t   upperRL   RP   Rƒ   R   RU   (   RC   t   parRJ   t	   e_map_objt   coeffs_1t   coeffs_2t	   fft_map_1t   map_1t	   fft_map_2t   map_2RÀ   Ry   R-   Ri   RG   t   sel_it   selt   cct   map_value_1t   map_value_2RX   RV   R‰   RŠ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyRA   °  s†    !						
		
!	"  
c         C   só  |  j  j d  k rà |  j j ƒ  } |  j j j | ƒ } |  j j j ƒ  j | ƒ } | j | ƒ } | j ƒ  t	 j
 d d } t j | d  ƒ } | d  k	 r® | |  j  j k  sÀ | |  j  j k rì |  j  j |  j  j d } qì n |  j  j } |  j  j d k r@t j |  j j ƒ  t j d |  j  j d | d |  j  j ƒ ƒ } n� |  j  j d k r»t j |  j j j ƒ  t j | ƒ ƒ } t j |  j j ƒ  t j d |  j  j d	 | d |  j  j ƒ ƒ } n t ‚ | j |  j ƒ t j d
 |  j j d | ƒ }	 |  j j j |  j j ƒ  ƒ }
 |  j j j |  j j ƒ  ƒ } |
 j d |	 ƒ }
 t j | j  ƒ  j ƒ  t! ƒ } | j" t j |
 j  ƒ  j ƒ  t# ƒ ƒ |  j j$ d |	 d |  j  j% d |  j  j& d |  j  j' d |  j  j( d |  j  j ƒ |  j) j* d |  j j d t# ƒ d  S(   Ni   i   g       @t	   isotropict	   occupancyt   bt   scattering_typeRI   t   ut   special_position_settingsR-   t   otherR\   R‹   RŒ   R�   R?   R>   R   RK   (+   R   t   b_isoR   R   R+   R   R_   RL   Rr   Rs   Rt   R   R•   R~   R   RO   t   xray_scattererR(   R.   R   t	   scattererRê   Rì   R   t   u_iso_as_u_starRi   t   b_as_uR1   t	   set_sitest	   structuret   concatenateR]   R-   R$   R^   R#   R�   R   R   R   R?   R   RU   (   RC   RX   R˜   R›   Rœ   Rë   t   b_solvt   new_scattererst   u_starR\   Rc   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR8   õ  s\     			%c   	      C   s  |  j  r|  j j r|  j j j r|  j j ƒ  j t ƒ d k r|  j	 j
 d |  j j d t d t ƒ |  j d |  j j ƒ  |  j j ƒ  f IJ|  j j j ƒ  } | } |  j j ƒ  } | } |  j j j ƒ  j ƒ  } |  j j d k rý | j | t ƒ n  |  j j j ƒ  j ƒ  } | j | t ƒ | j | t ƒ |  j sa| j | t ƒ | j | t ƒ n  | j | t ƒ | j | t ƒ |  j j d | d | ƒ t j j d	 d
 ƒ } t j d d  d |  j	 d |  j d |  j d t d | ƒ } |  j d |  j j ƒ  |  j j ƒ  f IJn  d  S(   Ni    R   RK   t   update_f_masks<   ADP refinement (water only), start r_work=%6.4f r_free=%6.4fRI   RZ   R[   t   max_iterationsi   t   restraints_managerRD   R   RE   R>   t   lbfgs_termination_paramss<   ADP refinement (water only), final r_work=%6.4f r_free=%6.4f(   R   R   R>   R   t   refinement_flagst   individual_adpR+   R,   R#   RD   RU   R   R%   R   R¶   t   r_freeRL   RM   RN   RO   RP   RQ   R$   RE   t   set_refine_individual_adpt   scitbxt   lbfgst   termination_parametersR   R   (	   RC   RV   RW   RX   RY   RZ   R[   Rþ   t	   minimized(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR>   &  sN    							c         C   sœ  |  j  r˜|  j j r˜|  j j j r˜|  j j ƒ  j t ƒ d k r˜|  j	 j
 d |  j j d t d t ƒ |  j d |  j j ƒ  |  j j ƒ  f IJ|  j	 j ƒ  j j ƒ  j d t ƒ |  j j ƒ  j ƒ  } |  j	 j ƒ  j j ƒ  j d | ƒ t j j d d	 ƒ } t j j j d
 d  d |  j	 d |  j d |  j d | ƒ } |  j	 j ƒ  j j d |  j j d |  j j  d | ƒ |  j d |  j j ƒ  |  j j ƒ  f IJn  d  S(   Ni    R   RK   Rû   sB   occupancy refinement (water only), start r_work=%6.4f r_free=%6.4ft   stateRT   Rü   i   Rý   RD   R   RE   Rþ   t   occ_maxt   occ_minRJ   (!   R   R   R?   R   Rÿ   t   occupanciesR+   R,   R#   RD   RU   R   R%   R   R¶   R  t   fmodel_xrayR-   t   flags_set_gradsR$   RT   t   flags_set_grad_occupancyR  R  R  Rv   t
   refinementR   R   RE   t   adjust_occupancyR�   R€   (   RC   t   i_selectionRþ   R  (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR?   P  s<    					N(   t   __name__t
   __module__R   R    R   RH   RB   R/   R0   R4   R`   R2   R   R9   RA   R8   R>   R?   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyR   œ   s   K			
	1		.			E	1	*t    c   	      C   s²   | d  k r t j } n  | | IJt j d |  d | ƒ } | j ƒ  } x[ t | j ƒ  ƒ D]G \ } } | j ƒ  | j ƒ  | d } | d | | | f IJ| } qY W| j	 ƒ  | S(   Nt   datat   n_slotsi   s   %7.3f - %7.3f: %d(
   R   R&   R'   R   t	   histogramt   data_minRÐ   t   slotst
   slot_widtht   flush(	   R  R  t   outt   prefixR  t
   low_cutoffRG   t   nt   high_cutoff(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyt   show_histogramq  s     
	

($   t
   __future__R    t   cctbx.array_familyR   t   cctbxR   Rs   R&   t   libtbxR   R   t   iotbx.xplor.mapR   t
   iotbx.philt   libtbx.str_utilsR   Rv   R   t   mmtbx.refinementR   t   scitbx.lbfgsR  t   mmtbx.utilsR   R	   t   libtbx.test_utilsR
   t   output_params_strt   h_bond_params_strt   adp_occ_params_strR   R   t   objectR   R   R   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/solvent/ordered_solvent.pyt   <module>   s0   )>	ÿ Ø