ó
©™xTc           @   s  d  d l  m Z d  d l 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 i' d  d¡ g d	 6d¢ d£ g d
 6d¤ d¥ g d 6d¦ d¨ g d 6d© d dª d f g d 6d« d d d¬ f g d 6d­ d® g d 6d¯ d d d° f g d 6d± d d d² f g d 6d³ d´ g d 6dµ d d d¶ f g d 6d· d d d¸ f g d 6d¹ d d dº f g d 6d» d¼ g d 6d½ d¿ g d 6dÀ dÂ g d 6dÃ dÅ g d 6dÆ dÇ g d 6dÈ d dÉ d f g d 6dÊ d dË d f g d  6dÌ d dÍ d f g d! 6dÎ dÏ g d" 6dÐ d d dÑ f g d$ 6dÒ d d dÓ f g d% 6dÔ d d dÕ f g d& 6dÖ d d d× f g d' 6dØ d d dÙ f g d) 6dÚ d dÛ d f g d* 6dÜ d d dÝ f g d+ 6dÞ d dß dà f g d, 6dá d dâ dã f g d- 6dä dæ g d. 6dç d d dè f g d/ 6dé dê d dë f g d0 6dì dí d dî f g d1 6dï dñ g d2 6dò d dó d f g d3 6dô dõ dö d f g d4 6d÷ dø dù d f g d5 6Z i
 d	 d g d6 6d* d+ d, d- g d7 6d d d  d! g d8 6d
 d g d9 6d. d/ d0 d1 g d: 6d2 d3 d4 d5 g d; 6d d g d< 6d d d g d= 6d d d d g d> 6d" d$ d% d& d' d) g d? 6Z e d7 Z e d6 Z e d8 Z e d: Z e d9 Z e d; Z e d< Z e d= Z e d> Z e d? Z i& g  d@ 6e e dA 6e e dB 6e e dC 6e e dD 6e e dE 6e e dF 6e e dG 6e e dH 6e e dI 6e e dJ 6e e dK 6e e dL 6e e e e dM 6e e e e dN 6e e e e dO 6e e e e dP 6e e e e dQ 6e e e e dR 6e e dS 6e e dT 6e e e dU 6e e e dV 6e e e dW 6e e e dX 6e e e dY 6e e e e dZ 6e e e e d[ 6e e e e d\ 6e e e e d] 6e e e d^ 6e e e d_ 6e e e e d` 6e e e e da 6e e e e db 6e e e dc 6e e e dd 6e e e de 6Z i& g  d@ 6e dA 6e dB 6e dC 6e dD 6e dE 6e dF 6e dG 6e dH 6e dI 6e dJ 6e dK 6e dL 6e e e dM 6e dN 6e dO 6e dP 6e e e dQ 6e e e dR 6e dS 6e dT 6e e dU 6e e dV 6e dW 6e dX 6e dY 6e dZ 6e d[ 6e d\ 6e d] 6e d^ 6e d_ 6e e e d` 6e e e da 6e e e db 6e e dc 6e e dd 6e e de 6Z i df dg 6dh di 6dj dk 6dl dm 6Z i# d* dn 6d+ do 6d, dp 6d	 dq 6d dr 6d4 ds 6d" dt 6d' du 6d- dv 6d) dw 6d& dx 6d. dy 6d dz 6d d{ 6d d| 6d d} 6d5 d~ 6d d 6d d€ 6d d� 6d d‚ 6d dƒ 6d3 d„ 6d% d… 6d0 d† 6d d‡ 6d/ dˆ 6d$ d‰ 6d2 dŠ 6d
 d‹ 6d dŒ 6d1 d� 6d dŽ 6d d� 6d d� 6Z i# dˆ d/ 6d† d0 6dy d. 6dŠ d2 6ds d4 6d„ d3 6dn d* 6dp d, 6do d+ 6dŒ d 6d{ d 6dr d 6d‹ d
 6dz d 6dq d	 6d� d1 6d~ d5 6dv d- 6d| d 6d} d 6dŽ d 6dƒ d 6d€ d 6d d 6d� d 6d‡ d 6d� d 6d‚ d 6d� d 6dt d" 6d‰ d$ 6dw d) 6du d' 6d… d% 6dx d& 6Z i d) d$ 6d' d% 6d$ d) 6d% d' 6d d 6d d 6d d 6d d 6Z d‘ e  f d’ „  ƒ  YZ! d“ e  f d” „  ƒ  YZ" d d• „ Z# d– e j$ j% f d— „  ƒ  YZ& d˜ e  f d™ „  ƒ  YZ' dš e j$ j% f d› „  ƒ  YZ( dœ e j$ j% e j) f d� „  ƒ  YZ* dž „  Z+ e, dŸ k re+ ƒ  n  d S(ú   iÿÿÿÿ(   t   divisionN(   t   flex(   t   crystal(   t   miller(   t   sgtbx(   t   table_utilsi    s   2_0 (a)s   2_0 (b)s   2_0 (c)g      ð?g       @s   2_1 (a)s   2_1 (b)s   2_1 (c)s   3_0 (c)g      @s   3_1 (c)s   3_2 (c)s   4_0 (c)g      @s   4_1 (c)s   4_2 (c)s   4_3 (c)s   4_0 (a)s   4_1 (a)s   4_2 (a)s   4_3 (a)s   4_0 (b)s   4_1 (b)s   4_2 (b)s   4_3 (b)s   6_0 (c)g      @s   6_1 (c)s   6_2 (c)s   6_3 (c)s   6_4 (c)g      @s   6_5 (c)s   b (a)s   c (a)s   n (a)s   d (a)s   a (b)s   c (b)s   n (b)s   d (b)s   a (c)s   b (c)s   n (c)s   d (c)s	   along a 2s   along as	   along b 4s	   along b 2s   along bs   along cs	   along c 2s	   along c 3s	   along c 4s	   along c 6s   P -1s	   P 1 2/m 1s	   C 1 2/m 1s	   A 1 2/m 1s	   I 1 2/m 1s	   P 1 1 2/ms	   A 1 1 2/ms	   B 1 1 2/ms	   I 1 1 2/ms	   P 2/m 1 1s	   B 2/m 1 1s	   C 2/m 1 1s	   I 2/m 1 1s   P m m ms   C m m ms   A m m ms   B m m ms   F m m ms   I m m ms   P 4/ms   I 4/ms	   P 4/m m ms	   I 4/m m ms   P -3s   R -3 :Hs   R -3 :Rs   P -3 1 ms   P -3 m 1s	   R -3 m :Hs	   R -3 m :Rs   P 6/ms	   P 6/m m ms   P m -3s   F m -3s   I m -3s   P m -3 ms   F m -3 ms   I m -3 mt   As   1 (0, 0, 0) 0,1/2,1/2t   Bs   1 (0, 0, 0) 1/2,0,1/2t   Cs   1 (0, 0, 0) 1/2,1/2,0t   Is   1 (0, 0, 0) 1/2,1/2,1/2s   -2 (1, 0, 0) 0,1/2,0s   -2 (1, 0, 0) 0,0,1/2s   -2 (1, 0, 0) 0,1/2,1/2s   2 (1, 0, 0) 0,0,0s   2 (1, 0, 0) 1/2,0,0s   -2 (0, 0, 1) 1/2,1/2,0s   6 (0, 0, 1) 0,0,0s   6 (0, 0, 1) 0,0,2/3s   -2 (1, 0, 0) 0,1/4,1/4s   6 (0, 0, 1) 0,0,5/6s   6 (0, 0, 1) 0,0,1/2s   -2 (0, 1, 0) 1/2,0,0s   2 (0, 0, 1) 0,0,0s   2 (0, 0, 1) 0,0,1/2s   4 (0, 0, 1) 0,0,0s   4 (0, 0, 1) 0,0,1/4s   -2 (0, 0, 1) 1/4,1/4,0s   4 (1, 0, 0) 1/4,0,0s   4 (1, 0, 0) 0,0,0s   3 (0, 0, 1) 0,0,0s   3 (0, 0, 1) 0,0,1/3s   4 (0, 0, 1) 0,0,3/4s   -2 (0, 0, 1) 0,1/2,0s   6 (0, 0, 1) 0,0,1/3s   -2 (0, 1, 0) 1/2,0,1/2s   4 (1, 0, 0) 3/4,0,0s   -2 (0, 1, 0) 0,0,1/2s   6 (0, 0, 1) 0,0,1/6s   -2 (0, 0, 1) 1/2,0,0s   2 (0, 1, 0) 0,0,0s   2 (0, 1, 0) 0,1/2,0s   -2 (0, 1, 0) 1/4,0,1/4s   4 (0, 0, 1) 0,0,1/2s   4 (1, 0, 0) 2/4,0,0s   3 (0, 0, 1) 0,0,2/3t   conditions_for_operatorc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sU   t  j | j ƒ  ƒ } t  j | ƒ } | j ƒ  |  _ | j ƒ  |  _ | j ƒ  |  _ d  S(   N(   R   t   rot_mx_infot   rt   translation_part_infot   typet   evt   intrinsic_partt   trans(   t   selft   st   r_infot   t_info(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt   __init__!  s
    c         C   s#  g  } |  j  d k  r t |  j j ƒ  ƒ j d ƒ d k  rv x@ t D]/ } | d k rb | j d  ƒ q@ | j d ƒ q@ Wq d } n  t  d k rï t |  j j ƒ  ƒ j d ƒ d k  rï x: t D]/ } | d k rØ | j d  ƒ q¶ | j d ƒ q¶ Wqï n  t | ƒ d k rd  d  d  g } n  | t t	 ƒ g S(   Ni    i   (   NNN(
   R   t   listR   t	   as_doublet   countR   t   appendt   Nonet   lent   t(   R   t   condt   ii(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt	   condition)  s"    $	$c         C   sf   |  j  j ƒ  } t |  j ƒ d t |  j ƒ d t |  j  ƒ } d } t j | ƒ rb t | } n  | S(   Nt    s
   Non absent(   R   R   t   strR   R   t   symbol_from_stringt   has_key(   R   R   t	   id_stringt   op_name(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt   absence_typeB  s    1(   t   __name__t
   __module__R   R    R'   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR
      s   		t   absencesc           B   s5   e  Z d  d d „ Z e d „ Z d „  Z d „  Z RS(   g       @gffffffî?c         C   s(   t  |  _ t |  _ | |  _ | |  _ d  S(   N(   t   absence_and_conditionst   libt$   absences_via_intensity_symmetry_prott   absence_classest   multt	   threshold(   R   R/   R0   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR   L  s    			c   	      C   s¶   d t  | ƒ } |  j j | ƒ r˜ |  j | \ } } |  j | | ƒ } |  j | | ƒ } | r‡ | rv | d | 7} q• | d | 7} qž | d | 7} n d } | r® | | f S| Sd  S(   Ns    The reflection with index %s is s    PRESENT under the %s operators    ABSENT under the %s operartors(    not of the type that is absent under %ss   No such type of absence(   R"   R,   R$   t
   check_maskt   check_condition(	   R   t   abs_typet   hklt   return_boolt   messaget   maskR    t   mct   cc(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt   checkR  s    
c   	      C   s’   d } x' | D] } | d  k r | d 7} q q Wd } t } x6 t | | ƒ D]% \ } } | | k rL | d 7} qL qL W| d | k rŽ t } n  | S(   Ni    i   i   (   R   t   Falset   zipt   True(	   R   R4   R7   t   mask_none_countR   R   t   resultt   mt   h(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR1   g  s    	c         C   sŒ   t  } | d | d | d | d | d | d } t j | d t j ƒ } d t j |  j | ƒ d } | |  j k rˆ t } n  | S(   t   magici    i   i   g       @g      à?(   R;   t   matht   cost   pit   tanhR/   R0   R=   (   R   R4   R    R?   t   xt   yt   z(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR2   u  s    2	(   R(   R)   R   R;   R:   R1   R2   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR*   K  s   	c         C   s3   d d l  m } | } | j |  | | | ƒ } | S(   Niÿÿÿÿ(   t   absence_likelihood(   t   mmtbx.scalingRJ   t   log_p(   RI   t   sigzt   absent_or_centric_or_acentrict   sigma_inflationRJ   t   flagR?   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt
   likelihood  s    t   analyze_absencesc           B   sG   e  Z d  d d „ Z d „  Z e d d „ Z d d „ Z d d	 „ Z RS(
   i   g      ð?c         C   s%  | |  _  | |  _ | j ƒ  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _	 g  |  _
 g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ |  j j ƒ  d  k	 sÃ t ‚ t j d |  j j ƒ  ƒ |  _ |  j j ƒ  |  _ |  j j |  j ƒ |  _ t ƒ  |  _ |  j ƒ  d  S(   Nt   group(    t   cutRO   t	   deep_copyt   miller_arrayt   n_abst   n_n_abst   n_tott
   n_abs_violt   n_n_abs_violt
   n_tot_violt   isi_abst	   isi_n_abst   isi_tott   i_abst   i_n_abst   i_totR&   t   scoret   presentt   sigmasR   t   AssertionErrorR   t   space_group_infot   space_groupt   sgt'   change_of_basis_op_to_reference_settingt   cb_opt   change_basisR*   t	   abs_checkt   check_conditions(   R   RV   t	   isigi_cutRO   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR   ‡  s0    																	c         C   sp   | j  d ƒ | j d ƒ | j d ƒ | j d ƒ | j d i |  j d 6ƒ | j d ƒ | j |  j ƒ d  S(   Ns!   Table of systematic absence ruless´    The following table gives information about systematic absences allowed for
 the specified intensity point group.

 For each operator, the reflections are split in three classes:
sÂ   
  Absent    : Reflections that are absent for this operator.
  Non Absent: Reflection of the same type (i.e. (0,0,l)) as above, but they should be present.
  Complement: All other reflections.
s·   For each class, the <I/sigI> is reported, as well as the number of
'violations'. A 'violation' is designated as a reflection for which a I/sigI
criterion is not met. The criteria are:sˆ   
  Absent violation     : I/sigI > %(cut)2.1f
  Non Absent violation : I/sigI < %(cut)2.1f
  Complement violation : I/sigI < %(cut)2.1f
RT   sS  Operators with low associated violations for *both* absent and non absent
reflections, are likely to be true screw axis or glide planes. Both the
number of violations and their percentages are given.  The number of
violations within the 'complement' class, can be used as a comparison for
the number of violations in the non-absent class.
(   t   show_sub_headert   showt
   show_linest   show_preformatted_textRT   t	   show_textt
   show_tablet   table(   R   t   out(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt
   _show_impl§  s    g      >@c         C   s^   d d t  j | | |  j ƒ } | s? t t  j | d ƒ ƒ St t  j d | d ƒ ƒ Sd  S(   Ng      à?i   g:Œ0âŽyE>(   RC   RF   RT   t   abst   log(   R   t   isigt   absentt   at   tmp(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt   score_isigiÆ  s    "i   c         C   sk  g  } g  } g  } g  } g  } d } d }	 d }
 xó t  |  j |  j |  j |  j |  j |  j ƒ D]Ä \ } } } } } } | | k r£ |
 | 7}
 | | 7} |	 | 7}	 n  | d k r| | k rç | | k r× | j | ƒ q| j | ƒ q"| | k r"| j | ƒ q"q^ | | k r^ | j | ƒ q^ q^ Wt | ƒ t | ƒ } t | ƒ t | ƒ } t | ƒ } |
 | |	 f S(   Ni    (	   R<   R&   Rc   RW   RX   RZ   R[   R   R   (   R   t   opst   threst   in_sg_and_seemingly_correctt!   not_in_sg_and_seemingly_incorrectt   in_sg_and_seemingly_incorrectt   observed_but_not_in_sgt   in_sg_but_no_observationst   absent_class_violationst   not_absent_class_violationst   total_scoret   opt   sct   nt   n_nt   n_vt   n_n_vt   post   negt   abstain(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt   proposeÍ  s8    4

	g�íµ ÷Æ°>c         C   s¬  d } xŸd g D]”} g  } xj|  j  j t t j d |  j j ƒ  j t ƒ ƒ j	 ƒ  ƒ D].} d } d } d } d }	 d }
 d } d } d } d } d } d } d } d } x t
 |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  ƒ D]e\ } } } } |  j  j | | d	 t ƒ\ } } t | ƒ | k  r<t | | ƒ } n  | r| r­| d
 7} | | | 7} | | 7} | | |  j k  rŠ|
 d
 7}
 n  | t | | | d
 |  j ƒ 7} qJ| d
 7} | | | 7} | | 7} | | |  j k rï|	 d
 7}	 n  | t | | d  ƒ 7} qå | d
 7} | | | 7} | | 7} | | |  j k  rå | d
 7} qå qå W| d k rq| | } | | } n  | d k r”| | } | | } n  | d k r·| | } | | } n  |  j j | ƒ |  j j | ƒ |  j j | ƒ |  j j |	 ƒ |  j j |
 ƒ |  j j | ƒ |  j j | ƒ |  j  j | ƒ |  j! j | ƒ |  j" j | ƒ |  j# j | ƒ |  j$ j | ƒ |  j% j | ƒ t& | ƒ t d
 | | ƒ } |  j' j | ƒ | j | t d | ƒ t d | |	 d t& |	 ƒ t d
 | ƒ f ƒ t d | ƒ t d | |
 d t& |
 ƒ t d
 | ƒ f ƒ t d | ƒ t d | | d t& | ƒ t d
 | ƒ f ƒ t d t | ƒ ƒ g ƒ qW Wt( j) d | d | ƒ |  _* q Wd  S(   Nt   Operators   # absents   <I/sigI> (violations)s   # not absents
   # completet   Scorei    RS   R5   i   s   %8.0fs   %8.2f  (%i, %4.1f%%)g      Y@s   %8.2et   column_headerst
   table_rows(   R”   s   # absents   <I/sigI> (violations)s   # not absents   <I/sigI> (violations)s
   # completes   <I/sigI> (violations)R•   (+   Rm   R.   R"   R   Rg   Ri   RS   t(   build_derived_reflection_intensity_groupR;   t   as_reference_settingR<   RV   t   indicest   centric_flagst   dataRe   R:   R=   Ry   t   maxRT   RQ   RO   R   RW   R   RX   RY   RZ   R[   R\   R]   R^   R_   R`   Ra   Rb   R&   t   floatRc   R   t   simple_tableRv   (   R   t   abs_lower_i_thresholdt   table_labelst   itemR—   R    RW   RX   RY   RZ   R[   R\   R]   R^   R_   R`   Ra   Rb   Rc   R4   t   centric_flagt   it   sigiR8   R9   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyRn   ô  s®           )L!

#






	!!!	(   R(   R)   R   Rx   R;   R   R“   Rn   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyRR   †  s
    	't   sgi_iteratorc           B   s,   e  Z e d d d  „ Z d „  Z d „  Z RS(   c         C   sF   | |  _  | |  _ | |  _ |  j |  j g j d  ƒ d k sB t ‚ d  S(   Ni    (   t   chiralt   crystal_systemt   intensity_symmetryR   R   Rf   (   R   R§   R¨   R©   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR   ^  s    			c         C   sf   |  j  d  k	 r7 |  j  d  k p6 |  j  | j ƒ  j  ƒ  k S|  j d  k pa |  j | j ƒ  j t ƒ k Sd  S(   N(   R¨   R   RS   R©   R˜   R;   (   R   t   sgi(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt
   comparatord  s
    c         c   s}   xv t  j ƒ  D]h } t  j d t  j d | ƒ ƒ } |  j | ƒ r |  j d  k sj |  j | j ƒ  j ƒ  k ru | Vqu q q Wd  S(   NRS   t   space_group_symbols(	   R   t   space_group_symbol_iteratorRg   Rh   R«   R§   R   RS   t	   is_chiral(   R   t   symbolsRª   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR   l  s    *N(   R(   R)   R=   R   R   R«   R   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR¦   ]  s   	t   protein_space_group_choicesc           B   s5   e  Z d  e e d d d „ Z d „  Z d d „ Z RS(   i   g      ð?c      	   C   s  d |  _  | j ƒ  s t ‚ | j ƒ  j ƒ  j ƒ  j ƒ  j ƒ  |  _ |  j j	 ƒ  } t
 d |  j d | d | ƒ |  _ | d  k	 r™ t d | d t ƒ |  _ n t d |  j d t ƒ |  _ t d t d | j t ƒ ƒ |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  } x¼|  j j ƒ  D]«}	 t j d	 |  j j ƒ  d
 |	 j ƒ  ƒ }
 |  j j d |
 ƒ } | j  | j! ƒ  j" ƒ  ƒ } | j" ƒ  j# ƒ  d k r;t$ j% | j" ƒ  ƒ } | j& ƒ  d k } | j  | ƒ } t$ j% | j" ƒ  | j& ƒ  ƒ } | j" ƒ  j# ƒ  } t$ j' | j" ƒ  | j& ƒ  |  j  k ƒ j( t ƒ } n d } d } d } d } g  } x÷ |	 j ƒ  D]é } t) | ƒ } | j* ƒ  d k rf| j* ƒ  |  j j+ k rO|  j j+ j, | j* ƒ  ƒ } | j* ƒ  | k rLt- j. | j* ƒ  ƒ r#t- | j* ƒ  | k rF| j/ | j* ƒ  ƒ |  j j0 | } qFqI| j/ | j* ƒ  ƒ |  j j0 | } qLqOqfqfW|  j j/ | ƒ |  j j1 | ƒ } |  j j/ | ƒ |  j j/ |	 ƒ |  j j/ | ƒ |  j j/ | ƒ |  j j/ | ƒ |  j j/ | ƒ q*W|  j2 ƒ  } t3 j4 d d d d d d d d g d | ƒ |  _5 d  S(   Ng      @RV   Ro   RO   t   obst   was_filteredR§   R©   t	   unit_cellRh   t   crystal_symmetryi    R   R–   s   space groups   n absents
   <Z>_absents   <Z/sigZ>_absents   +++s   ---Rc   R—   (6   R0   t   is_xray_intensity_arrayRf   RU   t	   f_sq_as_ft   average_bijvoet_matest	   f_as_f_sqt
   map_to_asuRV   Rh   RR   t   absences_tableR   t   absences_listR;   R=   R¦   R˜   t   sg_iteratort
   sg_choicest   mean_it
   mean_isigiRŒ   t
   violationst	   abs_typest   tuple_scoreR   R   t   symmetryR³   RS   t   customized_copyt   selectt   sys_absent_flagsRœ   t   sizeR   t   meanRe   t   boolR   R
   R'   R&   t   indext   equivsR$   R   Rc   R“   t   suggest_likely_candidatesR   RŸ   t   sorted_table(   R   RV   R0   t   proteint	   print_allRO   t   original_dataRh   Rc   Ri   t   xst
   tmp_millert   these_absent_millerst
   tmp_mean_it   zero_selt   tmp_mean_isigit   tmp_nt   tmp_violationst   to_be_checkedR   R~   R   t	   tmp_scoreRÂ   t   tmp_rows(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR   v  sŠ    	'									%		c         C   s‹   | j  d ƒ |  j j | ƒ | j d ƒ | j d ƒ | j |  j ƒ t |  d d  ƒ d  k	 r‡ |  j	 j
 d k r‡ |  j	 j | ƒ q‡ n  d  S(   Ns   Systematic absencess   Space group identificationsE  Analyses of the absences table indicates a number of likely space group
candidates, which are listed below. For each space group, the number of
absent violations are listed under the '+++' column. The number of present
violations (weak reflections) are listed under '---'. The last column is a
likelihood based score for the particular space group.  Note that
enantiomorphic spacegroups will have equal scores. Also, if absences were
removed while processing the data, they will be regarded as missing
information, rather then as enforcing that absence in the space group choices.
R»   i    (   t   show_headerRº   Rq   Rp   Rt   Ru   RÍ   t   getattrR   R»   t   n_possible_max(   R   Rw   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyRx   Ó  s    	gÇY)	kŸRc         C   s]  t  j t |  j ƒ t ƒ } g  } t } d } t |  j ƒ d k rF g  Sg  } x" |  j D] } | j | d ƒ qV Wt  j t  j | ƒ t ƒ } g  } t  j	 t  j | ƒ ƒ }	 x¬ | D]¤ }
 |  j |
 } |  j
 |
 } |  j |
 } |  j |
 } |  j |
 } |  j |
 } | j t | ƒ d | d | d | d | d d | d d | d |	 g ƒ q± W| S(	   Niÿÿÿÿi    s   %is   %8.2f  s    %i i   i   s    %8.3e (   R   RÉ   R   R½   R;   RÂ   R   t   sort_permutationt   doublet   minRŒ   RÀ   R¾   R¿   R"   (   R   t   acceptable_violationst   usedt   ordert   all_doneR   t
   tmp_scorest   ttt   sorted_rowst	   max_scoreR   Ri   R×   RØ   RÔ   RÖ   RÂ   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyRÌ   æ  s4    N(   R(   R)   R=   R   R   Rx   RÌ   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR°   u  s   W	R»   c           B   s    e  Z d  Z d „  Z d „  Z RS(   sµ   
  Container for lists of systematic absences.  This subclass simply overrides
  the default output of the base class in cctbx.miller to be consistent with
  the rest of Xtriage.
  c         O   s   t  j j j |  | | Ž d  S(   N(   t   mmtbxt   scalingt   xtriage_analysisRq   (   R   t   argst   kwds(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyRq     s    c         C   s‚  | j  d ƒ | j d ƒ |  j r3 | j d ƒ n  xH|  j D]=\ } } d } t | ƒ t |  j ƒ k rs d } n  | t k r™ | j d | | f ƒ q= | d k r¿ | j d | | f ƒ q= | j d | | f ƒ g  } x… t	 | j
 ƒ  ƒ D]q \ } } | j ƒ  | } | j ƒ  | }	 d	 | }
 |	 d
 k rE| j d |
 ƒ qï | j d |
 | |	 f ƒ qï W| j d j | ƒ ƒ q= Wd S(   s‚   
    For each possible space group, show a list of possible systematically
    absent reflections and corresponding I/sigmaI.
    s&   List of individual systematic absencessÀ    Note: this analysis uses the original input data rather than the filtered data
 used for twinning detection; therefore, the results shown here may include
 more reflections than shown above.
sÕ    Also note that the input data were amplitudes, which means that weaker
 reflections may have been modified by French-Wilson treatment or discarded
 altogether, and the original intensities will not be recovered.
t    s    (input space group)s%   %s%s: no systematic absences possibles   %s%s: no absences founds   %s%ss   (%4d, %4d, %4d)i    s     %s: i/sigi = undefineds     %s: i/sigi = %6.1fs   
N(   Rp   Rt   t   input_amplitudest"   space_group_symbols_and_selectionsR"   Rg   R;   t   show_paragraph_headerR   t	   enumerateRš   Rœ   Re   R   Rs   t   join(   R   Rw   t
   group_infoR*   t
   group_notet   linest   i_hklR4   t	   intensityt   sigmat   indices_fmt(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyRx     s6    	
			
(   R(   R)   t   __doc__Rq   Rx   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyR»     s   	c          C   s"  t  ƒ  }  |  j d d t ƒ t t f k s0 t ‚ |  j d d t ƒ t t f k sW t ‚ |  j d d t ƒ t t f k s~ t ‚ |  j d d t ƒ t t f k s¥ t ‚ t d t d	 d  d
 t j d ƒ j	 ƒ  j
 t ƒ ƒ }  g  } g  } xl |  j ƒ  D]^ } | j t | ƒ ƒ t | ƒ d k rñ x0 | j	 ƒ  D] } | j t | ƒ j ƒ  ƒ q)Wqñ qñ Wd | k set ‚ d | k swt ‚ d | k s‰t ‚ d | k s›t ‚ d | k s­t ‚ d | k s¿t ‚ d | k sÑt ‚ d | k sãt ‚ d | k sõt ‚ d | k st ‚ d | k st ‚ d GHd  S(   Ns   2_1 (c)i    i   i   s   4_1 (a)s   3_1 (c)i   R§   R¨   R©   t   P222s
   P 21 21 21s   2_1 (a)s   2_1 (b)s   P 2 2 2s   P 21 2 2s   P 2 21 2s   P 2 2 21s	   P 21 21 2s	   P 21 2 21s	   P 2 21 21t   OK(   i    i    i   (   i    i    i   (   i   i    i    (   i    i    i   (   R*   R:   R=   R;   Rf   R¦   R   R   Rg   RS   R˜   R   R   R"   R
   R'   (   R~   t   sg_listt   abs_listRi   R   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt   test;  s6    	''''!$t   __main__(   Ni    i    (   i    i    i    (   i    Ni    (   i    i    i    (   i    i    N(   i    i    i    (   Ni    i    g      à?(   g      à?i    i    (   i    Ni    g      à?(   i    i    Ng      à?(   i    i    N(   i    i    i    (   i    i    NgUUUUUUÕ?(   i    i    NgUUUUUUÕ?(   i    i    N(   i    i    i    (   i    i    Ng      Ð?(   i    i    Ng      à?(   i    i    Ng      è?(   Ni    i    (   i    i    i    (   Ni    i    g      Ð?(   g      Ð?i    i    (   Ni    i    g      à?(   g      à?i    i    (   Ni    i    g      è?(   g      è?i    i    (   i    Ni    (   i    i    i    (   i    Ni    g      Ð?(   i    Ni    g      à?(   i    Ni    g      è?(   i    i    N(   i    i    i    (   i    i    NgUUUUUUÅ?(   i    i    NgUUUUUUÕ?(   i    i    Ng      à?(   i    i    NgUUUUUUå?(   i    i    Ng«ªªªªªê?(   i    NNg      à?(   i    NNg      à?(   i    NNg      à?g      à?(   i    NNg      Ð?g      Ð?(   Ni    Ng      à?(   g      à?i    i    (   Ni    Ng      à?(   Ni    Ng      à?g      à?(   Ni    Ng      Ð?g      Ð?(   NNi    g      à?(   g      à?i    i    (   NNi    g      à?(   NNi    g      à?g      à?(   NNi    g      Ð?g      Ð?(-   t
   __future__R    RK   Rê   t   cctbx.array_familyR   t   cctbxR   R   R   t   libtbxR   RC   R   R+   R.   t   along_at	   along_a_2t	   along_b_4t   along_bt	   along_b_2t   along_ct	   along_c_2t	   along_c_3t	   along_c_4t	   along_c_6t   absences_via_intensity_symmetryR-   t   lattice_from_stringR#   t   string_from_symbolRË   t   objectR
   R*   RQ   Rë   Rì   RR   R¦   R°   t   systematic_absences_infoR»   R  R(   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/absences.pyt   <module>   sÚ  
















+4×“2	/