ó
ƒ™xTc           @   sd   d  d l  m Z d  d l Z d  d l Z d  d l Z d d „ Z e d k r` e e j d ƒ n  d S(   iÿÿÿÿ(   t   divisionNs   R-free-flagsc   	      C   s  t  |  ƒ d k s t ‚ |  d } d t j j | ƒ } d G| GHt j j d | ƒ } | j d | ƒ } | j	 ƒ  } | j
 ƒ  } | d k } d G| | @j t ƒ GHd G| | @j t ƒ GH| j | | @d ƒ | j | | @d ƒ | j d	 | d
 | ƒ d G| GH| j d | ƒ d  S(   Ni   i    t   free_flipped_s   Reading file:t	   file_namet   labels   Number of 0:s   Number of 1:t   valuest   selection_valids   Writing file:(   t   lent   AssertionErrort   ost   patht   basenamet   iotbxt   mtzt   objectt
   get_columnR   t   extract_valuest   countt   Truet   set_selectedt
   set_valuest   write(	   t   argsR   t   input_file_namet   output_file_namet   mtz_objt   columnR   t   flagst   sel_0(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/mtz_free_flipper.pyt   run   s     
		t   __main__i   (	   t
   __future__R    t	   iotbx.mtzR   t   sysR   R   t   __name__t   argv(    (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/mtz_free_flipper.pyt   <module>   s
   