ó
=™xTc           @   sœ   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 d „  Z d „  Z d S(   iÿÿÿÿ(   t   division(   t   sgtbx(   t   harker(   t   io_utils(   t	   cgi_utilsc         C   s  t  j |  d
 d f ƒ } g  | _ g  | _ |  j d ƒ r|  d j j d ƒ } x¾ | D]³ } | j ƒ  } | d  j ƒ  } | d k r› | j j	 | d ƒ qV | d k rÄ | j j	 | d j ƒ  ƒ qV xB | j d	 ƒ D]1 } | j ƒ  } | d k rÔ | j j	 | ƒ qÔ qÔ WqV Wn  | S(   Nt   sgsymbolt    t
   conventiont   symxyzs   
i   t   LATTt   SYMMt   ;(   s   sgsymbolR   (   s
   conventionR   (
   R   t   inp_from_formt
   shelx_lattR   t   has_keyt   valuet   splitt   stript   uppert   append(   t   formt   inpt   linest   lt   st   CARD(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   interpret_form_data
   s&    			 c         C   s   d |  S(   Ns
   [%d,%d,%d](    (   t   ev(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   str_ev!   s    c           C   s'   d GHd GHd GHd GHd GHd GHd GHd  S(   Ns   <tr>s
   <th>Matrixs   <th>Rotation-part types   <th>Axis directions   <th>Screw/glide components   <th>Origin shifts   </tr>(    (    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   rt_mx_analysis_header$   s    c         C   s7  d GHd t  |  ƒ d GHt j |  j ƒ  ƒ } t j |  ƒ } | j ƒ  d k rV d GHnØ | j ƒ  d k rŒ d | j ƒ  t  | j ƒ  ƒ f GHn¢ t | j ƒ  ƒ d k ræ d	 | j ƒ  t | j	 ƒ  ƒ t  | j
 ƒ  ƒ t  | j ƒ  ƒ f GHnH d
 | j ƒ  | j ƒ  t | j	 ƒ  ƒ t  | j
 ƒ  ƒ t  | j ƒ  ƒ f GHd GHd  S(   Ns   <tr>s   <td><tt>s   </tt>i   s   <td>1<td>-<td>-<td>-iÿÿÿÿs   <td>%d<td>-<td>-<td>%si   s   <td>%d<td>%s<td>%s<td>%ss   <td>%d^%d<td>%s<td>%s<td>%ss   </tr>(   t   strR   t   rot_mx_infot   rt   translation_part_infot   typet   origin_shiftt   absR   R   t   intrinsic_partt   sense(   R   t   r_infot   t_info(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   rt_mx_analysis-   s.    				c         C   s"  |  j  ƒ  } d G| j ƒ  GH| j ƒ  r/ d GHn d GH| j ƒ  rH d GHn  |  j ƒ  r\ d GHn  d G| j ƒ  GHd G| j ƒ  GHHd GHy t j |  ƒ } Wn t	 k
 r± } d	 G| GHn( Xd	 Gt
 | ƒ j d
 d ƒ j d d ƒ GHHd GHd GHt | _ t ƒ  x | D] } t | ƒ qû Wd GHt | _ Hd  S(   Ns   Number of lattice translations:s   Space group is centric.s   Space group is acentric.s   Space group is chiral.s   Space group is enantiomorphic.s-   Number of representative symmetry operations:s$   Total number of symmetry operations:s-   Parallelepiped containing an asymmetric unit:t    t   <s   &lt;t   >s   &gt;s   List of symmetry operations:s$   </pre><table border=2 cellpadding=2>s   </table><pre>(   t   groupt   n_ltrt
   is_centrict	   is_chiralt   is_enantiomorphict   n_smxt   order_zR   t   brickt   RuntimeErrorR   t   replacet   Truet   in_tableR   R)   t   False(   t   sg_typet   statust   sgR4   t   eR   (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   show_group_genericG   s8     '	 	c         C   s7  d G|  j  ƒ  GHd G|  j ƒ  GHd G|  j ƒ  GH|  j ƒ  } | d k r‘ | d k r] d G| GHq‘ | d k rq d GHq‘ | d	 k r… d
 GHq‘ t d ‚ n  |  j ƒ  } | d k r|  j  ƒ  d k  r| d d k râ | d  } | d } n | } d } d G| GH| d k rd G| GHqqd G| GHn  d G|  j ƒ  j ƒ  GHd  S(   Ns     Space group number:s     Schoenflies symbol:s     Hermann-Mauguin symbol:t    t   12s     Origin choice:t   Hs     Trigonal using hexagonal axest   Rs"     Trigonal using rhombohedral axess   Internal errorR   i   iÿÿÿÿt   123s     Unique axis:s     Cell choice:s     Relation to standard setting:s     Hall symbol:(   t   numbert   schoenfliest   hermann_mauguint	   extensionR5   t	   qualifiert   hallR   (   t   symbolsR=   t   qt   unique_axist   cell_choice(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   show_symbolse   s2    
	c         C   s  i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6} i  } x" | j  ƒ  D] } | | | | <qJ Wy  t | ƒ } | t | ƒ } Wn$ t k
 r¨ t d t | ƒ ‚ n Xd t | ƒ d GH| d k ræ d GH|  j t j d ƒ ƒ n  d t | ƒ d GH|  j	 | ƒ Hd  S(   Ni   t   Pi   t   Ii   RB   i   t   Fi   t   Ai   t   Bi   t   Cs   Format Error: LATT s   Addition of SHELX LATT t   :i    s0     Addition of centre of inversion at the origin.s   -x,-y,-zs5     Addition of lattice translations for centring type t   .(
   t   keyst   intR$   t	   ExceptionR5   R   t
   expand_smxR   t   rt_mxt!   expand_conventional_centring_type(   R<   t   n_fldt   z_dictt   n_dictt   zt   n(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   expand_shelx_lattƒ   s.    
 c         C   s0  d GHt  j | j | j ƒ d  } | j } | d k r? d } n  | j d k rW | } nU t j | | j ƒ } | j ƒ  } | j ƒ  d k rœ d  } d | _ n d GHt	 | ƒ Hy" t j
 | ƒ } t j | ƒ } Wn@ t k
 r} d | j ƒ  d GHd	 | j ƒ  d
 d GH‚  n Xt | j ƒ d k rJx! | j D] }	 t | |	 ƒ q0Wn  t | j ƒ d k r)d GHd GHt | _ t ƒ  x› | j D]� }
 t j
 |
 ƒ } y t j | ƒ }
 WnN t k
 rû} d GHt | _ d | j ƒ  d GHd	 | j ƒ  d
 d GH‚  n Xt |
 ƒ | j |
 ƒ qƒWd GHt | _ Hn  | j ƒ  } t | | ƒ | j d k s{t | j ƒ d k s{t | j ƒ d k rR| j ƒ  } | j ƒ  d k rÙ| d  k s½| j ƒ  | j ƒ  k rÐd GHt	 | ƒ HqOd GHHqRd G| j ƒ  GHd Gt j | j ƒ  ƒ j ƒ  GHd G| j ƒ  GHd G| j ƒ  GHd G| j  ƒ  j! ƒ  GHd G| j  ƒ  j" ƒ  GHHn  t j# | ƒ } d GHd GHt | _ d GHd GHd GHd GHd GHd GHxf t$ | j% ƒ  ƒ D]R } | j& | ƒ } d GHd | j' ƒ  | j( ƒ  | j) ƒ  t* | j+ ƒ  ƒ f GHd GHq¥Wd GHt | _ Hd GHd GHt | _ d GHd  GHd! GHd" GHd GHt, j- | ƒ } xE | j. D]: } d GHd# | j/ ƒ  t0 | j1 ƒ t* | j2 ƒ f GHd GHqOWd GHt | _ Hd$ GHt j3 | ƒ } | j4 ƒ  } d% Gt | ƒ GHt | ƒ rd& GHx$ | D] } d' G| j5 G| j6 GHqãWn  | j7 t t ƒ } | j7 t t ƒ } t | ƒ rjd( Gt | ƒ d) k sOt8 ‚ t j9 | d ƒ j: ƒ  GHn  t | ƒ r¼d* GHd GHt | _ t ƒ  x | D] }
 t |
 ƒ q—Wd GHt | _ n  Hd+ GH| j; ƒ  } | j; ƒ  } | j< t t ƒ } | j= | ƒ } d, G| GHd- G| GHd. G| GHHd/ GHd0 GHd1 GHHd2 GHd  S(3   Ns   <pre>R   s   P 1t   Halli    s   Result of symbol lookup:s   --&gt;s   &lt;--t   -i   t   ^s    Addition of symmetry operations:s$   </pre><table border=2 cellpadding=2>s   </table><pre>s   Symmetry operations match:s-   Additional symmetry operations are redundant.s   Space group number:s$   Conventional Hermann-Mauguin symbol:s$   Universal    Hermann-Mauguin symbol:s   Hall symbol:s   Change-of-basis matrix:s                  Inverse:s   List of Wyckoff positions:s   <tr>s   <th>Wyckoff letters   <th>Multiplicitys%   <th>Site symmetry<br>point group types,   <th>Representative special position operators   </tr>s!   <td>%s<td>%d<td>%s<td><tt>%s</tt>s   Harker planes:s   <th>Algebraics   <th>Normal vectors   <th>A point in the planes   <td><tt>%s</tt><td>%s<td>%ss.   Additional generators of Euclidean normalizer:s6     Number of structure-seminvariant vectors and moduli:s       Vector    Moduluss      s      Inversion through a centre at:i   s     Further generators:s#   Grid factors implied by symmetries:s     Space group:s,     Structure-seminvariant vectors and moduli:s     Euclidean normalizer:s4     All points of a grid over the unit cell are mappeds4     exactly onto other grid points only if the factorss&     shown above are factors of the grid.s   </pre>(>   R   t   show_input_symbolR   R   t   NoneR   t   space_group_symbolsRI   RD   RN   t   parse_stringt   space_groupR5   t   stringt   wheret   lenR   Rb   R   R7   R8   R   R[   R9   R)   RZ   R"   R>   t   match_tabulated_settingst   universal_hermann_mauguint    universal_hermann_mauguin_symbolt   hall_symbolt   cb_opt   ct   c_invt   wyckoff_tablet   xranget   sizet   positiont   lettert   multiplicityt   point_group_typeR   t   special_op_simplifiedR   t   planes_fractionalt   listt	   algebraicR   Ra   t   pt   structure_seminvariantst   vectors_and_modulit   vt   mt'   addl_generators_of_euclidean_normalizert   AssertionErrorR!   R#   t   griddingt.   expand_addl_generators_of_euclidean_normalizert   refine_gridding(   t   server_infoR   R;   t   symbols_inpt   lookup_symbolRq   t   psR<   R=   R]   R   R:   t   symbols_matchRu   t
   i_positionRx   t   planest   planet   sst   ss_vmt   vmt   k2lt   l2nt   grid_sgt   grid_sst   eucl_sgt	   grid_eucl(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   runœ   s&   	 		
		
		
							'		 	 			N(   t
   __future__R    t   cctbxR   t   cctbx.sgtbxR   t	   cctbx.webR   R   R   R   R   R)   R>   RN   Rb   R›   (    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/web/explore_symmetry.pyt   <module>   s   								