ó
ƒ™xTc           @   sÎ   d  d l  m Z d  d l Z e j j d ƒ r` d  d l m Z d  d l m Z d  d l	 j
 Z n d Z d  d l m Z d  d l m Z d  d l m Z d  d l Z d	 „  Z d
 „  Z e d k rÊ e ƒ  n  d S(   iÿÿÿÿ(   t   divisionNt   ccp4io(   t   mtz_free_flipper(   t   mtz_convert_free_to_work(   t	   show_diff(   t   format_cpu_times(   t   StringIOc          C   s  t  d  k r d GHd  St j j d d d t j j ƒ }  |  d  k rK d GHd  Sd } t j	 d |  g d | ƒ t j	 d d	 g d | ƒ t
 j	 d |  g d | ƒ g  } x>|  d f d	 d f d d f d d f g D]\ } } t ƒ  } t  j d | ƒ } | j d | d d ƒ | j ƒ  } | j | ƒ d \ } } }	 xo | j ƒ  d D]] }
 |
 j d ƒ re| d 7} qC|
 j d ƒ r�| d 7} qC|
 j d ƒ s–t ‚ |	 d 7}	 qCW| j ƒ  | | |	 k sÄt ‚ | | |	 f | k sÍ t ‚ qÍ Wt | d | d ƒ st ‚ | d | d k st ‚ d  S(    NsE   Skipping iotbx/examples/tst_mtz_free_flipper.py: ccp4io not availablet   relative_paths(   phenix_regression/reflection_files/l.mtzt   tests-   Skipping exercise(): input file not availables   R-free-flags(-)t   argst   labels   free_flipped_l.mtzi�4  i)  i	  s   free_flipped_free_flipped_l.mtzs   less_free_l.mtzi²6  i  t	   file_namet   outt   formatt   spreadsheeti    i   s   ,0s   ,1t   ,i   (   i�4  i)  i	  (   i)  i�4  i	  (   i�4  i)  i	  (   i²6  i  i	  (   i    i    i    (   t	   iotbx_mtzt   Nonet   libtbxt   envt   find_in_repositoriest   ost   patht   isfileR   t   runR   R   t   objectt   show_column_datat   getvaluet   appendt
   splitlinest   endswitht   AssertionErrort   n_reflectionsR   (   t   input_file_nameR
   t   spreadsheetsR   t   expectedt   st   mtz_objt   n_0t   n_1t   n_restt   line(    (    sQ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/tst_mtz_free_flipper.pyt   exercise   sH    				   c           C   s   t  ƒ  t ƒ  GHd  S(   N(   R*   R   (    (    (    sQ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/tst_mtz_free_flipper.pyR   4   s    t   __main__(   t
   __future__R    t   libtbx.load_envR   R   t
   has_modulet   iotbx.examplesR   R   t	   iotbx.mtzt   mtzR   R   t   libtbx.test_utilsR   t   libtbx.utilsR   t	   cStringIOR   R   R*   R   t   __name__(    (    (    sQ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/tst_mtz_free_flipper.pyt   <module>   s   	&	