ó
”™xTc           @   sK   d  d l  m Z d  d l Z d  d l Z e j Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   divisionNt   build_hkl_cifc           B   s#   e  Z d d d  „ Z d d „ Z RS(   c         C   s²  | d  k	 r! | d k s! t ‚ n  d } t j j | ƒ } | d  k r} d | d d d d d	 | g } t d
 j | ƒ ƒ ‚ n  t j | d ƒ } t j | d ƒ } d „  } i  |  _ i  |  _	 i  |  _
 | d  k sã t | ƒ d k r¬| d  k sû | d k r­x¯ t j | ƒ D]› \ }	 }
 } d |
 k r6|
 j d ƒ n  xm t | ƒ D]_ } | j d ƒ r^qCn  | j d ƒ ssqCn  | d  } t j |	 | ƒ } |  j	 j | | ƒ qCWqWn  | d  k sÅ| d k r®xá t j | ƒ D]Í \ }	 }
 } d |
 k r |
 j d ƒ n  xŸ t | ƒ D]‘ } | j d ƒ r(qn  | j d ƒ s=qn  | d  } t j |	 | ƒ } |  j
 j | | ƒ | |  j	 k r|  j j | |  j	 | | f ƒ qqWqÕWq®nd } xÚ | D]Ò } | | | d ƒ } | | | d ƒ } d } t j | ƒ r|  j
 j | | ƒ n d G| GH| d 7} t j | ƒ rF|  j	 j | | ƒ n d G| GH| d 7} | d k r�|  j j | | | f ƒ q¹| | 7} q¹W| d k r®t d | ƒ ‚ n  d  S(   Nt   cift   hklt   COD_SVN_WORKING_COPYs$   Environment variable %s not defined:s     Usage:s       mkdir /some/paths       cd /some/paths2       svn checkout svn://www.crystallography.net/cods       export %s=/some/path/cods   
c         S   s/   t  j |  | d | d d !| d d !| | ƒ S(   Ni    i   i   i   (   t   opt   join(   t   cod_dirt   cod_idt   ext(    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/cif/cod_tools.pyt   cod_path   s    i    s   .svnt   .s   .hkliüÿÿÿs   .cifs   Missing COD cif file:i   s   Missing COD hkl file:s   Number of missing COD files: %d(   s   cifs   hkl(   t   Nonet   AssertionErrort   ost   environt   gett   RuntimeErrorR   R   t   hkl_cif_pairsR   R   t   lent   walkt   removet   sortedt
   startswitht   endswitht
   setdefaultt   isfile(   t   selft   cod_idsR	   t   envart   cod_svnt   msgt   cif_dirt   hkl_dirR
   t   roott   dirst   filest	   file_nameR   t   hkl_patht   cif_patht   n_missing_allt	   n_missing(    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/cif/cod_tools.pyt   __init__   s€    				   
   
	(	
	
c         C   sŸ   | d  k r t j } n  | d It t |  j j ƒ  ƒ t |  j j ƒ  ƒ ƒ IJ| d It |  j ƒ IJ| d It |  j ƒ IJ| d It |  j ƒ IJd  S(   Ns   Number of hkl without cif:s   Number of cif: s   Number of hkl: s   Number of hkl+cif:(	   R   t   syst   stdoutR   t   setR   t   keysR   R   (   R   t   out(    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/cif/cod_tools.pyt   show_summaryH   s     +N(   t   __name__t
   __module__R   R*   R0   (    (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/cif/cod_tools.pyR      s   B(   t
   __future__R    R   R+   t   pathR   t   objectR   (    (    (    sA   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/cif/cod_tools.pyt   <module>   s   	