ó
¨™xTc           @   sÝ  d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d d l	 m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l Z d e j f d „  ƒ  YZ d e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ  d e j f d „  ƒ  YZ! d e j f d „  ƒ  YZ" d  e j f d! „  ƒ  YZ# d" e j f d# „  ƒ  YZ$ d S($   s»   
Collect multiple analyses of experimental data quality, including
signal-to-noise ratio, completeness, ice rings and other suspicious
outliers, anomalous measurability, and Wilson plot.
iÿÿÿÿ(   t   division(   t   absolute_scaling(   t   scaling(   t
   data_plots(   t   miller(   t   adptbx(   t   flex(   t   chebyshev_polynome(   t   chebyshev_lsq_fit(   t   erf(   t   approx_equal(   t   Sorry(   t   table_utilsNt   i_sigi_completeness_statsc           B   s,   e  Z d  Z d d d d d „ Z d „  Z RS(   s{   
  Collects resolution-dependent statistics on I/sigma expressed as percentage
  of reflections above specified cutoffs.
  i   g      @g333333ë?g      @c            s   ˆ  j  ƒ  j ˆ  ƒ ‰  t |  _ ˆ  j ƒ  rQ ˆ  j ƒ  rQ t |  _ ˆ  j ƒ  ‰  qQ n  ˆ  j ƒ  sc t	 ‚ ˆ  j
 ƒ  d  k	 s{ t	 ‚ ˆ  j d | ƒ t ˆ  j ƒ  j ƒ  ƒ |  _ ˆ  j d t ƒ |  _ ˆ  j d t ƒ j d d !|  _ g  |  _ ‡  f d †  } g  } d d d d d	 d
 g } x$ | D] }	 |  j j | |	 ƒ ƒ qWd d d d d d d g }
 t j d d d d d g |
 d d d d g d g d d d g d d' g d  t t d d! ƒ ƒ g d" t d# t ƒ |  _ x‡ t d t |  j ƒ d ƒ D]i } |  j | d } |  j | } | | g } x& |  j D] } | j d$ | | ƒ qW|  j j | ƒ qåW| |  _ | |  _ | |  _  d% |  _! | | ƒ } d% } xq t d t |  j ƒ d ƒ D]S } |  j | d } |  j | } | | k  r¥| | | k rø| d& |  _! qøq¥q¥Wd  S((   Nt   n_binst   use_binningi   iÿÿÿÿc            sQ   ˆ  j  ˆ  j ƒ  |  ˆ  j ƒ  k ƒ } | j ˆ  ƒ | j d t d d ƒ } | j S(   NR   t   return_failg        (   t   selectt   datat   sigmast   use_binning_oft   completenesst   True(   t	   cut_valuet
   tmp_millerR   (   t   miller_array(    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   cut_completeness4   s    	i   i   i   i
   i   s
   Res. Ranges	   I/sigI>1 s	   I/sigI>2 s	   I/sigI>3 s	   I/sigI>5 s	   I/sigI>10s	   I/sigI>15t   titles   Completeness and data strengtht   column_labelss   Low res.s	   High res.t   column_formatss   %4.2fs   %5.1fi   t   graph_namess   I/sigI by shellt   graph_labelss   High resolution of shells
   % of totalt   graph_columnsi   t   x_is_inverse_d_mint    first_two_columns_are_resolutiong      Y@g      @g      à¿(   s   High resolution of shells
   % of total("   t	   deep_copyt   set_observation_typet   Falset   amplitudes_flagt   is_real_arrayt   is_xray_amplitude_arrayR   t	   f_as_f_sqt   is_xray_intensity_arrayt   AssertionErrorR   t   Nonet   setup_binnert   listt   binnert   limitst   resolution_binsR   t   overallR   t   overall_binnedt   completeness_binst   appendR   t
   table_datat   ranget   tablet   xranget   lent   add_rowt	   isigi_cutt   completeness_cutt   resolution_at_leastt   resolution_cut(   t   selfR   R   R<   R=   R>   R   R6   t   cut_listR   t   legendt   iit   at   bt   rowt   jjt	   comp_datat   reso(    (   R   sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   __init__   s`    						#				#c         C   sº   | j  d ƒ | j d ƒ |  j r3 | j d ƒ n  | j |  j d d ƒ| j |  j ƒ d |  j |  j d |  j	 f } |  j	 |  j
 k  r˜ | d 7} n | d	 |  j
 7} | j | ƒ d  S(
   Ns   Completeness at I/sigma cutoffssg  
 The following table lists the completeness in various resolution ranges,
 after applying a I/sigI cut. Miller indices for which individual I/sigI
 values are larger than the value specified in the top row of the table, are
 retained, while other intensities are discarded. The resulting completeness
 profiles are an indication of the strength of the data.
sØ   Please be aware that the input data were given as amplitudes and squared for
the purposes of this analysis, therefore the numbers displayed here are less
reliable than the values calculated from the raw intensities.
t   indenti   sn     The completeness of data for which I/sig(I)>%.2f, exceeds %.0f %%
  for resolution ranges lower than %.2fA.
id   s_     The data are cut at this resolution for the potential twin tests and
  intensity statistics.
s„     As we do not want to throw away too much data, the resolution for
  analyzing the intensity statistics will be limited to %3.2fA.
(   t   show_sub_headert	   show_textR&   t   warnt
   show_tableR8   t	   show_plotR<   R=   R?   R>   (   R@   t   outt   message(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt
   _show_impl_   s    	
 
(   t   __name__t
   __module__t   __doc__RJ   RS   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyR      s   =t   completeness_enforcementc           B   s   e  Z d  d „ Z RS(   g      è?c         C   sÎ   | j  ƒ  |  _ |  j j d t ƒ |  j j d t d d ƒ } t j |  j j ƒ  j ƒ  t	 ƒ } xW | j
 j ƒ  D]F } | j
 j | ƒ j ƒ  } | j | | k rn | j | t ƒ } qn qn W| j | ƒ |  _ d  S(   Nt   auto_binningR   R   g      ð?(   R#   R   t   setup_binner_d_star_sq_stepR   R   R   t   boolt   indicest   sizeR%   R/   t	   range_allt	   selectiont
   iselectionR   t   set_selectedR   t
   new_miller(   R@   R   t   minimum_completenessR   t   selection_arrayt   binR^   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   „   s    	!(   RT   RU   RJ   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRW   ƒ   s   t   analyze_resolution_limitsc           B   s8   e  Z d  Z d d „ Z d „  Z d d „ Z d „  Z RS(   sN  
  Check for elliptical truncation, which may be applied to the data by some
  processing software (or as a post-processing step).  As a general rule this
  is not recommended since phenix.refine and related programs will handle
  anisotropy automatically, and users tend to apply it blindly (and even
  deposit the modified data).
  g      Ð?c         C   s[  | j  ƒ  } | j ƒ  j ƒ  d d k rñ t j ƒ  } x~ | j ƒ  D]p \ } } } | d k rt | d k rt | d k s˜ | d k rA | d k rA | d k rA | j | | | f ƒ qA qA Wt | t j	 ƒ rÜ | j
 d | ƒ } qý | j d | ƒ } n | j  ƒ  } | j ƒ  |  _ t |  j | j ƒ  d d ƒs0t ‚ | j ƒ  \ |  _ |  _ |  _ | |  _ d  S(   Ni   iZ   i    R[   t   epsgš™™™™™¹?(   iZ   iZ   iZ   (   t   expand_to_p1t	   unit_cellt
   parametersR   t   miller_indexR[   R5   t
   isinstanceR   t   arrayt   sett   customized_copyt   d_mint   d_min_overallR
   R+   t   d_min_along_a_b_c_start   d_min_at   d_min_bt   d_min_ct   d_min_max_delta(   R@   t
   miller_setRu   R   t   all_pos_neg_indicest   ht   kt   l(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   Ÿ   s    H$c         C   st   |  j  |  j |  j g } d } xO t d ƒ D]A } x8 t | d ƒ D]' } t | t | | | | ƒ ƒ } qA Wq+ W| S(   sD   
    Return the maximum difference in d_min along any two axes.
    i    i   i   (   Rr   Rs   Rt   R7   t   maxt   abs(   R@   R0   t	   max_deltat   it   j(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   max_d_min_delta·   s    )c         C   s(   | d  k r |  j } n  |  j ƒ  | k S(   N(   R,   Ru   R€   (   R@   Ru   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   is_elliptically_truncatedÂ   s    c         C   s‚   | j  d ƒ | j d ƒ |  j ƒ  } | j d |  j |  j |  j |  j | f ƒ | |  j k rq | j d ƒ n | j d ƒ d  S(   Ns   Analysis of resolution limitss´  Your data have been examined to determine the resolution limits of the data
along the reciprocal space axes (a*, b*, and c*).  These are expected to vary
slightly depending on unit cell parameters and overall resolution, but should
never be significantly different for complete data.  (This is distinct from the
amount of anisotropy present in the data, which changes the effective
resolution but does not actually exclude reflections.)sÉ   
    overall d_min                = %.3f
    d_min along a*               = %.3f
    d_min along b*               = %.3f
    d_min along c*               = %.3f
    max. difference between axes = %.3f
s  The resolution limit appears to be direction-dependent, which may indicate
issues with the data collection geometry, processing errors, or that elliptical
truncation has been applied.  We do not recommend using elliptically truncated
data, as anisotropy is handled automatically by Phaser, phenix.refine, and
related programs, and discarding large numbers of weak reflections may result
in increased map bias and/or artifacts.  You should always deposit the original,
uncorrected reflections in the PDB, not the truncated data.s1   Resolution limits are within expected tolerances.(	   RL   RM   R€   t   show_preformatted_textRp   Rr   Rs   Rt   Ru   (   R@   RQ   R}   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS   Ç   s    
N(   RT   RU   RV   RJ   R€   R,   R�   RS   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRe   —   s
   	t   log_binned_completenessc           B   s)   e  Z d  Z d d d d „ Z d „  Z RS(   s?   
  Table of completeness using log-scale resolution binning.
  id   i   i2   c         C   sæ   g  } | j  d | d | d | ƒ } x— | D]� } | j | ƒ } | j ƒ  \ }	 }
 | j ƒ  } | j d |	 ƒ j ƒ  } | j d |	 ƒ } | j d |	 |
 f d | | f d | d f ƒ q+ Wt j d	 d
 d d g d | ƒ |  _	 d  S(   Nt&   n_reflections_in_lowest_resolution_bint   max_number_of_binst   min_reflections_in_bint   d_maxs   %.4f - %.4fs   %d/%ds   %.1f%%id   t   column_headerst
   Resolutiont   Reflectionst   Completenesst
   table_rows(
   t   log_binningR   t	   d_max_minR\   t   complete_setR   R5   R   t   simple_tableR8   (   R@   R   R„   R…   R†   t   rowst   binsR^   t	   bin_arrayR‡   Ro   t   n_reflt   n_refl_expectR   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   ê   s     			c         C   s.   | j  d ƒ | j d ƒ | j |  j ƒ d  S(   Ns   Completeness (log-binning)s  The table below presents an alternative overview of data completeness, using
the entire resolution range but on a logarithmic scale.  This is more sensitive
to missing low-resolution data (and is complementary to the separate table
showing low-resolution completeness only).(   RL   RM   RO   R8   (   R@   RQ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS      s    (   RT   RU   RV   RJ   RS   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRƒ   æ   s
   t   possible_outliersc           B   sJ   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(	   su   
  Flag specific reflections with suspicious intensities.  Inspired by:
  Read, Acta Cryst. (1999). D55, 1759-1764
  gš™™™™™¹?g�íµ ÷Æ°>c         C   s€  | j  ƒ  d  k r! t d ƒ ‚ n  | j ƒ  s< | j ƒ  } n | j ƒ  } | j ƒ  sZ t ‚ | j ƒ  } t j | d t	 ƒ} | j
 d | j j ƒ  | j ƒ  j ƒ  j ƒ  ƒ } | j ƒ  |  _ | j ƒ  j | ƒ } | j ƒ  j | ƒ } | j ƒ  j d ƒ s t ‚ d d t j | j ƒ  ƒ } d t t j | j ƒ  d ƒ ƒ }	 |	 j ƒ  }
 | j ƒ  } d t j d t j | j ƒ  ƒ t | ƒ ƒ } d t j t t j | j ƒ  d ƒ ƒ t |
 ƒ ƒ } | | k  pÓ| | k  } | | k  pë|	 | k  } | j ƒ  j | ƒ |  _ | j ƒ  j | ƒ |  _ t j |  j ƒ |  _ | j ƒ  j ƒ  j | ƒ |  _  | j | ƒ |  _! | j | ƒ |  _" t# j$ d d d	 d
 d d d d g d d d d d d g d d g d d d d d d g g ƒ |  _% x] t& |  j  |  j |  j |  j! |  j" ƒ D]4 \ } } } } } |  j% j' | | | | | g ƒ qýW| j ƒ  j | ƒ |  _( | j ƒ  j | ƒ |  _) t j |  j) ƒ |  _) | j ƒ  j ƒ  j | ƒ |  _* |	 j | ƒ |  _+ | j | ƒ |  _, t# j$ d d d	 d
 d d d d g d d d d d d g d d g d d d d d d g g ƒ |  _- x] t& |  j* |  j( |  j) |  j+ |  j, ƒ D]4 \ } } } } } |  j- j' | | | | | g ƒ qDWd  S(   Ns   Unknown observation typet   auto_kernelR   i    g      ð?g       @R   s   Acentric reflectionsR   t	   d_spacings   H K Ls   |E|s	   p(wilson)s
   p(extreme)R   s   %8.3fs   %5i,%5i,%5is   %6.2fs   %9.2es   %10.2eR   s   Possible acentric outliersR    i   i   i   i   s   Centric reflectionss   Possible centric outliers(.   t   observation_typeR,   R   R*   R)   R#   R+   R   t   kernel_normalisationR   Rl   t   normalised_millerR   t   epsilonst	   as_doubleR\   R”   t   select_centricR$   t   select_acentrict   all_geR   t   expR	   t   sqrtt   powt   floatR[   R   t   acentric_outlier_millert   acentric_outlier_e_valst
   d_spacingst   acentric_outlier_d_spacingst   acentric_outlier_p_valt   acentric_outlier_extreme_valR   R6   t   acentric_outliers_tablet   zipR;   t   centric_outlier_millert   centric_outlier_e_valst   centric_outlier_d_spacingst   centric_outlier_p_valt   centric_outlier_extreme_valt   centric_outliers_table(   R@   R   t   prob_cut_ext   prob_cut_wilt
   work_arrayt
   normalizert   centric_cutt   acentric_cutt   p_acentric_singlet   p_centric_singlet	   n_centrict
   n_acentrict   extreme_acentrict   extreme_centrict   acentric_outliert   centric_outliert   dt   hklt   et   pt   extr(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ     s�    		#-2		#		c         C   s   |  j  ƒ  |  j S(   N(   t
   n_outliersR”   (   R@   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   fraction_outlierse  s    c         C   s&   |  j  j ƒ  } |  j j ƒ  } | | S(   N(   R¥   R\   R­   (   R@   R¼   R»   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRÆ   h  s    c         C   sj   t  j | j ƒ  |  j ƒ } | j | j d ƒ ƒ } t  j | j ƒ  |  j ƒ } | j | j d ƒ ƒ } | S(   Ni    (   R   t   match_indicesR[   R­   R   t   single_selectionR¥   (   R@   R   t   centric_matchest   acentric_matches(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   remove_outliersm  s    c         C   sâ   | j  d ƒ | j d ƒ | j d ƒ |  j j ƒ  d k rL | j d ƒ n0 | j |  j d d ƒ| j d ƒ | j d	 ƒ | j d
 ƒ |  j j ƒ  d k r® | j d ƒ n0 | j |  j d d ƒ| j d ƒ | j d ƒ d  S(   Ns   Possible outlierss8     Inspired by: Read, Acta Cryst. (1999). D55, 1759-1764
s   Acentric reflections:i    s               None
RK   i   sP   

 p(wilson)  : 1-(1-exp[-|E|^2])
 p(extreme) : 1-(1-exp[-|E|^2])^(n_acentrics)
si  
 p(wilson) is the probability that an E-value of the specified value would be
 observed if it were selected at random the given data set. p(extreme) is the
 probability that the largest |E| value is larger or equal than the observed
 largest |E| value.

 Both measures can be used for outlier detection. p(extreme) takes into
 account the size of the dataset.
s   Centric reflections:sV   

 p(wilson)  : 1-(erf[|E|/sqrt(2)])
 p(extreme) : 1-(erf[|E|/sqrt(2)])^(n_acentrics)
sr  
 p(wilson) is the probability that an E-value of the specified
 value would be observed when it would selected at random from
 the given data set.
 p(extreme) is the probability that the largest |E| value is
 larger or equal than the observed largest |E| value.

 Both measures can be used for outlier detection. p(extreme)
 takes into account the size of the dataset.
(	   RL   t   showR¥   R\   RO   R«   R‚   R­   R²   (   R@   RQ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS   w  s$    	c         C   s$   |  j  ƒ  d k r d g Sd g Sd  S(	   Ngü©ñÒMbP?i   s1   There are a large number of outliers in the data.s   Possible outliersi    s7   The fraction of outliers in the data is less than 0.1%.(   i   s1   There are a large number of outliers in the data.s   Possible outliers(   i    s7   The fraction of outliers in the data is less than 0.1%.s   Possible outliers(   RÇ   (   R@   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   summarize_issues¡  s
      (	   RT   RU   RV   RJ   RÇ   RÆ   RÌ   RS   RÎ   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyR–     s   R			
	*t   ice_ring_checkerc           B   s2   e  Z d  Z d d d d „ Z d „  Z d „  Z RS(   s“   
  Check intensity and completeness statistics in specific resolution ranges
  known to have strong diffraction when crystalline ice is present.
  g      @gš™™™™™¹?i
   c         C   s›  | |  _  | |  _ | |  _ t j d d d d d d d d d	 d
 g
 ƒ |  _ t j d d d d d d d d d d g
 ƒ |  _ d  d  d  d  d  d  d  d  d  d  g
 |  _ d  |  _	 d  |  _
 | d } | | j ƒ  d } | d | d }	 d }
 t j | j ƒ  d ƒ } xÿ |  j D]ô } d | d } | | } | |	 d |	 } t | d ƒ d } | d k  red  } n  | | j ƒ  d k r„d  } n  | |  j |
 <|
 d 7}
 | d  k	 rd | | <| d d k rÒd | | d <n  | d | j ƒ  d k r d | | d <q qqWt j | | ƒ } | t j | ƒ } t j | | | ƒ } | t j | ƒ } t j | | | ƒ } t j | | ƒ } | t j | ƒ } t j | | | ƒ } | t j | ƒ } t j | | | ƒ } | |  _	 | |  _
 | |  _ | |  _ t j d d ƒ |  _ t j d d ƒ |  _ t j d d ƒ |  _ t j d d ƒ |  _ xÞ t d ƒ D]Ð } |  j | d  k	 rW| |  j | |  j | <| |  j | |  j | <|  j | c | 8<|  j | c | d <| |  j | |  j | <| |  j | |  j | <|  j | c | 8<|  j | c | d <qWqWWd |  _ g  } x� t d ƒ D]s } |  j | d  k	 rG| j d |  j | d t |  j | ƒ d t |  j | ƒ d t |  j | ƒ g ƒ qGqGWt j d | d  d! d" d# d$ g ƒ |  _ d |  _ |  j  } x� t d ƒ D]� } |  j | d  k	 r|  j | |  j k rt |  j | ƒ } | | k s~|  j | | k s~t |  j | ƒ | k r“|  j d 7_ q“qqWd  S(%   Ng“V-@g'1¬Z@gºI+‡@g‘í|?5^@gË¡E¶óý@gú~j¼t“ @g^ºI+ÿ?gã¥›Ä °þ?gTã¥›Ä þ?gð§ÆK7‰û?g      ð?g      è?gö(\�Âõà?gÃõ(\�ÂÅ?gö(\�ÂõØ?g333333Ó?g{®Gáz¤?g
×£p=
Ç?g¸…ëQ¸ž?g{®Gáz”?i    i   g       @g      à?g        i
   g�íµ ÷Æ°>s   %9.3fs   %10.3fs   %7.2fRŒ   Rˆ   R˜   s   Expected rel. Is   Data Z-scoreR‹   (   t   completeness_abnormality_levelt   intensity_levelt   z_score_limitR   t   doublet   ice_d_spacingst   ice_rel_intensR,   t   ice_ring_bin_locationt	   mean_compt   mean_z_scoreR\   t   intt   sumt   mathR¢   t   std_compt   std_z_scoret   abnormality_intensityt   value_intensityt   abnormality_completenesst   value_completenessR7   t   warningsR5   R|   R   R�   R8   (   R@   t   bin_centerst   completeness_datat   z_scores_dataRÐ   RÑ   RÒ   t   tmp_low_d_star_sqt   tmp_high_d_star_sqt   tmp_stept   countt   weightst   ice_ringt   tmp_ice_ringt   tmp_ice_ring_binRØ   RÝ   R×   RÜ   RC   t
   icy_shellst   cutoffRà   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   °  s°    					

		

					"			c         C   s"  | j  d ƒ | j d ƒ | j d |  j |  j |  j |  j f ƒ | j d ƒ | j |  j d d ƒ| j d |  j	 ƒ t
 } |  j } x7t d ƒ D])} |  j | d  k	 r– |  j | |  j	 k r– t |  j | ƒ } | | k r;t } | j d	 |  j | ƒ t |  j | ƒ | k r+| j d
 ƒ q;| j d ƒ n  t |  j | ƒ | k syt |  j | ƒ t |  d d ƒ k r¿t } t |  j | ƒ | k r¼| j d |  j | | f ƒ q¼q¿q– q– W| sÙ| j d ƒ n  |  j d k rø| j d ƒ n& |  j d k r| j d |  j ƒ n  d  S(   Ns   Ice ring related problemssV    The following statistics were obtained from ice-ring insensitive resolution
 ranges:
sŒ       mean bin z_score      : %4.2f
        ( rms deviation   : %4.2f )
    mean bin completeness : %4.2f
        ( rms deviation   : %4.2f )
sr   The following table shows the Wilson plot Z-scores and completeness for
 observed data in ice-ring sensitive areas.  The expected relative intensity
 is the theoretical intensity of crystalline ice at the given resolution.
 Large z-scores and high completeness in these resolution ranges might
 be a reason to re-assess your data processsing if ice rings were present.
RK   i   s‹    Abnormalities in mean intensity or completeness at resolution ranges with a
 relative ice ring intensity lower than %3.2f will be ignored.i
   sU    At %3.2f A there is an lower occupancy than expected from the rest of the
 data set.sY    At the same resolution range, the expected mean intensity does not behave as
 it should.so    Even though the completeness is lower as expected, the mean intensity is
 still reasonable at this resolution.RÒ   s’    At %3.2f A the z-score is more than %3.2f times the standard deviation of
 all z-scores, while at the same time, the occupancy does not go down.
s©    No ice ring related problems detected.
 If ice rings were present, the data does not look worse at ice ring related
 d_spacings as compared to the rest of the data set.i   s|    As there was only 1 ice-ring related warning, it is not clear whether or not
 ice ring related features are really present.sZ    There were %d ice ring related warnings.  This could indicate the presence of
 ice rings.(   RL   RÍ   R‚   RØ   RÝ   R×   RÜ   RO   R8   RÑ   R%   RÐ   R7   RÖ   R,   RÕ   R|   Rà   R   RÔ   RÞ   Rß   t   getattrRâ   (   R@   RQ   t   problems_detectedRï   RC   Rà   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS     sR    #	

%%

c         C   s!   |  j  d k r d g Sd g Sd  S(   Ni    i   s.   The data appear to have one or more ice rings.s   Ice ring related problemss&   Ice rings do not appear to be present.(   i   s.   The data appear to have one or more ice rings.s   Ice ring related problems(   i    s&   Ice rings do not appear to be present.s   Ice ring related problems(   Râ   (   R@   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRÎ   [  s
      (   RT   RU   RV   RJ   RS   RÎ   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRÏ   «  s   c	Bt   analyze_measurabilityc           B   s#   e  Z d d  d d „ Z d „  Z RS(   g¸…ëQ¸ž?g¸…ëQ¸®?c         C   s©  | | k } | | k } | j  | ƒ }	 | j  | ƒ }
 d  |  _ d  |  _ d  d  g g } |	 j ƒ  d k r™ t j |	 ƒ d |  _ t j |	 ƒ | d d <n  |
 j ƒ  d k rÛ t j |
 ƒ d |  _ t j |
 ƒ | d d <n  d  |  _ | d  k	 r0| j ƒ  } | j	 d d ƒ | j
 d t ƒ j d d ƒ |  _ n  t j d	 d
 d d d d g d d g d d g d d d d g g d t | ƒ t | ƒ t | ƒ g d t d | ƒ |  _ d  S(   Ni    g      à¿i   R   i
   R   t
   data_labelt   MeasurabilityR   s!   Measurability of Anomalous signalR   s
   1/resol**2s   Smooth approximationR   s   Anomalous measurabilityR   R‰   R    i   R   R!   t   reference_marks(   s
   ResolutionRô   (   R   R,   t	   low_d_cutt
   high_d_cutR\   R   R{   t
   meas_tableR#   R-   t   measurabilityR   t   as_simple_tableR   R6   R.   R8   (   R@   t	   d_star_sqt   smooth_approxt	   meas_dataR   t   low_level_cutt   high_level_cutt   low_level_ranget   high_level_ranget   tmp_lowt   tmp_hight	   ref_marksRµ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   f  s8    							!c         C   sœ  | j  d ƒ d  } |  j |  j g j d  ƒ } | d k rÁ d  } |  j |  j k r[ d } q|  j |  j k  rd |  j |  j f } |  j d k  rŸ | d 7} q¾ |  j d k r¾ | d 7} q¾ qnO | d	 k rÖ d
 } n: | d k r
|  j d  k rd |  j } qd } n d } | d  k	 r,| j | ƒ n  |  j d  k	 r˜| j d ƒ | j |  j d d	 ƒ| j d ƒ | j d ƒ | j d ƒ | j	 |  j
 ƒ n  d  S(   Ns!   Measurability of anomalous signali    sõ    The full resolution range seems to contain a useful ammount of anomalous
 signal. Depending on your specific substructure, you could use all the data
 available for the location of the heavy atoms, or cut the resolution
 to speed up the search.sß    The anomalous signal seems to extend to about %3.1f A (or to %3.1f A, from a
 more optimistic point of view).  The quoted resolution limits can be used as a
 guideline to decide where to cut the resolution for phenix.hyss.g      @s‹   
 Depending however on the size and nature of your substructure you could cut
 the data at an even lower resolution to speed up the search.g      @s  
 As the anomalous signal is not very strong in this dataset substructure
 solution via SAD might prove to be a challenge.  Especially if only low
 resolution reflections are used, the resulting substructures could contain a
 significant amount of false positives.i   sM    There seems to be no real significant anomalous differences in this dataset.i   sÆ    The anomalous signal seems to extend to about %3.1f A, but doesn't seem very
 strong. The quoted resolution limits can be used as a guideline to decide
 where to cut the resolution for phenix.hyss.sZ    This should not have happend: please contact software authors at
 bugs@phenix-online.org.s5   
Table of measurability as a function of resolution:
RK   s„   
 The measurability is defined as the fraction of Bijvoet related intensity
 differences for which the following relationship holds:sS   
    |delta_I|/sigma_delta_I > 3.0
    min[I(+)/sigma_I(+), I(-)/sigma_I(-)] > 3.0
s�    The measurability provides an intuitive feeling of the quality of the data,
  as it is related to the number of reliable Bijvoet differences.  When the
  data are processed properly and the standard deviations have been estimated
  accurately, values larger than 0.05 are encouraging.  Note that this
  analysis relies on the correctness of the estimated standard deviations of
  the intensities.
(   RL   R,   Rö   R÷   Ré   RÍ   Rø   RO   R‚   RP   R8   (   R@   RQ   RR   t   unknown_cutoffs(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS   Š  sF    	
		N(   RT   RU   R,   RJ   RS   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRò   e  s   t   data_strength_and_completenessc           B   sA   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   si   
  Collect basic info about overall completeness and signal-to-noise ratios,
  independent of scaling.
  g      @g333333ë?c         C   sþ  | j  ƒ  } | j d t ƒ | j ƒ  j d ƒ |  _ d  |  _ d  |  _ | j	 ƒ  d  k	 r| j
 d t d d ƒ } | j d t | j ƒ d !|  _ t j |  j ƒ |  _ t j d d d	 d
 d g d d g d d! g d d d g g d |  j |  j g d t ƒ |  _ n  d  |  _ | j	 ƒ  d  k	 r;t | d | d | ƒ|  _ n  | j ƒ  |  _ | j d d ƒ } d  |  _ d  |  _ d  |  _ | j ƒ  j ƒ  d k r»| j d d ƒ | j d t ƒ |  _ | j d t ƒ } | j d d ƒ |  _ | j } g  }	 g  }
 xk | j ƒ  D]] } | j | ƒ } |	 j  d | d ƒ | j | } | d  k rId } n  |
 j  | d ƒ qýWt j d d d	 d d g d d g d d" g d d d g g d |	 |
 g d t d  t ƒ |  _ n  y t! | ƒ |  _" Wn t# k
 rêd  |  _" n Xt$ | ƒ |  _% d  S(#   NRX   i   R   R   i    i   R   s   Signal to noise (<I/sigma_I>)R   s
   1/resol**2s   <I/sigma_I>R   s   Signal to noiseR   R‰   R    R   R!   R<   R=   Ro   g      @R   i
   Ró   R‹   id   s   Low-resolution completenesss   Max. resolutions   High resolution of shells
   % of totalt   force_exact_x_labels(   s
   Resolutions   <I/sigma_I>(   s   High resolution of shells
   % of total(&   R#   RY   R   R/   Rã   t   d_star_sq_oriR,   t   i_sig_it   i_sig_i_tableR   t   i_over_sig_iR   R:   R   RÓ   R   R6   t   data_strengthR   R   t   completeness_overallt   resolution_filtert   low_resolution_completenesst#   low_resolution_completeness_overallt   low_res_tableR[   R\   R-   R%   Rú   t
   range_usedt	   bin_d_minR5   Re   t   d_min_directionalR+   Rƒ   t
   log_binned(   R@   R   R<   R=   R   t   i_over_sigmat   tmp_miller_lowresR  R/   R  t   compt   i_binRo   t   frac(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   Ø  sv    			 														c         C   s§   | j  d ƒ |  j d  k	 r/ |  j j | ƒ n  |  j d  k	 rq | j d ƒ | j d ƒ | j |  j d d ƒn  |  j j | ƒ |  j d  k	 r£ |  j j | ƒ n  d  S(   Ns   Data strength and completenesss$   Low resolution completeness analysessb  The following table shows the completeness of the data to 5.0 A.  Poor
low-resolution completeness often leads to map distortions and other
difficulties, and is typically caused by problems with the crystal orientation
during data collection, overexposure of frames, interference with the beamstop,
or omission of reflections by data-processing software.RK   i   (	   t   show_headerR  R,   RÍ   R  RL   RO   R  R  (   R@   RQ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS     s    c         C   sC   |  j  d  k r d  S|  j  j |  j  j k r5 |  j  j S|  j  j Sd  S(   N(   R  R,   R?   R>   (   R@   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   high_resolution_for_twin_tests0  s    	
c         C   s   |  j  d  k	 r |  j  d Sd  S(   Niÿÿÿÿ(   R	  R,   (   R@   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   i_over_sigma_outer_shell9  s    c         C   s  g  } |  j  j ƒ  r% | j d ƒ n | j d ƒ d |  j k  oL d k  n rn | j d d d	 d
 f ƒ nV d |  j k oˆ d k  n rª | j d d d	 d
 f ƒ n | j d d d d
 f ƒ |  j d k  rã | j d ƒ n, |  j d k  r| j d ƒ n | j d ƒ | S(   Ni   s4   The data appear to have been elliptically truncated.s   Analysis of resolution limitsi    s>   The resolution cutoff appears to be similar in all directions.g      è?i   s2   The overall completeness in low-resolution shells s   is less than 90%.s$   Low resolution completeness analysesgÍÌÌÌÌÌì?s   is at least 90%.s&   Overall completeness is less than 75%.s&   Overall completeness is less than 90%.s"   Overall completeness is above 90%.(   i   s4   The data appear to have been elliptically truncated.s   Analysis of resolution limits(   i    s>   The resolution cutoff appears to be similar in all directions.s   Analysis of resolution limits(   i   s&   Overall completeness is less than 75%.N(   i   s&   Overall completeness is less than 90%.N(   i    s"   Overall completeness is above 90%.N(   R  R�   R5   R  R  R,   (   R@   t   issues(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRÎ   >  s*    
 (   RT   RU   RV   RJ   RS   R  R  RÎ   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyR  Ó  s   D				t	   anomalousc           B   s   e  Z d d  „ Z d „  Z RS(   c      	   C   sy  | j  ƒ  s t ‚ | j ƒ  } | j d t ƒ | j ƒ  j d ƒ |  _ d  |  _	 | d  k	 rj | j	 |  _	 n  d  |  _
 | j ƒ  d  k	 ru| j
 d t d d ƒ } t j | j d t | j ƒ d !ƒ } t j t |  j j ƒ  d ƒ d |  j | ƒ } t t |  j j ƒ  d ƒ d t j |  j ƒ t j |  j ƒ | j ƒ } | j |  j ƒ } t d	 |  j d
 | d | d | ƒ |  _
 n  d  S(   NRX   i   R   R   i    i   i
   i   Rû   Rü   Rý   R   (   t   anomalous_flagR+   R#   RY   R   R/   Rã   R  R,   t   cc_anom_tableRù   R   R   RÓ   R   R:   R   RÙ   R\   R   t   minR{   t   coefst   fRò   (   R@   R   t   merging_statsR   Rù   Rý   t   smooth_meas_approxt   meas_smooth(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   Y  s8    					c         C   s‹   | j  d ƒ |  j d  k	 re | j d ƒ | j d ƒ | j rR | j |  j ƒ qe | j |  j ƒ n  |  j d  k	 r‡ |  j j	 | ƒ n  d  S(   Ns   Anomalous signals"   Half-dataset anomalous correlationse   This statistic (also called CC_anom) is calculated from unmerged data, which
 have been split into two half-datasets of approximately the same size and
 merged to obtain unique (anomalous) intensities, and their anomalous
 differences compared.  Resolution shells with CC_anom above 0.3 contain
 substantial anomalous signal useful for heavy atom location.(
   R  R!  R,   RL   RM   t
   gui_outputRP   RO   Rù   RÍ   (   R@   RQ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS   y  s    	N(   RT   RU   R,   RJ   RS   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyR  X  s    t   wilson_scalingc           B   sJ   e  Z d  Z d d
 d d d d „ Z d „  Z d „  Z d „  Z d	 „  Z RS(   s…   
  Calculates isotropic and anisotropic scale factors, Wilson plot, and various
  derived analyses such as ice rings and outliers.
  t	   eigen_mini   i    g      @c   %      C   s±  | | d k r | d k s" t  ‚ | j ƒ  } | j ƒ  }	 |	 j d t ƒ |	 j ƒ  j d ƒ |  _ | d  k rw d } n  | d  k rŒ d } n  | | d k r« t	 d ƒ ‚ n  | j
 ƒ  j ƒ  }
 t j d | d | |
 | d | |
 | ƒ } | |  _ | j |  _ | j |  _ |  j j } | j
 ƒ  j ƒ  }
 t j d | d | |
 | d | |
 | ƒ } | j } | |  _ | j |  _ | j |  _ | j |  _ t | d d  ƒ |  _ | j } | d | d	 | d d
 } | d } | d	 | k  rñ| d	 } n  | d | k  r| d } n  | d k r*| j d } nN | d k rKt j | j ƒ } n- | d k rrt  d  k	 sit  ‚ | } n d } | | | d d d g } t! j" | j# ƒ  t! j$ | ƒ ƒ } t j% | d | j ƒ |  _& t j% |  j& d | ƒ |  _& |  j& j' | ƒ |  _& |  j& j( ƒ  d k } |  j& j) d |  j& j( ƒ  j* | d ƒ ƒ |  _& |  j& j' | ƒ |  _& t j+ |  j& d t ƒ} | j, j ƒ  |  _, | j- d t. j/ d@ ƒ d t. j/ dA ƒ ƒ } t j% d | d |  j d |  j ƒ } | j' | ƒ | j d t ƒ | j ƒ  j d ƒ } d t j0 | j1 ƒ  j( ƒ  ƒ t j0 | j1 ƒ  j( ƒ  ƒ | | j2 ƒ  d	 <| j3 d t d d ƒ } | j4 d t d d ƒ } | j5 | ƒ t j+ | d t ƒ} | j, j ƒ  } | j d t ƒ | j ƒ  }	 |	 j d t ƒ |	 j ƒ  j d ƒ |  _ | |  _6 t j7 | j8 j9 |  j6 ƒ ƒ |  _: t j; | j( d	 t< | j( ƒ d	 !ƒ |  _= t j> | | ƒ } | j? |  _@ t j; | j ƒ  jA ƒ  ƒ } | d	 | j2 ƒ  d	 !} |  j= |  j= | d |  _B |  jB | jC | jC 7_B t j/ |  jB ƒ |  _B t jD |  j= |  j@ ƒ |  jB |  _E t j; | j( d	 t< | j( ƒ d	 !ƒ |  _4 tF | ƒ |  _G |  jG jH | ƒ |  _I d  |  _J |  j6 j2 ƒ  d	 k r§t j0 |  j6 ƒ d k r§tK d |  j6 d  |  j4 d! |  jE ƒ |  _J n  tL jM d" d# d$ d% d& d' d( g d) d# g d* dB g d- d d	 d d. g g d tN |  j6 ƒ tN |  j: ƒ tN |  j= ƒ tN |  j@ ƒ g d/ t ƒ |  _O |  jE | k } | jP t ƒ |  _Q tL jM d" d0 d$ d1 d2 d3 d4 g d5 d6 d7 d7 d8 g d) d9 g d- d d	 d d. g g ƒ |  _R x‰ tS |  j6 j2 ƒ  ƒ D]r }  | |  r¿|  j6 |  d: }! |  jE |  }" |  j4 |  }# |  j= |  |  j@ |  }$ |  jR jT |! |" |# |$ g ƒ q¿q¿WtL jM d" d; d$ d% d< d= g d) d> g d* dC g d- d d	 d g g d tN |  j6 ƒ tN |  jE ƒ tN |  j4 ƒ g d/ t ƒ |  _U d  S(D   Ni    RX   i   s   No scatterers availableR   t
   n_residuest   n_basest   overall_b_carti   g      @R*  t
   eigen_meant
   user_b_isoi   g        gšd~ÅQJR   R—   R‡   g      ð?gü©ñÒMb€?Ro   g®Gázæ?t   cache_0t   p_scalet   u_starR   R   g�íµ ÷Æ°>g{®Gáz„?Rã   Rä   Rå   R   s   Intensity plotsR   s
   1/resol**2s   <I> smooth approximations   <I> via binnings   <I> expectedR   R   R‰   s   <I>R    i   R!   s"   Mean intensity by shell (outliers)R˜   t   z_scoreR   s   <Iobs>/<Iexp>R   s   %9.3fs   %7.2fs   %10.3fs   Worrisome resolution shellsg      à¿s   Z scores and completenesst   Z_scores   Fractional completenesss"   Data sanity and completeness checks"   Z score or fractional completenessg     @_@gtíÀ\;0÷?(   s
   Resolutions   <I>(   s
   Resolutions"   Z score or fractional completeness(V   R+   t   infoR#   RY   R   R/   Rã   R  R,   R   t   space_groupt   order_zR   t   ml_iso_absolute_scalingt   iso_scale_and_bR1  t   iso_p_scalet   b_wilsont   iso_b_wilsont	   scat_infot   ml_aniso_absolute_scalingt   b_cartt   aniso_scale_and_bt   aniso_p_scaleR2  t   aniso_u_start   aniso_b_cartRð   R-  t   eigen_valuesR   t   meant   remove_aniso_b_isoR   t   u_cart_as_u_starRh   t   b_as_ut   anisotropic_correctiont   no_aniso_arrayR$   R   Rl   R`   Rš   R›   R  RÛ   R¢   R"  R§   R\   t$   mean_of_intensity_divided_by_epsilonR   t	   scat_dataRû   R¡   R¶   R$  t   mean_I_normalisationRÓ   R:   t   mean_I_obs_datat   expected_intensityt   mean_intensityt   mean_I_obs_theoryt   counts_givent   mean_I_obs_sigmat   sigma_intensityR|   t   z_scoresR–   t   outliersRÌ   t   miller_array_filteredt	   ice_ringsRÏ   R   R6   R.   t   wilson_tableRé   t   n_worrisomet   outlier_shell_tableR7   R;   t   zscore_table(%   R@   R   R+  t   remove_aniso_final_bt	   use_b_isot   n_copies_solcR,  t   z_score_cutR5  R   R7  R9  R=  R@  R?  t   b_cart_observedt   b_trace_averaget   b_trace_mint   b_uset   b_cart_aniso_removedt   u_star_aniso_removedt   sel_bigt   normalistiont   absolute_millerRû   t   mean_observed_intensityR   t   normalisationR›   t   theoryt   countst	   worrisomeRC   t   d_spaceR3  R  t   ratio(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRJ   �  s(   "								
  			!				+			#	-							
#			*c         C   s`   | j  d ƒ | j d ƒ |  j d k rO | j |  j d d ƒ| j d ƒ n | j d ƒ d  S(   Ns   Mean intensity analysessl    Inspired by: Morris et al. (2004). J. Synch. Rad.11, 56-59.
 The following resolution shells are worrisome:i    RK   i   sg   Possible reasons for the presence of the reported unexpected low or elevated
 mean intensity in a given resolution bin are :
   - missing overloaded or weak reflections
   - suboptimal data processing
   - satellite (ice) crystals
   - NCS
   - translational pseudo symmetry (detected elsewhere)
   - outliers (detected elsewhere)
   - ice rings (detected elsewhere)
   - other problems
 Note that the presence of abnormalities in a certain region of reciprocal
 space might confuse the data validation algorithm throughout a large region
 of reciprocal space, even though the data are acceptable in those areas.

s    *** None ***(   RL   RÍ   RZ  RO   R[  (   R@   RQ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   show_worrisome_shellsW  s    
c         C   s    | j  d ƒ |  j j d | ƒ |  j j d | ƒ | j d ƒ | j d ƒ | j |  j ƒ |  j | ƒ |  j	 j | ƒ |  j
 d  k	 rœ |  j
 j | ƒ n  d  S(   Ns$   Absolute scaling and Wilson analysisRQ   s   Wilson plots   The Wilson plot shows the falloff in intensity as a function in resolution;
 this is used to calculate the overall B-factor ("Wilson B-factor") for the
 data shown above.  The expected plot is calculated based on analysis of
 macromolecule structures in the PDB, and the distinctive appearance is due to
 the non-random arrangement of atoms in the crystal.  Some variation is
 natural, but major deviations from the expected plot may indicate pathological
 data (including ice rings, detector problems, or processing errors).(   R  R9  RÍ   R@  RL   RM   RP   RY  Rq  RV  RX  R,   (   R@   RQ   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRS   q  s    c         C   st   g  } |  j  d  k	 r. | j |  j  j ƒ  ƒ n  | j |  j j ƒ  ƒ | j |  j j ƒ  ƒ | j |  j j ƒ  ƒ | S(   N(   RX  R,   t   extendRÎ   RV  R9  R@  (   R@   R  (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyRÎ   ‡  s    c         C   s[   d |  _ d |  _ d |  _ d |  _ d |  j _ d |  j _ d |  j _ d |  j _ |  j	 S(   sB   
    Pickling function with storage efficiency optimizations.
    N(
   R,   RW  RJ  R›   R  R9  Rµ   R@  R=  t   __dict__(   R@   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   __getstate__–  s    				N(	   RT   RU   RV   R,   RJ   Rq  RS   RÎ   Rt  (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyR)  Š  s   Á			(%   RV   t
   __future__R    t   mmtbx.scalingR   t   mmtbxR   t   iotbxR   t   cctbxR   R   t   cctbx.array_familyR   t   scitbx.mathR   R   R	   t   libtbx.test_utilsR
   t   libtbx.utilsR   t   libtbxR   RÛ   t   xtriage_analysisR   t   objectRW   Re   Rƒ   R–   RÏ   Rò   R  R  R)  (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/data_statistics.pyt   <module>   s0   kO% ºn…2