ó
í™xTc           @   sû   d  d l  m Z d  d l m Z m Z m Z m Z d  d l m Z 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	 d	 d	 d	 e e e d
 „ Z d „  Z e d k r÷ d  d	 l Z e e j d ƒ n  d	 S(   iÿÿÿÿ(   t   division(   t   millert   sgtbxt   uctbxt   xray(   t   reflection_file_utilst   reflection_file_reader(   t   shelx(   t   masks(   t   time_log(   t   option_parser(   t   StringIONc   $      C   s<  | d  k s | d  k s t ‚ |  j ƒ  } t d ƒ j ƒ  } | j d t ƒ } | j ƒ  } | j ƒ  } | j	 ƒ  } | d  k	 r“ | j
 d | ƒ } n  |
 rÒ d GHd | j ƒ  | j ƒ  f GH| j ƒ  H| j ƒ  Hn  t j |  | ƒ } t d ƒ j ƒ  } | j d | d | d	 | d
 | d | d | ƒ | j ƒ  t d ƒ j ƒ  } | j ƒ  } | j ƒ  | j ƒ  | j ƒ  } t ƒ  } | j ƒ  } | j | ƒ t d d ƒ } | j | j ƒ  ƒ | j ƒ  |
 ríHt j GH| j ƒ  GH| j ƒ  GH| j ƒ  GHn  |	 r8| j ƒ  } t  j j! d | d t ƒ } | |  | ƒ j" ƒ  } | j ƒ  } | j# | ƒ } | j# | ƒ } | j$ d | | ƒ } t% j& | j' | ƒ } | j( ƒ  t% j& | j' | ƒ } | j( ƒ  t% j& | j' | ƒ } | j( ƒ  | j$ d | | ƒ }  t% j& | j' |  ƒ }! |! j( ƒ  t% j& | j' | j ƒ  j) | ƒ ƒ }" |" j( ƒ  d d l* m+ }# |# j, d d d | j j- j. ƒ  d | j/ ƒ  ƒ |# j, d d d | j0 ƒ  d | j/ ƒ  ƒ |# j, d d d | j0 ƒ  d | j/ ƒ  ƒ |# j, d d d | j0 ƒ  d | j/ ƒ  ƒ |# j, d d d |! j0 ƒ  d | j/ ƒ  ƒ |# j, d d d |" j0 ƒ  d | j/ ƒ  ƒ n  | S(   Ns   masks totalt   anomalous_flagt   d_mins   Merging summary:s   R-int, R-sigma: %.4f, %.4fs   compute maskt   solvent_radiust   shrink_truncation_radiust   resolution_factort	   grid_stept   atom_radii_tablet   use_space_group_symmetrys   structure factorss   modified.hklt   wt
   miller_sett   cos_sin_tablei   iÿÿÿÿ(   t   wx_map_viewert   titlet   Maskt   raw_mapt	   unit_cells   f_obs - f_calct   f_maskt   f_models   f_obs - f_modelt   modified_fo_sq(1   t   Nonet   AssertionErrort   deep_copy_scatterersR	   t   startt   customized_copyt   Truet   eliminate_sys_absentt   merge_equivalentst   arrayt   resolution_filtert   r_intt   r_sigmat   show_summaryt   show_comprehensive_summaryR   t   maskt   computet   stopt   structure_factorsR   R   t   modified_intensitiest   export_as_shelx_hklft   opent   writet   getvaluet   closet   legendt   reportt   logt   as_amplitude_arrayR   t   from_scattererst   f_calct   scale_factort   f_obs_minus_f_calcR   t   fft_mapt   crystal_griddingt   apply_volume_scalingt   phase_transfert   crys3dR   t   displayt   datat	   as_doubleR   t   real_map($   t   xst   fo_sqR   R   R   R   t   resolution_cutoffR   R   t   debugt   verboset   xs_reft
   time_totalt   mergingt   fo_sq_mergedR-   t   time_compute_maskt   time_structure_factorsR   R   t   outR   t   out_filet   f_obst   sfR<   R=   t   kR>   t   diff_map_calct   mask_mapt	   model_mapt   f_obs_minus_f_modelt   diff_map_modelt   modified_fo_sq_mapR   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/smtbx/command_line/masks.pyt   exercise_masks   s´    





	
	




						c         C   sw  d „  } t  d d ƒ j ƒ  j d  d d d d d d	 d
 ƒj d  d d d d d d	 d
 ƒj d  d d d ƒj d  d d d ƒj d  d d d d d d	 d5 ƒj d  d d d d d ƒj d  d d d d d ƒj d  d d d d d ƒj d  d d d d d ƒj d  d d d d | d d d d ƒj d  d d d ƒj d |  ƒ } | j d } t j j | ƒ d j	 ƒ  } | d6 k r‹t
 j j d  | ƒ } n1 | d! k r¯t
 j j d  | ƒ } n d" | GHd  St j d# | j ƒ  d$ t j | j d ƒ g ƒ } | j d  ƒ d } | j j d  k	 rNt j t j | j j ƒ ƒ } | j | ƒ j d# | ƒ } n  d% | j d GHd& | j d GH| j j rŒd' | j j GHn  H| j ƒ  H| j j }	 | j j }
 |	 |
 g j d  ƒ d k sÑt  ‚ |
 d  k	 rût! j" |
 d( d) d* t# ƒ}	 n  t$ | | d+ | j j% d, | j j& d- | j j' d. | j j( d/ |	 d0 | j j) d1 | j j* d2 | j j d3 | j j+ ƒ	d4 GHd  S(7   Nc         S   s™   i  } | j  ƒ  } t | ƒ d d k s. t ‚ xN t t t | ƒ d ƒ ƒ D]0 } | j | | d t | | d d ƒ ƒ qK Wt | j |  j	 | ƒ d  S(   Ni   i    i   (
   t   splitt   lenR    t   ranget   intt
   setdefaultt   floatt   setattrt   valuest   dest(   t   optiont   opt_strt   valuet   parsert   radiit   itemst   i(    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/smtbx/command_line/masks.pyt   vdw_radii_callback~   s    #.t   usages+   smtbx.masks structure reflections [options]s   --solvent_radiust   actiont   storet   typeRd   t   defaultgÍÌÌÌÌÌô?s   --shrink_truncation_radiuss   --debugt
   store_trues	   --verboses   --resolution_factori   i   s   --grid_steps   --d_mins   --two_theta_maxs   --cb_opt   strings   --vdw_radiit   callbackt   nargss   --use_space_group_symmetryt   argsi    iÿÿÿÿs   .ress   .inst   filenames   .cifs1   %s: unsupported structure file format {shelx|cif}t   crystal_symmetryt   reflection_filess   structure file: %ss   reflection file: %ss	   debug: %st
   wavelengthg‘'I×L¾æ?t   degR   R   R   R   RJ   R   R   RK   RL   t   OKg      Ð?(   s   .ress   .ins(,   R
   t   enable_symmetry_comprehensiveRh   R   t   processRy   t   ost   patht   splitextt   lowerR   t	   structuret
   from_shelxt   from_cifR   t   reflection_file_serverR{   R   t   any_reflection_filet   get_miller_arrayst   optionst   cb_opR   t   change_of_basis_opt   rt_mxt   change_basisR#   RK   R+   R   t   two_theta_maxt   countR    R   t   two_theta_as_dR$   R^   R   R   R   R   t	   vdw_radiiR   RL   (   Ry   Ro   t   command_linet   structure_filet   extRH   t   reflections_serverRI   R�   R   R‘   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/smtbx/command_line/masks.pyt   run}   sœ    																								
!	t   __main__i   (   t
   __future__R    t   cctbxR   R   R   R   t   iotbxR   R   R   t   smtbxR   t   libtbx.utilsR	   t   iotbx.option_parserR
   t	   cStringIOR   R‚   R   t   FalseR^   R™   t   __name__t   syst   argv(    (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/smtbx/command_line/masks.pyt   <module>   s&   "e	`