ó
Ñ™xTc           @   sq   d  d l  m Z d  d l m Z d  d l Z d  d l Z e j Z d „  Z e	 d k rm e d e j
 d ƒ n  d S(   iÿÿÿÿ(   t   division(   t   easy_pickleNc      	   C   s¥  t  |  ƒ d k s t d ƒ ‚ |  d } t j d t j | d ƒ ƒ } t j | d ƒ } t j | ƒ r| t j d | ƒ } n  i  } xs t j | ƒ D]b } | j	 d ƒ s­ q’ n  y t
 | d ƒ } Wn t k
 r× q’ n X| | k sê t ‚ | | | <q’ Wd | k s
t ‚ t j d t j | | d ƒ ƒ } t | j ƒ  ƒ } t j d t j | | | ƒ ƒ }	 d	 |	 j | ƒ GHd
 d  l }
 |
 j j j d | d |	 ƒ } d G| j GH|
 j j d | j ƒ } d G| j Gd | j d t ƒ GHd G| j j ƒ  GH| j ƒ  } d | j | ƒ GHd
 d l m } | ƒ  } | | j ƒ  } d
 d l m } | j  | d t ƒ} x} t! | j" | ƒ j# | ƒ | j$ | j# | ƒ ƒ | j$ |	 | j ƒ  j# | ƒ ƒ ƒ D]) \ } } } | | Id | | f IJq±W| d  k	 r¡d
 d l& m' } | j( ƒ  } x˜ | j) ƒ  D]‡ } d G| | GHy3 | j* d | d | j+ | ƒ j, ƒ  d |	 | ƒ Wqt k
 r™} d
 d l- m. } | d d d  t/ | ƒ ƒ GHHqXqWn  d  S(!   Ni   t   trajectory_directoryi    t	   file_namet   labelst   xray_structuret   sites_i   s$   rms difference start vs. final: %.3fiÿÿÿÿt   reference_sitest   other_sitess   ls r:t   rs   ls r axis, angle:s   %.2ft   degs   ls t:s'   rms difference start vs. best fit: %.3f(   t   StringIO(   t   flext   reverses	   %.2f %.2f(   t   crystals   special position:t   crystal_symmetryt
   special_opt	   site_cart(   t   prefix_each_linet   prefixs     t   lines_as_one_string(0   t   lent   AssertionErrorR   t   loadt   opt   joint   isfilet   ost   listdirt
   startswitht   intt
   ValueErrort   maxt   keyst   rms_differencet   scitbx.math.superposet   matht	   superposet   least_squares_fitR	   t&   r3_rotation_axis_and_angle_from_matrixt   axist   anglet   Truet   tt	   transposet   other_sites_best_fitt	   cStringIOR   t   dott   scitbx.array_familyR   t   sort_permutationt   zipt
   std_stringt   selectt   sqrtt   Nonet   cctbxR   t   site_symmetry_tablet   special_position_indicest   correct_special_positiont   getR   t   libtbx.str_utilsR   t   str(   t   argst   traj_dirR   t   fnR   t   sites_file_names_by_indext   it   sites_0t   max_it   sites_finalt   scitbxt   lst   fmt	   sites_fitR   t   outt   fit_dists_sqR   t   permt   lblt   fit_dt   final_dR   R8   t   i_seqt   eR   (    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/refinement/inspect_tardy_trajectory.pyt   run   st    
   		 	2	t   __main__R>   i   (   t
   __future__R    t   libtbxR   t   sysR   t   pathR   RR   t   __name__t   argv(    (    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/refinement/inspect_tardy_trajectory.pyt   <module>   s   		>