ó
œ™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 Z d  d l Z d  d l Z d „  Z d	 „  Z e d
 k r¬ e ƒ  n  d S(   iÿÿÿÿ(   t   division(   t   server(   t	   cif_types(   t   flex(   t   dicts(   t   easy_pickleNc         C   sf  | d  k r d G|  j GHd  Sx˜ |  j ƒ  D]Š } t t |  | ƒ ƒ j ƒ  } t t | j | ƒ ƒ j ƒ  } | d k r) | d k r) | | k r) d |  j | t | ƒ t | ƒ f GHq) q) W|  j } t | j	 ƒ } | | k rù d |  j t | ƒ | f GHn  |  j
 } d } x- | j	 D]" } | j d k r| d 7} qqW| | k rbd |  j t | ƒ | f GHn  d  S(	   Ns   Missing file:t    s   %s: %s: %s, %ss$   %s: number_atoms_all: %s, %d countedi    t   Hi   s#   %s: number_atoms_nh: %s, %d counted(   t   Nonet   idt   cif_keywordst   strt   getattrt   stript	   chem_compt   number_atoms_allt   lent	   atom_listt   number_atoms_nht   type_symbol(   t   chem_comp_from_list_filet   comp_comp_idt   keyt   at   bt   atom(    (    sN   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/monomer_library/tst_server.pyt   check_chem_comp
   s,    $(		 c           C   sp  d t  j d k }  d t  j d k } t j ƒ  } t j d | ƒ } d G| j GHd t  j d k } t so | ri  } t j d ƒ } x| j d d	 D]î } | rº t	 j	 ƒ  d
 k  rº q– n  |  rÌ d G| GHn  | j
 d | ƒ } | d  k rö d | GHq– t }	 t }
 xf | j D][ } | | j c d 7<| j j d ƒ d k rFt }	 n  | j j d ƒ d k rt }
 qqW|
 r– |	 | | j j <q– q– W| GHt j | j ƒ  ƒ } t j | j ƒ  ƒ } t j d | d t ƒ } | j | ƒ } | j | ƒ } x) t | | ƒ D] \ } } | G| GHqýWn  t s%| rÐx | j d d j ƒ  D]f } | rat	 j	 ƒ  d
 k  raq=n  |  rwd G| d	 GHn  | j
 d | d	 ƒ } t t j | �  | ƒ q=Wd t  j d k rÐt j d | ƒ qÐn  t sÜ| r| j
 d ƒ } | j ƒ  | j  d } | j! | ƒ j ƒ  n  t s$| r`| j
 d ƒ } | j ƒ  | j  d } | j! | ƒ j ƒ  n  t sl| rGxØ| j d d j ƒ  D]¼} | r¨t	 j	 ƒ  d
 k  r¨q„n  | j
 | d	 ƒ } | d  k	 r„| j" d k r| j j G| j j# G| d G| d j$ ƒ  j% ƒ  } | d: k rd Gn  Hnd | d j$ ƒ  j d ƒ d k s_| j j& j$ ƒ  j d ƒ d k rƒ| j j G| j j# G| d Gd GHn  | j" d; k rÙ| j j G| j j# G| d G| j" | d j% ƒ  k rÕ| j" Gd Gn  Hq@| d j$ ƒ  j d" ƒ d k s| j j& j$ ƒ  j d" ƒ d k r@| j j G| j j# G| d Gd GHq@q„q„Wn  t sS| rIxó | j d d j ƒ  D]× } | r�t	 j	 ƒ  d
 k  r�qkn  | j
 | d	 ƒ } | d  k	 rk| j' ƒ  } x… | D]z } i  } x$ | j( D] } d | t) | j* ƒ <q×Wt+ | ƒ d k s| j ƒ  d d# k rÁ| j j G| j, G| j ƒ  GHqÁqÁWqkqkWn  t sU| rñd d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d d4 d5 g } xW| j d d j ƒ  D];} | d	 | k } d rØ| rØq¯n  | j
 | d	 ƒ } | r$| d  k	 st- ‚ | j j& j% ƒ  d6 k s$t- ‚ n  | d  k	 r¯| j j j% ƒ  G| j j# j% ƒ  G| j j& j% ƒ  GHxG | j. D]< } d7 G| j/ G| j0 G| j1 G| j2 G| j3 G| j4 G| j5 GHqkWx< | j6 D]. } d8 G| j7 G| j/ G| j0 G| j1 G| j8 GHqµWq¯q¯Wn  t sý| rgt j9 ƒ  } t s| r7x | j: j; ƒ  D] } | GHq%Wn  t sC| rgx | j< D] } | j ƒ  qMWqgn  d9 GHd  S(<   Ns	   --verbosei   s   --quickt   list_cifs   srv.root_path:s   --default_offi    t	   comp_lists   _chem_comp.idgffffffî?s   id:t   comp_ids$   Error instantiating comp_comp_id(%s)t   't   ,t   datat   reverset
   _chem_comps   --pickles   mon_lib.picklet   GLYt   COOt   LYSt   B2Ct   peptides   _chem_comp.groups	   l-peptides	   d-peptidet   polymert   LOOKt   MISMATCHt   RNAt   DNAt   NAs   0.02t   VALt   ALAt   LEUt   ILEt   PROt   METt   PHEt   TRPt   SERt   THRt   TYRt   CYSt   ASNt   GLNt   ASPt   GLUt   ARGt   HISs	   L-peptides     tor:s     chir:t   OK(   s	   l-peptides	   d-peptideR(   (   R+   R,   (=   t   syst   argvR   t   mon_lib_list_cift	   root_patht   FalseR   t   with_default_valuet   cift   randomt   get_comp_comp_id_directR   R   t   atom_idt   findt   TrueR   R	   R   t
   std_stringt   keyst   size_tt   valuest   sort_permutationt   selectt   zipt   iterrowsR   R   R   t   dumpt   showt   mod_mod_id_dictt	   apply_modt   classificationt   namet   lowerR   t   groupt
   get_planest   plane_atomsR   t   dist_esdR   t   plane_idt   AssertionErrort   tor_listt	   atom_id_1t	   atom_id_2t	   atom_id_3t	   atom_id_4t   value_anglet   value_angle_esdt   periodt	   chir_listt   atom_id_centret   volume_signt   ener_libt   lib_synonymt   itemst   lib_vdw(    t   verboset   quickR   t   srvt   default_switcht   monomers_with_commast   atom_id_countst   row_idR   t
   has_primest
   has_commasR   t   atom_idst   countst   permRJ   t   countt   rowt   compt   modt   grpt   planest   planet   dist_esd_dictt
   plane_atomt   standard_amino_acidst   is_standard_aat   tort   chirt   elibt   synt   vdw(    (    sN   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/monomer_library/tst_server.pyt   exercise!   sþ      	  

 !! ($!$t   __main__(   t
   __future__R    t   mmtbx.monomer_libraryR   R   t   cctbx.array_familyR   t   scitbx.python_utilsR   t   libtbxR   RH   RA   t   osR   R�   t   __name__(    (    (    sN   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/monomer_library/tst_server.pyt   <module>   s   		€