ó
§™xTc           @   sº   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d l	 Z
 d  d l	 m Z m Z d  d l	 m Z d  d l	 m Z d  d l Z d  d l Z d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿ(   t   division(   t   adptbx(   t   flex(   t   Sorryt#   show_exception_info_if_full_testingN(   t   absolute_scalingt   relative_wilson(   t   matthews(   t   data_statisticst   basic_analysesc           B   s    e  Z d d d d d  d „ Z RS(   i    c         C   s   | d  k r t j } n  | d k r9 | J| J| d IJn  d } t |  _ | j j j j d  k	 sx | j j j j	 d  k	 r© t
 |  _ | j j j j d  k	 rG| d IJqGnž | j j j j d  k	 rG| d | j j j j IJt j j d | j j j j d | ƒ }	 |	 d  k	 rG|	 j | j j j _ |	 j	 | j j j _	 t
 |  _ qGn  t j d | d	 | j j j j d
 | j j j j	 d | d d ƒ }
 |
 d | j j j _ |
 d | j j j _	 |
 d } |
 |  _ | j j j j d  k	 r'| j j j j } | |  _ | d k rB| d IJ| d I| IJqBn | | j j j _ | |  _ | } d  |  _ | } | d  k	 r~| j ƒ  sut ‚ | } n  | j ƒ  d  k	 rTt j | d | j j j j j j d | j j j j j j ƒ} | j  | ƒ | |  _ | j j j j j j! d  k rT| j" | j# k r3| j# | j j j j j _! qQ| j" | j j j j j _! qTn  | d k ru| J| J| d IJn  | j j j j } | j j j j	 } | d  k r®d } n  | d  k rÃd } n  | | d k rât$ d ƒ ‚ n  t% j& d | d	 | | j' ƒ  j( ƒ  | d
 | | j' ƒ  j( ƒ  | ƒ } | j  d | d | ƒ | |  _) | j* |  _+ | j, |  _- | d k r€| J| J| d IJn  t% j. d | d	 | | j' ƒ  j( ƒ  | d
 | | j' ƒ  j( ƒ  | ƒ } | j  d | d d ƒ | |  _/ y | j0 } Wn5 t1 k
 r)} | d IJ| t2 | ƒ IJt3 ƒ  d  SX| j* |  _4 | j5 |  _6 | j0 |  _7 t8 | d d  ƒ |  _9 | d k r€| d IJ| Jn  | j0 } | d | d | d d } | d } | d | k  rÎ| d } n  | d | k  rë| d } n  | j j j: j; j< d k r| j= d } nŠ | j j j: j; j< d k rFt> j? | j= ƒ } nZ | j j j: j; j< d k rš| j j j: j; j@ d  k	 s‚t ‚ | j j j: j; j@ } n d } | | | d d d g } tA jB | jC ƒ  tA jD | ƒ ƒ } t% jE | d | j5 ƒ |  _F t% jE |  jF d | ƒ |  _F |  jF jG | ƒ |  _F |  jF jH ƒ  d  k } |  jF jI d! |  jF jH ƒ  jJ | d ƒ ƒ |  _F |  jF jG | ƒ |  _F t% jK |  jF d" t
 ƒ} | jL jM ƒ  |  _L | |  _N | d k rÎ| d# IJ| Jn  t jO | | j* | j5 | jP d | d$ | ƒ} | |  _Q | jR |  _S d  |  _T | d  k	 rƒ| jU ƒ  d% k  rƒy tV jV d& | d' | ƒ |  _T WqƒtW k
 r} | d( IJ| d) IJqƒXn  | d k rœ| d* IJn  d  S(+   Ni    s3   Matthews coefficient and Solvent content statisticsg      ð?s!     warning: ignoring sequence files/     determining composition from sequence file %st	   file_namet   logt   crystal_symmetryt
   n_residuest   n_basest   outt   verbosei   i   s-   Number of copies per asymmetric unit provideds"    Will use user specified value of t	   isigi_cutt   completeness_cuts,   Maximum likelihood isotropic Wilson scaling s   No scatterers availablet   miller_arrays.   Maximum likelihood anisotropic Wilson scaling s   *** ERROR ***t   overall_b_carts%   Correcting for anisotropy in the datag      @t	   eigen_mint
   eigen_meant
   user_b_isoi   g        gšd~ÅQJt   datat   auto_kernels'   Some basic intensity statistics follow.t   out_plotg      @t
   miller_obst   miller_calcs6   *** Error calculating relative Wilson plot - skipping.t    s   Basic analyses completed(X   t   Nonet   syst   stdoutt   Falset
   nres_knownt   scalingt   inputt   asu_contentsR   R   t   Truet   sequence_filet   iotbxt   bioinformaticst   composition_from_sequence_fileR   t   matthews_ruppt   matthews_resultst   n_copies_per_asut   defined_copiest   guessed_copiest   data_strengtht   is_xray_intensity_arrayt   AssertionErrort   sigmasR   t   i_sigi_completeness_statst
   parameterst   misc_twin_parameterst   twin_test_cutsR   R   t   showt   high_resolutiont   resolution_cutt   resolution_at_leastR   R   t   ml_iso_absolute_scalingt   space_groupt   order_zt   iso_scale_and_bt   p_scalet   iso_p_scalet   b_wilsont   iso_b_wilsont   ml_aniso_absolute_scalingt   aniso_scale_and_bt   b_cartt   AttributeErrort   strR   t   aniso_p_scalet   u_start   aniso_u_start   aniso_b_cartt   getattrR   t   optionalt   anisot   final_bt   eigen_valuesR   t   meant   b_isoR   t   u_cart_as_u_start	   unit_cellt   b_as_ut   anisotropic_correctiont   no_aniso_arrayt   set_observation_typeR   t   arrayt   set_selectedt   kernel_normalisationt   normalised_millert	   deep_copyt   phil_objectt   basic_intensity_statisticst	   scat_infot   basic_data_statst
   new_millerR   t
   rel_wilsont   d_minR   t   RuntimeError(   t   selfR   R_   R   R   R   t   original_intensitiesR   t   n_copies_solct   seq_compR,   t   miller_array_newt   miller_array_intensitiesR0   R   R   R?   RE   RF   t   et   b_cart_observedt   b_trace_averaget   b_trace_mint   b_uset   b_cart_aniso_removedt   u_star_aniso_removedt   sel_bigt   normalistionRb   (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/basic_analyses.pyt   __init__   sH   				
		
				!						 

	
  !			!		
					
N(   t   __name__t
   __module__R   Rv   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/basic_analyses.pyR	      s   (   t
   __future__R    t   cctbxR   t   cctbx.array_familyR   t   libtbx.utilsR   R   t   mmtbx.scalingt   mmtbxR   R   R   R   t   iotbx.bioinformaticsR(   R   t   objectR	   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/basic_analyses.pyt   <module>   s   