ó
‚™xTc           @   s³   d  d l  m Z d  d l m Z d  d l Z d  d l m Z d  d l m Z d  d l m	 Z	 m
 Z
 m Z m Z d  d l Z d  d l Z d „  Z e d k r¯ e e j d	 ƒ n  d S(
   iÿÿÿÿ(   t   division(   t   cnsN(   t   crystal_symmetry_from_any(   t   show_string(   t   Sorryt   Usaget   plural_st   detect_binary_filec         C   s  t  |  ƒ d k r! t d ƒ ‚ n  x9 |  D]1 } t j j | ƒ s( t d t | ƒ ƒ ‚ q( q( W|  \ } } t j | ƒ } | d  k r� t d t | ƒ ƒ ‚ n  t
 j j d | j ƒ  ƒ } | d  k ré t d t t | j ƒ  ƒ ƒ ƒ ‚ n  d | } g  | j ƒ  j ƒ  D] } d | ^ q\ } }	 }
 } } } d	 d
 d d d d d g } t t | d g t  | ƒ ƒ ƒ } g  } g  } t d d ƒ } y t | ƒ j ƒ  j ƒ  } Wn5 t k
 rÙ} t d t | ƒ t | ƒ f ƒ ‚ n Xt } x@| D]8} | d  k	 rB| j d | ƒ } | d  k	 rB| r6t d t | ƒ ƒ ‚ n  d  } qBn  | rX| j | ƒ qç| j ƒ  j d d ƒ } | d k r’| j | ƒ t } qç| } xw | D]o } | j d | ƒ rŸ| j d ƒ rŸ| | c d 7<d | t  ƒ  | f } | | k r
| j | ƒ n  PqŸqŸW| j | ƒ qçW| j! ƒ  j" d ƒ d k rct d t | ƒ t | ƒ f ƒ ‚ n¶ t  | ƒ d k r‡d t | ƒ GHn’ d  j# | ƒ } d! t$ t  | ƒ ƒ Gd" d# j# | ƒ Gd$ t | ƒ GHy t | d% ƒ | IJWn5 t k
 r} t d& t | ƒ t | ƒ f ƒ ‚ n Xd  S('   Ni   sÛ   iotbx.cns.transfer_crystal_symmetry any_symmetry_source_file cns_input_file
  *********************************************
  NOTE: the cns_input_file is changed in place.
  *********************************************s   No such file: %ssG   Unknown file format or unit cell and/or space group missing from file: t   space_group_infos$   Space group not available in CNS: %ss   "%s"s   %.6gt   sgt   at   bt   ct   alphat   betat   gammai    t   monitor_initialid   s   Error reading file %s (%s)t   blocks   %s appears to be a binary file.t    t    s    ){-endblockparameterdefinition-}s	   {===>}%s=t   ;i   s   {===>} %s=%s;i   s4   Unexpected set of variable names in %s:
  counts: %ss&   Info: no changes, %s was not modified.s   
s   Info: %d change%ss   (%s),s   , s   writing modified file %s.t   ws   Error writing file %s (%s)(%   t   lenR   t   ost   patht   existsR   R   R   t   extract_fromt   NoneR   t   space_group_symbolst
   cns_formatR   t   strt	   unit_cellt
   parameterst   dictt   zipR   t   opent   readt
   splitlinest   IOErrort   Falset   is_binary_filet   appendt   stript   replacet   Truet
   startswitht   endswitht   varst   valuest   countt   joinR   (   t   argst	   file_namet   sourcet   targett   crystal_symmetryt   cns_space_group_symbolR	   t   pR
   R   R   R   R   R   t   parameter_namest   parameters_foundt   parameters_changedt	   lines_outt   detect_binaryt   cns_inpt   et   end_block_parameter_definitiont   linet	   is_binaryt   lt   line_outt
   string_out(    (    s^   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/cns.transfer_crystal_symmetry.pyt   run	   s‚    
8" &	"  t   __main__i   (   t
   __future__R    t   iotbxR   t   iotbx.cns.space_group_symbolsR   t   libtbx.str_utilsR   t   libtbx.utilsR   R   R   R   t   sysR   RG   t   __name__t   argv(    (    (    s^   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/cns.transfer_crystal_symmetry.pyt   <module>   s   "	G