ó
›™xTc           @   sO   d  d l  m Z d  d l Z d  d l m Z m Z d  d l m Z d „  Z	 d S(   iÿÿÿÿ(   t   divisionN(   t   show_stringt   show_sorted_by_counts(   t   dict_with_default_0c      	   C   s’  d } d G|  GHt  j j j |  ƒ } xgt  j j j d |  d | ƒ D]G} | d 7} t ƒ  } xg | j D]\ } | j } | j d ƒ d k s� t	 ‚ | | k rµ t
 d t | ƒ ƒ ‚ n  | j | ƒ qf Wd Gt | ƒ GHt ƒ  } x¶ | j D]« } | j | j g }	 x3 |	 D]+ } | | k rt
 d	 t | ƒ ƒ ‚ qqWt t |	 ƒ ƒ }	 |	 | k r†t
 d
 t g  |	 D] }
 t |
 ƒ ^ qdƒ ƒ ‚ n  | j |	 ƒ qè Wd Gt | ƒ GHt ƒ  } x¼ | j D]± } | j | j | j g }	 x3 |	 D]+ } | | k rÞt
 d t | ƒ ƒ ‚ qÞqÞWt t |	 ƒ ƒ }	 |	 | k r]t
 d t g  |	 D] }
 t |
 ƒ ^ q;ƒ ƒ ‚ n  | j |	 ƒ q¹Wd Gt | ƒ GHt ƒ  } xÂ | j D]· } | j | j | j | j g }	 x3 |	 D]+ } | | k r»t
 d t | ƒ ƒ ‚ q»q»Wt t |	 ƒ ƒ }	 |	 | k r:t
 d t g  |	 D] }
 t |
 ƒ ^ qƒ ƒ ‚ n  | j |	 ƒ q�Wd Gt | ƒ GHi  } xH | j D]= } t t | j | j g ƒ ƒ }	 | j |	 g  ƒ j | ƒ qjWxW | j ƒ  D]I \ }	 } t | ƒ d k r¸d Gd j g  | D] } | j ^ qçƒ GHq¸q¸Wt ƒ  } xÂ | j D]· } | j | j | j | j g }	 x3 |	 D]+ } | | k rCt
 d t | ƒ ƒ ‚ qCqCWt t |	 ƒ ƒ }	 |	 | k rÂt
 d t g  |	 D] }
 t |
 ƒ ^ q ƒ ƒ ‚ n  | j |	 ƒ qWd Gt | ƒ GHt ƒ  } xO | j D]D } | j | k r&t
 d t | j ƒ ƒ ‚ n  | | j  c d 7<qõWd Gt | ƒ GHt | ƒ d k r˜t! d | j ƒ  d d ƒ t" | j# ƒ  ƒ d k s˜t	 ‚ n  | j$ ƒ  } | d  k	 rC d G| j& GHxD | j& D]9 } | j' ƒ  | k sät	 ‚ | j( ƒ  | g k sÆt	 ‚ qÆWxŠ | j) D] } t | ƒ d k s+t	 ‚ | d | j& k sDt	 ‚ xE | d D]9 } | j' ƒ  | k smt	 ‚ | j( ƒ  | g k sOt	 ‚ qOWqW| j* }	 |	 d  k	 rìxD |	 D]9 } | j' ƒ  | k sÊt	 ‚ | j( ƒ  | g k s¬t	 ‚ q¬Wn  | j+ d  k s| j+ d k st	 ‚ d Gt | j, ƒ GHd } xD| j, D]9} | j d  k	 sMt	 ‚ t | j j' ƒ  ƒ t | j ƒ k swt	 ‚ t | j j( ƒ  ƒ d k s˜t	 ‚ | j- d  k rÆ| j. d  k rð| d 7} qðn* | j- d k sÛt	 ‚ | j- d k  sðt	 ‚ | j/ d  k	 st	 ‚ t | j/ ƒ t | j& ƒ k s)t	 ‚ x? | j/ D]4 } | d  k s3d! | k  o\d" k n s3t	 ‚ q3Wq2W| d k rŠd# G| GHqŠqC qC W| S($   Ni    s
   file name:t   source_infot
   cif_objecti   t    s   Duplicate atom name: %ss     number of atoms:s   Unknown bond atom name: %ss   Duplicate bond: %s - %ss     number of bonds:s   Unknown angle atom name: %ss   Duplicate angle: %s - %s - %ss     number of angles:s   Unknown tor atom name: %ss    Duplicate tor: %s - %s - %s - %ss     number of tors:s       redundant tors:s   , s   Unknown chir atom name: %ss!   Duplicate chir: %s - %s - %s - %ss     number of chirs:s   Unknown plane atom name: %ss     number of planes:t   label_count_pairst   prefixs       i   s     rotamer_info.tor_ids:i   s     number of rotamers:s   for more uniform samplingiLÿÿÿi´   s)     WARNING: number of missing frequencies:(0   t   mmtbxt   monomer_libraryt   servert   read_cift   convert_comp_listt   sett	   atom_listt   atom_idt   countt   AssertionErrort   RuntimeErrorR   t   addt   lent	   bond_listt	   atom_id_1t	   atom_id_2t   tuplet   sortedt
   angle_listt	   atom_id_3t   tor_listt	   atom_id_4t
   setdefaultt   appendt   itemst   joint   idt	   chir_listt   atom_id_centreR   t   plane_atom_listt   plane_idR   t   mint   valuest   rotamer_infot   Nonet   tor_idst   stript   splitt   tor_atom_idst   atom_ids_not_handledt4   constrain_dihedrals_with_sigma_less_than_or_equal_tot   rotamert	   frequencyt   frequency_annotationt   angles(   t	   file_namet   resultR   t   comp_comp_idt
   atom_namest   atomt	   atom_namet   bond_atom_idst   bondt   atom_idst   st   angle_atom_idst   angleR/   t   tort   torst   chir_atom_idst   chirt   plane_atom_countst
   plane_atomR*   t   tor_idR   t   n_missing_frequenciesR2   (    (    sN   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/monomer_library/cif_triage.pyt
   check_comp   s   	
				&		&		&/		&	!#	"	*!$6(
   t
   __future__R    t   mmtbx.monomer_library.serverR	   t   libtbx.str_utilsR   R   t   libtbxR   RJ   (    (    (    sN   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/monomer_library/cif_triage.pyt   <module>   s   