ó
‚™xTc           @   s­   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 e j	 j
 d ƒ Z d d d d „ Z d „  Z d „  Z e d k r© e d	 e j d
 ƒ n  d S(   iÿÿÿÿ(   t   divisionN(   t   Sorrys(  
reindex
  .caption = This utility will reindex the contents of an MTZ file     using a given change-of-basis operator.  For instance, to convert a     file with symmetry P22121 to P21212, the operator c,a,b could be used.     (If your reflections are in a format other than MTZ, you can convert them     in the reflection file editor, which also supports change-of-basis     operations.)
  .style = box auto_align caption_img:icons/custom/phenix.reflection_file_editor.png
{
  hkl_file = None
    .type = path
    .short_caption = MTZ file
    .style = bold file_type:hkl input_file
  output_file = None
    .type = path
    .short_caption = Output file
    .style = new_file file_type:hkl
  change_of_basis = None
    .type = str
    .short_caption = Change of basis
    .input_size=100
    .style = bold
}c      	   C   sE  | d  k r t j } n  | d  k r„ t |  ƒ d k rE t d ƒ ‚ n  d d  l } | j j d |  d t d d ƒ } | j	 j
 ƒ  } n  t | ƒ t | j j ƒ } d d l m } | j | j j ƒ } | j j } g  }	 d	 d
 d g }
 g  } xC | D]; } |
 j | j ƒ  j ƒ | j d | ƒ } |	 j | ƒ qó W|	 d j d d ƒ } xC t |	 d ƒ D]1 \ } } | j d | d d t j | d ƒ qYW| j ƒ  } x1 t | j  ƒ  ƒ D] \ } } | j! |
 | ƒ q­W| j j" d  k rt# j$ j% | j j ƒ \ } } | d | j _" n  | j& d | j j" ƒ | d | j j" IJ| j j" S(   Ni    sá   
phenix.reindex data.mtz change_of_basis=<operator>

Change-of-basis operator: h,k,l or x,y,z or
                          to_reference_setting, to_primitive_setting,
                          to_niggli_cell, to_inverse_hand
iÿÿÿÿt   argst   master_philt   reflection_file_defs   reindex.hkl_file(   t   file_readert   Ht   Kt   Lt   cb_opt   column_root_labelt   Ai   t   miller_arrays   %ss   _reindex.mtzt	   file_names!   Reindex reflections written to %s('   t   Nonet   syst   stdoutt   lent   Usaget
   iotbx.philt   philt   process_command_line_with_filesR   t   workt   extractt   validate_paramst   convert_operatort   reindext   change_of_basist   iotbxR   t   any_filet   hkl_filet   file_servert   miller_arrayst   extendt   infot   labelst   change_basist   appendt   as_mtz_datasett	   enumeratet   add_miller_arrayt   stringt	   uppercaset
   mtz_objectt   columnst	   set_labelt   output_filet   ost   patht   splitextt   write(   R   t   paramst   outR   t   cmdlineR	   R   t   hkl_inR    t
   new_arraysR#   t   warningst   arrayt   mtz_outt   it   mtz_objt   columnt   baset   ext(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/reindex.pyt   run#   sN    	
		c         C   sS   d d l  m } y | j |  ƒ } Wn% t k
 rJ } t t | ƒ ƒ ‚ n X| Sd  S(   Niÿÿÿÿ(   t   sgtbx(   t   cctbxRA   t   change_of_basis_opt   RuntimeErrorR   t   str(   R   RA   t   c_o_bt   e(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/reindex.pyR   Q   s    c         C   sV   |  j  j d  k r! t d ƒ ‚ n  |  j  j d  k rB t d ƒ ‚ n t |  j  j ƒ t S(   Ns"   Please specify a reflections file.s*   Please specify a change-of-basis operator.(   R   R   R   R   R   R   t   True(   R3   (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/reindex.pyR   Z   s    t   __main__R   i   (    (   t
   __future__R    t   libtbx.philt   libtbxt   libtbx.utilsR   R)   R/   R   R   t   parseR   R   R@   R   R   t   __name__t   argv(    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/reindex.pyt   <module>   s   		.				