ó
,™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 Z d e f d „  ƒ  YZ d	 „  Z e d
 k r‘ e ƒ  n  d S(   iÿÿÿÿ(   t   division(   t   easy_pickle(   t   option_parser(   t   dicts(   t   euclidean_model_matchingNt   match_recordc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   t	   n_matchest
   model_size(   t   selfR   R   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/euclidean_model_matching.pyt   __init__
   s    	c         C   s   d |  j  |  j f S(   Ns   %d/%d(   R   R   (   R   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/euclidean_model_matching.pyt   __repr__   s    (   t   __name__t
   __module__R	   R
   (    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/euclidean_model_matching.pyR      s   	c       
   C   s<  t  d d d d ƒ j d d d d d	 ƒj d
 d d d t ƒj d t j d ƒ }  t |  j ƒ d k r„ |  j j	 ƒ  t j
 d ƒ n  t j |  j d ƒ } t | ƒ t g  ƒ t d ƒ f k rË | d } n  t j |  j d ƒ } t | ƒ t g  ƒ t d ƒ f k r| g } n  |  j j s_| j | j d ƒ ƒ x( | D] } | j | j d ƒ ƒ q;Wn  d GH| j ƒ  H| j ƒ  } g  } t j d ƒ } xî | D]æ } | j ƒ  t | d ƒ rÁ| j GHn  Ht j j ƒ  t j | | j ƒ  d |  j j d t d t ƒj } t | ƒ r2| d j ƒ  t | d j  ƒ } n d GHd } | j! t" | | j# ƒ  j$ ƒ  ƒ ƒ | | c d 7<Ht j j ƒ  q—Wd G| GH| j% ƒ  }	 |	 j& ƒ  |	 j' ƒ  d GHd }
 x" |	 D] } | | } |
 | 7}
 q¼Wd } xG |	 D]? } | | } | | 7} d | | d | |
 d | |
 f GHqçWHt j j ƒ  d  S(   Nt   usages[   usage: cctbx.euclidean_model_matching [OPTIONS] reference_structure.pickle structure.picklet   descriptiont    s   --tolerancet   typet   floatt   defaulti   s   --match_hydrogenst   boolt   argsi   i   i    t   Hs   Reference model:t   infot	   tolerancet'   models_are_diffraction_index_equivalentt   break_if_match_with_no_singless
   No matchess   match_list:s   matches: frequencys     %3d: %3d = %5.1f%%, %5.1f%%g      Y@(    (    ((   R   t   optiont   Truet   processt   syst   argvt   lenR   t   parsert
   print_helpt   exitR   t   loadR   t   optionst   match_hydrogenst   select_inplacet   element_selectiont   show_summaryt   as_emma_modelR   t   with_default_valuet   hasattrR   t   stdoutt   flusht   emmat   model_matchesR   t   Falset   refined_matchest   showt   pairst   appendR   t
   scattererst   sizet   keyst   sortt   reverse(   t   command_linet   reference_structuret
   structurest	   structuret   reference_modelt
   match_listt   match_histogramR1   t   mR7   t   sumt   keyt   vt   s(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/euclidean_model_matching.pyt   run   s‚    		$$

"	




)t   __main__(   t
   __future__R    t   libtbxR   t   libtbx.option_parserR   t   scitbx.python_utilsR   t   cctbxR   R.   R   t   objectR   RF   R   (    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/euclidean_model_matching.pyt   <module>   s   		G