ó
C™xTc           @   s@  d  d l  m Z d  d l Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l	 m
 Z d  d l m Z d  d	 l m Z d  d
 l m Z d  d l m Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d k r<e e j ƒ d k r2e j d d k r9e ƒ  e d ƒ d GHq9q<e ƒ  n  d S(   iÿÿÿÿ(   t   divisionN(   t   uctbx(   t   sgtbx(   t   flex(   t   crystal(   t   alternative_find_best_cell(   t   miller(   t   pointgroup_tools(   t   approx_equal(   t   StringIOc          C   sv  t  j d ƒ }  t j d d f ƒ } t j |  d ƒ } t j | | ƒ } | j ƒ  } | j	 | ƒ } t
 j j | j ƒ  d d ƒ} | j ƒ  j ƒ  } | j ƒ  } t j | | ƒ }	 |	 j j d d	 ƒ }
 d d	 g } d d
 d	 g } | |
 k só t ‚ | |
 k st ‚ t |
 ƒ d k st ‚ |	 j t t
 j d ƒ ƒ ƒ t |	 j j ƒ d k sWt ‚ |	 j j j d ƒ srt ‚ d  S(   Ns   40, 40, 60, 90.0, 90.0, 90.0i   i   i   i   s   P 1 2 1t	   max_deltag      @s   P 4 2 2s   P 2 2 2i   i   (   i   i   i   (   i   i   i   (   R   t	   unit_cellR   t   miller_indexR   t   symmetryR   t   sett"   change_of_basis_op_to_minimum_cellt   change_basisR   t   lattice_symmetryt   groupt   space_groupt   build_derived_point_groupt   ptt   point_group_grapht   grapht   find_all_pathst   AssertionErrort   lent2   remove_point_group_and_its_super_groups_from_grapht   strt   space_group_infot   node_objectst   has_key(   R   t   mit   xst   mst   cob_min_cellt   ms_newt   lattice_groupt   point_group_lowt   point_group_hight   pgtreet   atlast   route_1t   route_2(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_pointgroup_tools.pyt   tst_pgtools   s,    		c          C   sÄ  t  j d ƒ }  t j d d f ƒ } t j |  d ƒ } t j | | ƒ } t j	 |  | j
 ƒ  ƒ } t j t  j d ƒ d ƒ } t j t  j d	 ƒ d
 ƒ } t j t  j d ƒ d ƒ } t j t  j d ƒ d ƒ } t j t  j d	 ƒ d ƒ }	 i d  t | j ƒ  j ƒ  ƒ d t | j ƒ  ƒ 6d  t | j ƒ  j ƒ  ƒ d t | j ƒ  ƒ 6d  t | j ƒ  j ƒ  ƒ d t | j ƒ  ƒ 6d  t |	 j ƒ  j ƒ  ƒ d t |	 j ƒ  ƒ 6}
 | j j j d j } t | d d j ƒ  j ƒ  | j ƒ  j ƒ  ƒ sìt ‚ | d d j
 ƒ  | j
 ƒ  k st ‚ t | j | d d ƒ j ƒ  j ƒ  | j ƒ  j ƒ  ƒ sPt ‚ | j j j d j } xW | D]O } t | d j ƒ  j ƒ  ƒ d t | d j ƒ  ƒ } |
 j | ƒ smt ‚ qmWd  S(   Ns   40, 50, 60, 90.0, 90.0, 90.0i   i   i   i   s   P 1 1 21s#   40.00 60.00 50.00 90.00 90.00 90.00s   P 1 21 1s#   40.00 50.00 60.00 90.00 90.00 90.00s   P 2 2 21s	   P 21 21 2s#   50.00 60.00 40.00 90.00 90.00 90.00s
   P 21 21 21t    s   P 1 1 2i    i   s   P 2 2 2(   i   i   i   (   i   i   i   (   R   R   R   R   R   R   R   R   R   t"   space_group_graph_from_cell_and_sgR   t   NoneR   t
   parametersR   t   pg_graphR   R   t   allowed_xtal_symsR   R   R   R   (   R   R    R!   R"   t
   tmp_choicet   xs1t   xs2t   xs3t   xs4t   xs5t	   p222_dictt   p112t   p222t   comp_string(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_pointgroup_tools.pyt   tst_sg_tools0   s>    						---0&#4c      
   C   sÿ  d } t  |  ƒ } | | k s$ t ‚ xÔt t j ƒ  ƒ D]À\ } } | | | k rY q7 n  t ƒ  } t j | j ƒ  ƒ } t j d | ƒ j	 d d ƒ } t
 j d | d | ƒ } | j ƒ  } | j | j ƒ  ƒ }	 |	 j ƒ  }
 t j d |
 ƒ } | j ƒ  } | j ƒ  } |	 j | ƒ } t | j ƒ  | j ƒ  ƒ } | j ƒ  } t j j |	 j ƒ  d d	 ƒ} |
 j | ƒ } g  } | j ƒ  r7 d
 Gt j d | ƒ Gd Gt j d | ƒ Gd GHxN|
 D]C} t j ƒ  } | j | ƒ | | k rÞq­n | j | ƒ t
 j |	 j ƒ  d | ƒ} | j | j ƒ  ƒ } t j | j ƒ  | j ƒ  ƒ } t } xŠ | j ƒ  D]| } t } t } t
 j | d d | d ƒ} t | d j ƒ  | j ƒ  j ƒ  d d d | ƒrL| d | k rÈt } qÈqLqLW| s­d G| j ƒ  GH| sðt ‚ q­q­Wq7 q7 Wd  S(   Ni   R   t   volumei9   iL   R   R   R
   g      @s
   Testing : s   ( or s    in reference setting)i    t   epsgü©ñÒMbP?t   outs	   FAILURE: i±  iŒÄ (   t   intR   t	   enumerateR   t   space_group_symbol_iteratorR	   R   t   hallR   t   any_compatible_unit_cellR   R   t	   best_cellR   t!   change_of_basis_op_to_niggli_cellt'   change_of_basis_op_to_reference_settingt   fbcR   t   return_best_xsR   R   t	   is_chiralt
   expand_smxt   appendR   R.   t   Falset   return_likely_sg_and_cellR   R0   t   True(   t
   this_chunkt   n_chunkst   i_chunkt   i_sgt   sgt   bufferR   R   t   xs_int
   xs_minimumt   sg_mint   sg_min_infot   sg_min_to_reft   sg_in_to_mint   xs_reft   best_cell_findert   xs_lattice_pgt   sg_in_ref_settingt   queuet   st   new_sgt   xs_cheatt   xs_cheat_mint   sg_cluest   found_itt	   sg_and_uct   check_sgt   check_ucR!   (    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_pointgroup_tools.pyt   test_extensivelyf   sv    							c       
   C   s§  t  ƒ  }  x—t j ƒ  D]‰} | j ƒ  } | j d d ƒ } t j | d | ƒ} t j | ƒ } t	 | ƒ d k r g  } xl | D]d } t j | j
 | ƒ j ƒ  d | j ƒ  ƒ} t | j ƒ  | j ƒ  ƒ }	 |	 j ƒ  } | j | ƒ q} Wd }
 x± t t	 | ƒ ƒ D]š } x‘ t t	 | ƒ ƒ D]} } | | k r| | j ƒ  | | j ƒ  k sOt ‚ t | | j ƒ  j ƒ  | | j ƒ  j ƒ  d d d	 |  ƒs”t ‚ qqWqþ Wq q Wd  S(   NR>   i9   iL   R   i   i    R?   gü©ñÒMbP?R@   i±  iŒÄ (   R	   R   t   reference_space_group_infosR   RE   R   R   R   t   reference_setting_choicesR   R   R   R   RI   RJ   RM   t   xrangeR   R   R0   (   RV   R   R   t   ucR!   t   cobst	   tmp_arrayt   cobt   xs_newR^   t   countt   tmp_xs1t   tmp_xs2(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_pointgroup_tools.pyt   test_reference_setting_choicesÄ   s4    	c          C   sÏ  t  j d ƒ }  g  t j |  ƒ D] } | j ƒ  ^ q } | d d g k sO t ‚ t  j d ƒ }  g  t j |  ƒ D] } | j ƒ  ^ qn } | d d d d d d g k sª t ‚ t  j d	 ƒ }  g  t j |  ƒ D] } | j ƒ  ^ qÉ } d | k só t ‚ d | k st ‚ d | k st ‚ d | k s)t ‚ d | k s;t ‚ d | k sMt ‚ d
 | k s_t ‚ d | k sqt ‚ d | k sƒt ‚ d | k s•t ‚ d | k s§t ‚ d | k s¹t ‚ d | k sËt ‚ d | k sÝt ‚ d | k sït ‚ d | k st ‚ d | k st ‚ d | k s%t ‚ d | k s7t ‚ d | k sIt ‚ d | k s[t ‚ d | k smt ‚ t  j d ƒ }  g  t j |  ƒ D] } | j ƒ  ^ qŒ} | d d d d d d d g k sËt ‚ d  S(    Ns   P 2xs   x,-y,-zs   x+1/2,-y,-zs   P 2x 2ys   -x,y,-zs   -x,y+1/2,-zs   -x,-y,zs   -x,-y,z+1/2s   P 2x 3*s   z,x,ys   z+1/3,x+1/3,y+1/3s   y,z,xs   y+1/3,z+1/3,x+1/3s   z,-x,-ys   z+1/3,-x-1/3,-y+1/3s   -y,z,-xs   -y-1/3,z+1/3,-x+1/3s   -y,-z,xs   -y+1/3,-z-1/3,x+1/3s   y,-z,-xs   y-1/3,-z-1/3,-x+1/3s   -z,-x,ys   -z-1/3,-x+1/3,y+1/3s   -z,x,-ys   -z-1/3,x-1/3,-y+1/3s   -P -2ys   x,-y,zs
   x+1/2,-y,zs
   x,-y,z+1/2s   x+1/2,-y,z+1/2s   -x,-y,-z(   R   R   R   t   compatible_symmetriest   as_xyzR   (   t   pgt   opt   ops(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_pointgroup_tools.pyt   exercise_compatible_symmetriesæ   sH    ((	((c           C   s%   t  ƒ  t ƒ  t ƒ  t ƒ  d GHd  S(   Nt   OK(   R}   R,   R=   Rw   (    (    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_pointgroup_tools.pyt   run  s
    t   __main__i   t   insanei    R~   (   t
   __future__R    t   syst   cctbxR   R   t   cctbx.array_familyR   R   t   cctbx.crystal.find_best_cellR   RI   R   t   cctbx.sgtbxR   R   t   libtbx.test_utilsR   t	   cStringIOR	   R,   R=   Rk   Rw   R}   R   t   __name__R   t   argv(    (    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_pointgroup_tools.pyt   <module>   s.   	#	6	^	"	3	
