ó
‚™xTc           @   s®   d  d l  m Z d  d l Z d  d l Z d  d l m Z m Z d  d l m	 Z	 d  d l
 Z d  d l j Z d  d l Z d „  Z d „  Z e d k rª e d e j d	 ƒ n  d S(
   iÿÿÿÿ(   t   divisionN(   t   Sorryt   Usage(   t   show_stringc           C   s&   t  d t j j t j j f ƒ ‚ d  S(   NsJ   %s reflection_file_name high_resolution_value

  Example: %s your.mtz 2.0
(   R   t   libtbxt   envt   dispatcher_name(    (    (    s_   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/r_free_flags_completion_simple.pyt   usage
   s    c         C   sb  t  |  ƒ d k s* d |  k s* d |  k r4 t ƒ  n  d  } d  } d  } xÅ |  D]½ } t j | ƒ r« | } t j j d | ƒ } | j ƒ  d  k r
t	 d t
 | ƒ ƒ ‚ q
qM y t | ƒ } Wn' t k
 rä t	 d t
 | ƒ ƒ ‚ n X| d k rM t	 d t
 | ƒ ƒ ‚ qM qM W| d  k s&| d  k r0t ƒ  n  t j j d | g ƒ } | j d d  d	 d  d
 d  d t d d ƒ \ } } d GH| j d d ƒ Hd G| GHH| j ƒ  d  k	 s°t ‚ | j ƒ  d  k	 sÈt ‚ | j ƒ  j ƒ  d k sæt ‚ | j d | j ƒ  | k ƒ } | j ƒ  j t ƒ | j ƒ  j ƒ  } d | d GH| d k sHt ‚ H| j d | ƒ j | j ƒ  ƒ }	 d G|	 j ƒ  j ƒ  GHH|	 j d | d d  d t ƒ }
 | j d |
 ƒ } d GH| j d d ƒ H| j  d d ƒ } t j! | ƒ } | j" d ƒ } | d k r| |  d | | d  } n  | d! 7} d" t
 | ƒ GH| j# ƒ  j$ d | ƒ Hd# t
 | ƒ GHd  S($   Ni    s   --helps   -ht	   file_names   File not recognized: %ss,   Not a file name or high-resolution value: %ss;   High-resolution value must be greater than zero (%s given).t   reflection_filest   labelt   test_flag_valuet   disable_suitability_testt   parameter_scopet   r_free_flagss!   Summary of existing R-free-flags:t   prefixs     s   Test flag value:t   datas   Fraction free: %.2f %%id   t   d_mins   Number of missing R-free-flags:t   fractiont   max_freet   use_lattice_symmetryt   others!   Summary of extended R-free-flags:t   column_root_labels   Extended-R-free-flagst   .t   _i   s   _extended_r_free_flags.mtzs   Writing file: %ss¤  Miscellaneous remarks:

  - ***PLEASE INSPECT*** the extended R-free-flags with this command:

      iotbx.r_free_flags_accumulation %s

  - For use in phenix.refine, simply add the new mtz file as an
    additional command-line argument. If necessary, follow the
    phenix.refine suggestions to select the extended R-free-flag
    array.

  - You may have to remove the
      REMARK r_free_flags.md5.hexdigest
    line from your PDB file(s) to use the new flags in phenix.refine.
    (phenix.refine will tell you why and what you need to do.)

  - phenix.reflection_file_converter can be used to combine reflection
    data from another file with the extended R-free-flags.
(%   t   lenR   t   Nonet   opt   isfilet   iotbxt   reflection_file_readert   any_reflection_filet	   file_typeR   R   t   floatt
   ValueErrort   reflection_file_utilst   reflection_file_servert   get_r_free_flagst   Falset   show_comprehensive_summaryt	   unit_cellt   AssertionErrort   space_group_infoR   t   sizet   arrayt   countt   Truet   complete_sett   lone_sett
   map_to_asut   indicest   generate_r_free_flagst   concatenatet   as_mtz_datasett   basenamet   rfindt
   mtz_objectt   write(   t   argst   refl_file_namet	   refl_filet   high_rest   argt   refl_file_serverR   R   t   fraction_freet   missing_sett   missing_flagst   extended_r_free_flagst   mtz_datasett   output_file_namet   i(    (    s_   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/r_free_flags_completion_simple.pyt   run   sˆ    *
	
		%				
t   __main__R:   i   (   t
   __future__R    t   iotbx.reflection_file_utilsR   t   iotbx.reflection_file_readert   libtbx.utilsR   R   t   libtbx.str_utilsR   t   libtbx.load_envR   t   os.patht   pathR   t   sysR   RG   t   __name__t   argv(    (    (    s_   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/r_free_flags_completion_simple.pyt   <module>   s   		Z