ó
J™xTc           @   s´   d  d l  m Z d  d l m Z d  d l m Z d  d l Z d  d l m Z d  d l	 Z
 d  d l Z d  d l Z d „  Z d „  Z d d	 d
 „ Z d „  Z e d k r° e ƒ  n  d S(   iÿÿÿÿ(   t   division(   t   strudat(   t   crystalN(   t   iotbx_option_parserc         C   sz  |  j  d | ƒ } t j j d | ƒ } | j d | ƒ t j j d | d | ƒ } t j j j d | d | ƒ } |  j ƒ  } | j	 ƒ  j
 d | ƒ }	 t j j j d |	 d | d | ƒ }
 | r'd GHt j j j d	 |  d
 | ƒ Hd GHt j j j d	 |  d
 | ƒ Hd GHt j j j d	 |  d
 |
 ƒ Hn  xL | |
 g D]> } x5 t | | ƒ D]$ \ } } | t | ƒ k sJt ‚ qJWq4Wd  S(   Nt   buffer_thicknesst   asu_mappingst   distance_cutofft   pair_asu_tablet	   max_shellt   site_symmetry_tablet   full_pair_sym_tables   term_table_slow:t	   structuret
   term_tables   term_table_simple_asu:s   term_table_simple_sym:(   R   t   cctbxR   R   t   add_all_pairst   coordination_sequencest   simple_and_slowt   simpleR	   t   extract_pair_sym_tablet   full_connectivityt
   simple_symt
   show_termst   zipt   listt   AssertionError(   R   R   R   t   verboseR   R   t   term_table_slowt   term_table_simple_asuR	   R
   t   term_table_simple_symt   term_table_simplet
   terms_slowt   terms_simple(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_coordination_sequences.pyt   exercise_simple	   sL    								c         C   sX  |  j  d d ƒ } t j d | ƒ } | j d d ƒ t j j d | d d ƒ } |  j ƒ  } | j ƒ  j d	 | ƒ } t j j	 d
 | d	 | d d ƒ } g  | D] } | j
 d	 | ƒ ^ q› }	 t }
 x» t | d |	 d ƒ D]¢ \ } } x“ t | | ƒ D]‚ \ } } | j ƒ  | j ƒ  k st ‚ | ró |
 ró xH | j ƒ  D]7 \ } } | | } t | ƒ t | ƒ k r7t }
 q7q7Wqó qó Wq× W|
 r«d GHd GH| j ƒ  Hd GH| j ƒ  Hn  x¦t | |	 ƒ D]•\ } } d sÓ| r|  j d | ƒ j } t | j ƒ GH| j | j ƒ  k st ‚ Hn  | j d t ƒ } t j d | ƒ } | j d | ƒ d sU| r²|  j d | ƒ j } t | j ƒ GH| j | j ƒ  k s“t ‚ H| j j | j ƒ s²t ‚ n  | | k sÄt ‚ | j ƒ  j
 d	 | ƒ } d d l m } | ƒ  } | j d | ƒ | ƒ  } | j d | ƒ d d l m } | | j ƒ  | j ƒ  ƒ s»t ‚ q»Wd  S(   NR   i
   R   R   g      @R   R   i   R	   R
   i   s=   crystal.coordination_sequences.shell_sym_tables redundancies:s	   original:s   tidy:i    t   skip_j_seq_less_than_i_seqt	   sym_tableiÿÿÿÿ(   t   StringIOt   f(   t	   show_diff(   R   R   R   R   R   t   shell_asu_tablesR	   R   R   t   shell_sym_tablest   tidyt   FalseR   t   keysR   t   itemst   lent   Truet   showt   show_distancest   distances_infoR   t   pair_countst   add_pair_sym_tablet   all_eqt	   cStringIOR#   t   libtbx.test_utilsR%   t   getvalue(   R   R   R   t   bond_asu_tableR&   R	   R
   t   shell_sym_tables_origt   _R'   t   have_redundanciest   o_pstt   t_pstt   o_pair_sym_dictt   t_pair_sym_dictt   j_seqt	   o_sym_opst	   t_sym_opst   shell_asu_tablet   shell_sym_tablet   pairs_1R"   t	   asu_tablet   pairs_2t   shell_sym_from_asu_tableR#   t   sio_symt   sio_asuR%   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_coordination_sequences.pyt   exercise_shell_asu_tables1   sv    			"$


					g      @i   c   
      C   s\  t  ƒ  j d  d d d d d ƒj d  d d d ƒj d  d d d ƒj d	 |  ƒ } | j } t j j d
 d d t j	 j
 ƒ } | d  k r� d GHd  St j t | ƒ ƒ } x° t | j ƒ D]Ÿ \ } } | j ƒ  }	 | j d  k	 r÷ | j | j k rqµ qn | j p| d d k sqµ n  | j r.d G| j GHn  t |	 | | | j ƒ t |	 | j ƒ qµ Wd  S(   Ns   --tagt   actiont   storet   typet   strings   --fullt
   store_trues	   --verboset   argst   relative_paths,   phenix_regression/misc/strudat_zeolite_atlast   tests-   Skipping exercise(): input file not availablei   i    s   strudat tag:(   R   t   optiont   Nonet   processt   optionst   libtbxt   envt   find_in_repositoriest   ost   patht   isfileR   t   read_all_entriest   opent	   enumeratet   entriest   as_xray_structuret   tagt   fullR   R    RJ   (
   RP   R   R   t   command_linet   cot
   atlas_filet   all_entriest   it   entryR   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_coordination_sequences.pyt   exercisep   s:    										c           C   s   t  t j d ƒ d GHd  S(   Ni   t   OK(   Rj   t   syst   argv(    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_coordination_sequences.pyt   run�   s    t   __main__(   t
   __future__R    t   iotbx.kriberR   R   R   t$   cctbx.crystal.coordination_sequencest   iotbx.option_parserR   t   libtbx.load_envRW   Rl   RZ   R    RJ   Rj   Rn   t   __name__(    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_coordination_sequences.pyt   <module>   s   	(	?	