ó
©™xTc           @   s3  d  d l  m Z d  d l m Z d  d l m Z m Z m 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 m Z d  d	 l m Z d  d
 l m Z m Z d  d l Z d  d l Z d  d l m Z e j ƒ  Z e	 j j e j ƒ  ƒ Z d „  Z e d k r/e e j d ƒ n  d S(   iÿÿÿÿ(   t   division(   t   crystal(   t   Sorryt   date_and_timet	   multi_outN(   t   reflection_file_reader(   t   reflection_file_utils(   t   crystal_symmetry_from_any(   t   pair_analyses(   t   StringIO(   t	   pre_scalet
   make_param(   t   fa_estimationc   !   	   C   s’	  t  |  ƒ d k r% t j d d ƒ ni	d |  k r9 d GHnU	d |  k rM d GHnA	d |  k rl t j d d ƒ n"	d |  k r‹ t j d d	 ƒ n	t ƒ  } d
 |  k r¼ | j d d d t j ƒ n  t ƒ  } t ƒ  } | j d d d | ƒ t ƒ  } | d IJ| J| t ƒ  IJ| J| Jg  } t j	 d d ƒ } d  } xˆ|  D]€} d  }	 t }
 | d
 k r\t }
 n  t j j | ƒ ry t j j d | ƒ }	 Wn$ t k
 r�‚  n t k
 r­n X|	 d  k	 rÐ| j |	 ƒ t }
 n  |	 d  k r÷t j d | d t ƒ } n  | d  k	 rt| } t }
 qtn_ y8 | j d | ƒ }	 |	 d  k	 rL| j |	 ƒ t }
 n  Wn$ t k
 rc‚  n t k
 rsn X|
 s5| d IJ| d I| IJ| d IJ| Jt d | ƒ ‚ q5q5Wt j d | ƒ } | j ƒ  } d  } | j j j j j  GHt! j" d | j j j j j  ƒ } | j j j j# d  k rO| j$ ƒ  | j j j _# | d IJn  | j j j j% d  k rŒ| j% ƒ  | j j j _% | d IJn  | j j j j# d  k r³t d ƒ ‚ n  | j j j j% d  k rÚt d ƒ ‚ n  t& j' d | j j j j% d t( | j j j j# ƒ ƒ } } t j d | ƒ } t j) d | ƒ } | d  IJ| d! IJ| j d" | d | j* ƒ | d# IJ| Jt+ j, d$ | d% t d& g  ƒ } d  } | j- d | j j j j j  d' | j j j j j. d( t d) d* ƒ } | j/ ƒ  } | j0 ƒ  j1 | j2 ƒ  d@ k ƒ } | j1 | j3 ƒ  d k ƒ } | j4 ƒ  r<| j5 ƒ  } n | j6 ƒ  rWt7 | ƒ } n  | j8 ƒ  srt d+ ƒ ‚ n  | j9 d, | ƒ d  } | j- d | j j j j: j  d' | j j j j: j. d( t d) d- ƒ } | j/ ƒ  } | j0 ƒ  j1 | j2 ƒ  dA k ƒ } | j1 | j3 ƒ  d k ƒ } | j4 ƒ  r-| j5 ƒ  } n | j6 ƒ  rHt7 | ƒ } n  | j8 ƒ  sct d. ƒ ‚ n  | j9 d, | ƒ | j; ƒ  s…t< ‚ | j; ƒ  r©| j= ƒ  j> | ƒ } n  | j? ƒ  } | j; ƒ  rÙ| j= ƒ  j> | ƒ } n  | J| d/ IJ| d0 IJ| j@ d1 | ƒ | JtA jB | | j j jC jD | j j jE ƒ } | jF j? ƒ  } ~ | J| d2 IJ| d3 IJ| j@ d1 | ƒ | JtA jB | | j j jC jD | j j jE ƒ } | jF j? ƒ  } ~ | J| d4 IJ| d5 IJ| j@ d1 | ƒ | JtA jB | | j j jC jD | j j jE ƒ } | jF j? ƒ  } | J| d6 IJ| d7 IJ| JtG jH | | | j j jC jI ƒ } | jF j? ƒ  } | jJ j? ƒ  } ~ tK jL | | ƒ } | J| d8 IJ| d9 IJ| JtG jM | | j j jC jN ƒ } | jO j? ƒ  } | jP j? ƒ  } ~ tK jL | | ƒ } | J| d: IJ| d; IJ| JtG jQ | jR | jR | j j jG ƒ } | J| d< IJ| d= IJ| J| jS jT d> d? | j j jU jV ƒ }  |  jW ƒ  jX d | j j jU jY ƒ d  S(B   Ni    t   expert_levels   --helps   no help available as yets   --hs   no help availableas yets   --show_defaultss   --show_defaults_alli
   s   --quiett   labelt   stdoutt   file_objectt
   log_buffers   #phil __OFF__t
   home_scopet   scalingt	   file_namet   ensure_read_accesst   args2   ##----------------------------------------------##s%   ## Unknown phil-file or phil-command:s'   Unknown file format or phil command: %st   sourcess   Using symmetry of native datas   Using cell of native datas   No space group defineds   No unit cell definedt	   unit_cellt   space_group_symbolt   python_objects   Effective parameterss   #phil __ON__t   outs   #phil __END__t   crystal_symmetryt   force_symmetryt   reflection_filest   labelst   ignore_all_zerost   parameter_scopes(   scaling.input.SIR_scale.xray_data.natives'   miller_array_native is not a real arrayt   infos,   scaling.input.SIR_scale.xray_data.derivatives+   miller_array_derivative is not a real arrays   Native datas   ===========t   fs!   Derivative data (merged friedels)s!   =================================s2   Anomalous data (non merged Friedels of derivative)s2   ==================================================s"   Working on isomorphous differencess"   ==================================s    Working on anomalous differencess    ================================s   Combining iso and ano datas   ==========================s   writing mtz files   ----------------t   column_root_labelt   F(   i    i    i    (   i    i    i    (Z   t   lent   master_paramst   showR   t   registert   sysR   R	   R   t!   command_line_argument_interpretert   Nonet   Falset   Truet   ost   patht   isfilet   iotbxt   philt   parset   KeyboardInterruptt	   Exceptiont   appendR   t   any_reflection_filet   processR   t   fetcht   extractR   t   inputt	   xray_datat   nativeR   R   t   extract_fromt   space_groupt   space_group_infoR   R   t   symmetryt   strt   formatR   R   t   reflection_file_servert   get_xray_dataR   R"   t
   map_to_asut   selectt   indicest   datat   is_xray_intensity_arrayt	   f_sq_as_ft   is_complex_arrayt   abst   is_real_arrayt   set_infot
   derivativet   anomalous_flagt   AssertionErrort   average_bijvoet_matest   set_observation_typet	   deep_copyt   show_comprehensive_summaryR
   t
   pre_scalert   scaling_strategyt   pre_scaler_protocolt   basict   x1R   t   combined_scalingt   iso_protocolt   x2R   t   delta_generatort   ano_scalingt   ano_protocolt   x1pt   x1nt   naive_fa_estimationt   abs_delta_ft   fat   as_mtz_datasett   outputt   outlabelt
   mtz_objectt   writet   hklout(!   t   argst   logt   string_buffert   string_buffer_plotst	   log_plotst   phil_objectst   argument_interpretert   reflection_fileR   t   command_line_paramst   arg_is_processedt   effective_paramst   paramst   crystal_symmetry_natR   t
   new_paramst   xray_data_servert   miller_array_nativet   info_nativet   miller_array_derivativet   info_derivativet   miller_array_derivative_anomt   native_pre_scalet   derivative_pre_scalet   derivative_anom_pre_scalet
   iso_scalert   delta_gen_isot
   ano_scalert   positive_millert   negative_millert   delta_gen_anoRg   t   mtz_dataset(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/siras_scale.pyt   run   s¨   				
			  		  

		


						







	

	



t   __main__i   (    t
   __future__R    t   cctbxR   t   libtbx.utilsR   R   R   t
   iotbx.philR2   R   R   R   t   mmtbx.scalingt   mmtbxR   t   libtbx.str_utilsR	   R
   R   R*   R/   R   t	   phil_legot   params_generatorR3   R4   t   default_sirasR'   RŒ   t   __name__t   argv(    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/siras_scale.pyt   <module>   s$   	ÿ 