ó
™xTc           @   sØ   d  d l  m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ e d k rÔ d  d l Z e ƒ  Z e j e j	 d ƒ x` e
 e j e j e j ƒ D]@ \ \ Z Z Z Z \ Z Z Z e e e f Ge Ge e e f GHq� Wn  d S(	   iÿÿÿÿ(   t   divisiont   readerc           B   s    e  Z d  Z d „  Z d „  Z RS(   s    Class to read the SPOT.XDS file.c         C   s   d S(   s    Init the reader.N(    (   t   self(    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/spot_xds.pyt   __init__   s    c         C   s%  g  |  _  g  |  _ g  |  _ t | d ƒ �õ } xë | D]ã } | j ƒ  } t | ƒ d k  rg t d ƒ ‚ n  t | ƒ d k rÌ |  j  j t g  | d d !D] } t	 | ƒ ^ q“ ƒ ƒ |  j j t	 | d ƒ ƒ n  t | ƒ d k r4 |  j j t g  | d d !D] } t
 | ƒ ^ qø ƒ ƒ q4 q4 WWd QXd S(   s   Read the spot file.t   ri   s   Not enough tokensi    i   i   N(   t   centroidt	   intensityt   miller_indext   opent   splitt   lent
   IndexErrort   appendt   tuplet   floatt   int(   R   t   filenamet   handlet   linet   tokenst   t(    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/spot_xds.pyt	   read_file   s    			6(   t   __name__t
   __module__t   __doc__R   R   (    (    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/spot_xds.pyR      s   	t   writerc           B   s&   e  Z d  Z d d „ Z d d „ Z RS(   s!   Class to write the SPOT.XDS file.c         C   sy   | |  _  | |  _ | |  _ t |  j  ƒ t |  j ƒ k s? t ‚ |  j d  k	 ru t |  j  ƒ t |  j ƒ k su t ‚ n  d  S(   N(   t	   centroidst   intensitiest   miller_indicesR
   t   AssertionErrort   None(   R   R   R   R   (    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/spot_xds.pyR   +   s    			$c      
   C   s—   t  | d ƒ �‚ } xx t t |  j ƒ ƒ D]a } | d |  j | I| d |  j | I|  j d k	 r | d	 |  j | In  | d Iq( WWd QXd S(
   s   Write the spot file.t   wbs    %.2fi   s   %.2fs    %is   
Ns    %.2f %.2f %.2fs	    %i %i %i(   R   t   rangeR
   R   R   R   R   (   R   R   t   ft   i(    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/spot_xds.pyt
   write_file4   s    N(   R   R   R   R   R   R#   (    (    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/spot_xds.pyR   (   s   	t   __main__Ni   (   t
   __future__R    t   objectR   R   R   t   sysR   R   t   argvt   zipR   R   R   t   xct   yct   zcR"   t   ht   kt   l(    (    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/spot_xds.pyt   <module>   s   	+