ó
‚™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  d l
 m Z d  d l m Z d  d l m Z m Z d  d	 l m Z d  d
 l Z d  d l m Z d  d
 l Z e d „ Z e d „ Z d d „ Z e d k re d e j d ƒ n  d
 S(   iÿÿÿÿ(   t   division(   t   sgtbx(   t   pointgroup_tools(   t   sub_lattice_tools(   t   crystal(   t   option_parser(   t   easy_run(   t   Sorryt	   multi_out(   t   show_stringN(   t   StringIOc         C   s·  | d  k r t j } n  t j |  | | ƒ } | d IJ| d IJ| J| d IJ| d IJ| d IJ| d I|  j ƒ  IJ| d I|  j ƒ  IJ| d It j d | ƒ IJ| J| J| d	 IJ| d
 IJ| d	 IJ| d I| j	 j
 ƒ  j ƒ  IJ| d I| j	 j
 ƒ  j ƒ  IJ| d I| j	 j ƒ  IJ| d It j d | j ƒ IJ| J| J| d IJ| d IJ| d IJ| d IJ| d IJ| d IJ| d IJ| J| j ƒ  | j d | ƒ | S(   NsD   A summary of the constructed point group graph object is given belowsD   ====================================================================s   ----------------------s   Input crystal symmetrys   Unit cell: s   Unit cell volume: s   Space group: t   groups   --------------------------s   Lattice symmetry deductions   Niggli cell: s   Niggli cell volume: s#   Niggli transformed input symmetry: s   Symmetry of Niggli cell: sD   All pointgroups that are both a subgroup of the lattice symmetry andsH   a supergroup of the Niggli transformed input symmetry wil now be listed,sC   as well as their minimal supergroups/maximal subgroups and symmetrys   operators that generate them.sE   For each pointgroup, a list of compatible spacegroups will be listed.sF   Care is taken that there are no systematic absence violation with the s   provided input spacegroup.t   out(   t   Nonet   syst   stdoutt   pgtt"   space_group_graph_from_cell_and_sgt
   parameterst   volumeR   t   space_group_infot   xs_prim_sett	   unit_cellt   pg_hight   flusht   show(   t   input_uct   input_lst	   max_deltaR   t   sg_explorer(    (    sX   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/explore_metric_symmetry.pyt   do_pointgroup_tricks   sJ    	















c         C   sÿ   | d  k r t j } n  t j j d d ƒ } | d  k rH t d ƒ ‚ n  t ƒ  } |  j d | ƒ d t	 | ƒ t	 | ƒ f } t
 j d | d | j ƒ  j ƒ  ƒ } | j d k rÕ t d | d	 j | j ƒ f ƒ ‚ n  | d
 It	 | ƒ Id IJ| d IJd  S(   Nt   commandt   dots_   The program "dot" is not on PATH:
  For information about "dot" visit: http://www.graphviz.org/R   s   %s -Tpng > %st   stdin_linesi    s   Fatal error running %s:
%ss   
s   A file nameds$   contains a graphical representation s   of the point group relations.(   R   R   R   t   libtbxt   patht   full_command_pathR   R
   t   graphviz_pg_graphR	   R   t   fully_bufferedt   getvaluet
   splitlinest   return_codet   RuntimeErrort   joint   stderr_lines(   t	   pg_objectt	   file_nameR   t   dot_patht   bufferR   t   rc(    (    sX   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/explore_metric_symmetry.pyt   make_graph_of_graphD   s$    			s   phenix.explore_metric_symmetryc         C   s%  t  d | d d d ƒ j ƒ  j d  d d d d d	 d
 d d d d d d d ƒj d  d d d d d d
 t d d ƒj d  d d d d
 d  d d ƒj d  d d d d d d d ƒj d  d d d d d d d d d ƒj d  d d d d d d d ƒj d  d  d d d d d d ƒj d  d! d d d d" d
 t d d# ƒj d  d$ d d d d	 d d% d
 d& d d d d' ƒj d  d( d d d d) d d	 d
 d* d d d d+ ƒj d  d, d d d d- d
 d. d d/ d d0 ƒj d1 |  ƒ } t ƒ  } | j d2 d3 d4 t j	 ƒ i d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6dA dB 6} | j
 j d  k	 rn| j | j
 j ƒ sn| dC | j
 j IJ| dD IJd  Sn  d  } d  } t |  ƒ dE k r�| j j ƒ  d  S| j j ƒ  d  k rÕ| J| dF IJ| J| j j ƒ  d  S| j
 j d  k r"| j j ƒ  d  k r"| J| dG IJ| J| j j ƒ  d  Sn  | j j ƒ  d  k	 r]| j j ƒ  j ƒ  s]| dH IJd  Sn  | j
 j d  k	 r¦t j dI | j j ƒ  dJ dK | j
 j ƒ } | | _ n  | j
 j rõ| dL IJ| j j | j j ƒ  ƒ j ƒ  } t j | dM ƒ | _ n  | j } | j
 j s_t | j ƒ  | j ƒ  | j
 j | ƒ } | j
 j d  k	 r_t | | j
 j | ƒ q_n  | j
 j d  k	 r!| dN IJd  } | j
 j d  k rÜ| j
 j  d  k r´t! dO ƒ ‚ qýt j | j
 j dJ dK | j
 j  ƒ} n! t j | j
 j dJ | j
 j ƒ} | j
 j s3t | j ƒ  | j ƒ  | j
 j | ƒ }	 n  | J| J| dP IJ| dQ IJ| J| dR IJ| dS IJ| dT IJ| J| J| j
 j" }
 |
 d. k rÖt# j$ dU | dV | d | j
 j dW | dX | j
 j% dY | j
 j& ƒ } q!| j | j ƒ  ƒ } | j | j ƒ  ƒ } d  } | j
 j" }
 d  } | j ƒ  j' ƒ  | j ƒ  j' ƒ  k rWt# j( | |
 ƒ } | } n t# j( | |
 ƒ } | } | J| dZ IJ| J| d[ IJ| | j) j* ƒ  IJ| J| d\ IJ| Jxnt+ | j, | j- | j. ƒ D]N\ } } } | j/ ƒ  } | d] IJ| d^ IJ| J| d_ | dE dE | dE d. | dE d` f IJ| da | d. dE | d. d. | d. d` f IJ| db | d` dE | d` d. | d` d` f IJ| J| dc IJ| dd I| j* ƒ  IJ| de IJ| j0 df | dg dh ƒ | J| Jt# j$ dU | dV | d | j
 j dW | dX | j
 j% dY | j
 j& ƒ } qÌWn  d  S(i   Nt   usages
    [options]t   descriptions  Explore Metric Symmetry. A list of possible unit cells and spacegroups is
given for the given specified unit cell and spacegroup combination. If a
second unit cell is given, linear combinations of the basis vector of one
unit cell are sought that match the other.s   --max_deltat   actiont   storet   typet   floatt   defaultg      @t   destR   t   helps|   Maximum delta/obliquity used in determining the lattice symmetry, using a modified Le-Page algorithm. Default is 5.0 degreest   metavart   FLOATs   --start_from_p1t
   store_truet   nigglis^   Reduce to Niggli cell and forget the input spacegroup before higher metric symmetry is sought.s   --graphsk   A graphical representation of the graph will be written out. Requires Graphviz to be installed and on PATH.s   --centring_typet   strs(   Centring type, choose from P,A,B,C,I,R,Fs   --other_unit_cells)   Other unit cell, for unit cell comparisons   10,20,30,90,103.7,90s   --other_space_groups9   space group for other_unit_cell, for unit cell comparisons   --other_centring_types   --no_point_group_grapht   pg_graphs9   Do not carry out the construction of a point group graph.s   --relative_length_tolerances;   Tolerance for unit cell lengths to be considered equal-ish.gš™™™™™¹?t   rel_length_tols   --absolute_angle_tolerancet   abs_angle_tolg      $@s)   Angular tolerance in unit cell comparisons   --max_ordert   inti   t   INTs%   Maximum volume change for target cellt   argst   labelR   t   file_objectt	   Primitivet   Ps
   A centeredt   As
   B centeredt   Bs
   C centeredt   Cs   Body centeredt   It   Rombohedralt   Rs   Face centeredt   Fs)   Sorry, the centring type %s is not known.s   Choose from P,A,B,C,I,R,F i    s   Sorry: Unit cell not specified.s2   Sorry: centring type or space group not specified.s1   Sorry, Non chiral space groups not yet supported.R   t   space_group_symbols
   Hall: %s 1s9   *Unit cell will be niggli reduced and P1 will be assumed*s   P 1s'   A second unit cell has been specified. s9   No space group or centring type for other cell specified.s   Unit cell comparisons   --------------------s:   The unit cells will be compared. The smallest niggli cell,s9   will be used as a (semi-flexible) lego-block to see if its%   can construct the larger Niggli cell.t   xs_at   xs_bR   t   relative_length_tolerancet   absolute_angle_tolerancesF   Volume change of largest niggli cell requested via keyword --max_ordersJ   Input crystal symmetry is tranformed to niggli setting using the operator:sA   Comparisons for various sublattices of the target cell are listedsC   ===================================================================s%   Niggli cell is expanded using matrix:s                   /%4i %4i %4i  \  i   s              M =  |%4i %4i %4i  |  s                   \%4i %4i %4i  /  s.   Change of basis operator to reference setting:s       s   resulting crystal symmetry:t   ft   prefixs      (1   R   t   enable_symmetry_comprehensivet   optionR   t   Falset   processR   t   registerR   R   t   optionst   centring_typet   has_keyt   lent   parsert	   show_helpt   symmetryR   R   t   space_groupt	   is_chiralR   R?   t   change_basist!   change_of_basis_op_to_niggli_cellRA   R   R   t   graphR2   t   other_unit_cellt   other_space_groupt   other_centring_typeR   t	   max_ordert   sltt   compare_latticeRB   RC   R   t"   make_list_of_target_xs_up_to_ordert   basic_to_niggli_cb_opt   as_xyzt   zipt   xs_listt   extra_cb_opt   matricest   as_list_of_listst   show_summary(   RF   t   command_namet   command_linet   logt   allowed_centring_typest   xst   other_xst   ucR-   t   other_pg_objectt   ordert	   sl_objectt   tmp_at   tmp_bt   modified_xst
   lego_blockt   tmp_xst   cb_opt   mat(    (    sX   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/explore_metric_symmetry.pyt   run`   s€   
																							





	
						
		




$	




///

t   __main__RF   i   (   t
   __future__R    t   cctbxR   t   cctbx.sgtbxR   R   R   Rn   R   t   iotbx.option_parserR   R"   R   t   libtbx.utilsR   R   t   libtbx.str_utilsR	   t   libtbx.patht	   cStringIOR
   R   R   R   R2   RŠ   t   __name__t   argv(    (    (    sX   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/explore_metric_symmetry.pyt   <module>   s"   2ÿ 