ó
:™xTc           @   s˜   d  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 Z d „  Z d	 „  Z e d
 k r” e e j d ƒ n  d S(   sˆ  
Rough script, generating space-group subgroups including super cells.
Shows the Universal Hermann-Mauguin Symbol (Zwart et al., 2008) for all
subgroups.

LIMITATION of the current implementation: settings with
fractional rotation matrix elements cannot be handled.

References:
  Grosse-Kunstleve (1999). Acta Cryst. A55, 383-395.
  Zwart et al. (2008). Acta Cryst. D64, 99-107. Section 2.1
iÿÿÿÿ(   t   division(   t   sgtbx(   t   Usage(   t   show_sorted_by_counts(   t   dict_with_default_0Nc            sW  ˆ  j  ƒ  d k s t ‚ x8t d |  d ƒ D]#} xt d |  d ƒ D]} xü t d |  d ƒ D]ç } t j d | | | f ƒ } y ˆ  j d | ƒ } Wni t k
 r} t | ƒ j d ƒ rÒ | d c d 7<qGt | ƒ j d ƒ rú | d c d 7<qGt ‚ q` X‡  f d †  }	 |	 | ƒ }
 t j	 d	 |
 ƒ j
 ƒ  } | | c d 7<q` WqF Wq, Wd  S(
   Ni   s   x/%d,y/%d,z/%dt   cb_ops.   Unsuitable value for rational rotation matrix.t!   incompatible_rotation_denominators1   Unsuitable value for rational translation vector.t$   incompatible_translation_denominatorc            su   t  j d d d ˆ  j ƒ  ƒ } xP t |  j ƒ  ƒ D]< } x3 t |  j ƒ  ƒ D] } | j |  d | | ƒ ƒ qJ Wq1 W| S(   Nt   hall_symbolt   P1t   t_deni    (   R   t   space_groupR
   t   xranget   f_invt   n_smxt
   expand_smx(   t   gt   resultt   i_invt   i_smx(   t   subgroup(    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/space_subgroups.pyt   remove_lattice_translations'   s    	!t   group(   t   n_ltrt   AssertionErrorR   R   t   change_of_basis_opt   change_basist   RuntimeErrort   strt   endswitht   space_group_typet    universal_hermann_mauguin_symbol(   t	   max_indext   all_subgroupsR   t   iat   ibt   icR   t
   scsubgroupt   eR   t   subsubgroupt   uhm(    (   R   sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/space_subgroups.pyt   loop_over_super_cells   s&    		
c      	   C   sè  t  |  ƒ d k r! t d ƒ ‚ n  t |  d ƒ } d G| GH| d k sL t ‚ Hd } t j d |  d d | ƒ } | j ƒ  H| j ƒ  } | j d	 | ƒ } | j	 ƒ  | j	 ƒ  k rÃ d
 GH| j ƒ  Hn  t
 ƒ  } | j	 ƒ  } | j ƒ  } | j ƒ  r| d d d ƒ j ƒ  }	 n d  }	 x½ | D]µ }
 t j d d d | ƒ } | j |
 ƒ x‡ | D] } t j | ƒ } | j | ƒ t d | d | d | ƒ |	 d  k	 rJt j | ƒ } | j |	 ƒ t d | d | d | ƒ qJqJWqWt d | j ƒ  ƒ d  S(   Ni   sp   cctbx.python space_subgroups.py max_index space_group_symbol
  Example: cctbx.python space_subgroups.py 2 P41212i    s
   max_index:i   i�   t   symbolt   space_group_t_denR   s   Primitive setting:R   R	   R
   R    R!   R   t   label_count_pairs(   t   lenR   t   intR   R   t   space_group_infot   show_summaryt'   change_of_basis_op_to_primitive_settingR   R   R   t   build_derived_acentric_groupt
   is_centrict   tt   NoneR   R   R)   t
   expand_invR   t   items(   t   argsR    R+   t   sginfot
   cb_op_to_pt   sginfo_pR!   t   sg_pt   sg_p_at   inv_mxt   symx1t   subgr1t   symx2t   subgr2t   subgr3(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/space_subgroups.pyt   run3   sL    		

	t   __main__i   (   t   __doc__t
   __future__R    t   cctbxR   t   libtbx.utilsR   t   libtbx.str_utilsR   t   libtbxR   t   sysR)   RD   t   __name__t   argv(    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/space_subgroups.pyt   <module>   s   		-