ó
°™xTc           @   se  d  d l  m Z d  d l m Z d  d l Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d	 „  ƒ  YZ d
 e j f d „  ƒ  YZ	 d e j f d „  ƒ  YZ
 e j ƒ  j e ƒ Z e j ƒ  j e ƒ Z e j ƒ  j e ƒ Z e j ƒ  j e	 ƒ Z e j ƒ  j e
 ƒ Z e j e e e e e g ƒ Z d „  Z e d k rae j d d ƒ j e ƒ n  d S(   iÿÿÿÿ(   t   division(   t   clashNt   TestAltlocStrategyc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sp   t  j j ƒ  |  _ t  j j ƒ  |  _ t  j j d d ƒ |  _ t  j j d d ƒ |  _ t  j j d d ƒ |  _ d  S(   Nt
   identifiert   At   B(	   R   t   altloc_strategyt   regulart   regular1t   regular2t	   alternatet   altloc1t   altloc2t   altloc3(   t   self(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   setUp	   s
    c         C   sš   |  j  |  j |  j k ƒ |  j  |  j |  j k ƒ |  j  |  j |  j k ƒ |  j  |  j |  j k ƒ |  j  |  j |  j k ƒ |  j  |  j |  j k ƒ d  S(   N(   t   assertFalseR   R	   R   R   R   (   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_equality   s    c         C   s<   |  j  | j d | ƒ | ƒ |  j  | j d | ƒ | ƒ d  S(   Nt   other(   t   assertEqualt   is_interacting_with(   R   t   leftt   rightt   outcome(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   run_interaction_tests   s    c         C   s�   |  j  |  j |  j t ƒ |  j  |  j |  j t ƒ |  j  |  j |  j t ƒ |  j  |  j |  j t ƒ |  j  |  j |  j t ƒ d  S(   N(   R   R   t   TrueR	   R   R   R   (   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_interaction_regular#   s
    c         C   sO   |  j  |  j |  j t ƒ |  j  |  j |  j t ƒ |  j  |  j |  j t ƒ d  S(   N(   R   R   R   R   R   t   False(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_interaction_altloc,   s    (   t   __name__t
   __module__R   R   R   R   R   (    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyR      s
   						t
   TestSpherec           B   sY   e  Z d  „  Z d d „ Z d „  Z g  g  d „ Z d „  Z d „  Z d „  Z d „  Z	 RS(	   c      
   C   s‚   d |  _  d |  _ d |  _ d |  _ t j j d d ƒ |  _ t j j	 ƒ  |  _	 t j j
 d d	 ƒ |  _ t j j
 d d
 ƒ |  _ d  S(   Ni   i   i   i   i   i   i    R   R   R   (   i   i   i   (	   i   i    i    i    i   i    i    i    i   (   i    i    i   (   t   centret   radiust   moleculet   atomR   t   sgtbxt   rt_mxt   symopR   R   R
   t   altloc_at   altloc_b(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyR   5   s    				i   c         C   sS   |  j  t | ƒ t | ƒ ƒ x0 t | | ƒ D] \ } } |  j | | | ƒ q, Wd  S(   N(   R   t   lent   zipt   assertAlmostEqual(   R   R   R   t	   precisiont   lt   r(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   assertVectorsAlmostEqualB   s    c         C   sr   |  j  |  j | j ƒ |  j |  j | j ƒ |  j |  j | j ƒ |  j |  j | j ƒ |  j |  j | j ƒ d  S(   N(   R/   R    R+   R!   R   R"   R#   R&   (   R   t   sphere(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   check_sphereJ   s
    c         C   sa   | j  } x' | D] } |  j | j d | ƒ ƒ q Wx' | D] } |  j | j d | ƒ ƒ q: Wd  S(   NR   (   t   altloct
   assertTrueR   R   (   R   R0   t   interactingt   noninteractingR2   t   a(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   check_altlocS   s
    	c         C   s~   t  j d |  j d |  j d |  j d |  j d |  j d |  j ƒ } |  j d | ƒ |  j	 d | d |  j |  j
 |  j g ƒ d  S(	   NR    R!   R"   R#   R2   R&   R0   R4   (   R   R0   R    R!   R"   R#   R   R&   R1   R7   R'   R(   (   R   R0   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_regular^   s    							c         C   s„   t  j d |  j d |  j d |  j d |  j d |  j d |  j ƒ } |  j d | ƒ |  j	 d | d |  j
 |  j g d	 |  j g ƒ d  S(
   NR    R!   R"   R#   R2   R&   R0   R4   R5   (   R   R0   R    R!   R"   R#   R'   R&   R1   R7   R   R(   (   R   R0   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_altloc_ao   s    							c         C   s„   t  j d |  j d |  j d |  j d |  j d |  j d |  j ƒ } |  j d | ƒ |  j	 d | d |  j
 |  j g d	 |  j g ƒ d  S(
   NR    R!   R"   R#   R2   R&   R0   R4   R5   (   R   R0   R    R!   R"   R#   R(   R&   R1   R7   R   R'   (   R   R0   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_altloc_b�   s    							c         C   s�   t  j d |  j d |  j d |  j d |  j d t  j j d d ƒ d |  j ƒ } |  j	 d	 | ƒ |  j
 d	 | d
 |  j g d |  j |  j g ƒ d  S(   NR    R!   R"   R#   R2   R   t   CR&   R0   R4   R5   (   R   R0   R    R!   R"   R#   R   R
   R&   R1   R7   R   R'   R(   (   R   R0   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_altloc_c“   s    						(
   R   R   R   R/   R1   R7   R8   R9   R:   R<   (    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyR   3   s   						t   TestOverlapInteractionPredicatec           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   sÇ   d |  _  d |  _ d |  _ d |  _ t j j d d ƒ |  _ t j j d d ƒ |  _ t j	 j
 d d ƒ |  _ t j d t j d |  j  d |  j d	 |  j d
 |  j d |  j d |  j ƒ d d ƒ |  _ d  S(   Ni    g333333û?i   R   R   t   objectR    R!   R"   R#   R2   R&   t	   tolerance(   i    i    i    (	   i   i    i    i    i   i    i    i    i   (   i    i    i    (	   i   i    i    i    i   i    i    i    i   (   i    i    i   (   R    R!   R"   R#   R   R$   R%   R&   t   symop2R   R
   R2   t   overlap_interaction_predicateR0   t	   predicate(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyR   §   s     											c         C   s  |  j  |  j d t j d |  j d |  j d |  j d |  j d |  j d |  j	 ƒ ƒ ƒ |  j
 |  j d t j d |  j d |  j d |  j d |  j d |  j d |  j ƒ ƒ ƒ |  j  |  j d t j d d d d	 |  j f d |  j d |  j d |  j d |  j d |  j ƒ ƒ ƒ d  S(
   NR   R    R!   R"   R#   R2   R&   i    i   (   R   RB   R   R0   R    R!   R"   R#   R2   R&   R3   R@   (   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_same_atom¾   s6    																				c         C   s�  |  j  |  j d t j d |  j d |  j d |  j d |  j d d |  j d |  j	 ƒ ƒ ƒ |  j
 |  j d t j d |  j d |  j d |  j d |  j d d |  j d |  j ƒ ƒ ƒ |  j  |  j d t j d d	 d	 d
 |  j f d |  j d |  j d |  j d d |  j d |  j ƒ ƒ ƒ |  j  |  j d t j d |  j d |  j d |  j d |  j d d t j j d d ƒ d |  j ƒ ƒ ƒ d  S(   NR   R    R!   R"   R#   i   R2   R&   i    i   R   R   (   R   RB   R   R0   R    R!   R"   R#   R2   R&   R3   R@   R   R
   (   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_same_moleculeé   sH    																						c         C   s  |  j  |  j d t j d |  j d |  j d |  j d d |  j d |  j d |  j	 ƒ ƒ ƒ |  j  |  j d t j d |  j d |  j d |  j d d |  j d |  j d |  j
 ƒ ƒ ƒ |  j |  j d t j d |  j d |  j d |  j d d |  j d t j j d	 d
 ƒ d |  j	 ƒ ƒ ƒ d  S(   NR   R    R!   R"   i   R#   R2   R&   R   R   (   R3   RB   R   R0   R    R!   R"   R#   R2   R&   R@   R   R   R
   (   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_other_molecules   s6    																	(   R   R   R   RC   RD   RE   (    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyR=   ¥   s   		+	7t   TestLinearSpheresIndexerc           B   s   e  Z d  „  Z d „  Z RS(   c      
   C   sd   t  j j ƒ  |  _ d |  _ d |  _ d |  _ d |  _ t  j j	 ƒ  |  _
 t  j j d	 d
 ƒ |  _ d  S(   Ni   i   i   i   i   i   i    (   i   i   i   (	   i   i    i    i    i   i    i    i    i   (   i    i    i   (   R   t   indexingt   linear_spherest   indexerR    R!   R"   R#   R   R   R2   R$   R%   R&   (   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyR   J  s    				c         C   s  |  j  t |  j ƒ d ƒ t j d |  j d |  j d |  j d |  j d |  j	 d |  j
 ƒ } |  j j d | d	 | j ƒ |  j  t |  j ƒ d
 ƒ |  j j d | j ƒ } |  j  t | ƒ d
 ƒ t | ƒ } |  j  | j | d j ƒ |  j  | j | d j ƒ |  j  | j
 | d j
 ƒ d  S(   Ni    R    R!   R"   R#   R2   R&   R>   t   positioni   (   R   R)   RI   R   R0   R    R!   R"   R#   R2   R&   t   addt   close_tot   list(   R   R0   t   closebyt   spheres(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   test_structureV  s     						(   R   R   R   RP   (    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyRF   H  s   	t   TestHashSpheresIndexerc           B   s   e  Z d  „  Z d „  Z RS(   c      
   C   s”   d d  l  } t j j d | j j j d d d d ƒ d d ƒ |  _ d |  _ d
 |  _	 d |  _
 d |  _ t j j ƒ  |  _ t j j d d ƒ |  _ d  S(   Niÿÿÿÿt	   voxelizert   basei    t   stepi   t   margini   i   i   i   i   (   i    i    i    (   i   i   i   (   i   i   i   (	   i   i    i    i    i   i    i    i    i   (   i    i    i   (   t   mmtbx.geometry.shared_typesR   RG   t   hash_spherest   geometryt   shared_typesRR   RI   R    R!   R"   R#   R   R   R2   R$   R%   R&   (   R   t   mmtbx(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyR   s  s    					c         C   sa  |  j  t |  j ƒ d ƒ t j d |  j d |  j d |  j d |  j d |  j	 d |  j
 ƒ } |  j j d | d	 | j ƒ |  j  t |  j ƒ d
 ƒ |  j j d | j ƒ } |  j  t | ƒ d
 ƒ t | ƒ } |  j  | j | d j ƒ |  j  | j | d j ƒ |  j  | j
 | d j
 ƒ |  j j d g  |  j D] } | d ^ q.ƒ } |  j  t | ƒ d ƒ d  S(   Ni    R    R!   R"   R#   R2   R&   R>   RJ   i   i   (   R   R)   RI   R   R0   R    R!   R"   R#   R2   R&   RK   RL   RM   (   R   R0   RN   RO   t   c(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyRP   †  s$    						/(   R   R   R   RP   (    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyRQ   q  s   	c         C   s   t  S(   N(   t   alltests(   t   loadert   testst   pattern(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt
   load_testsÀ  s    t   __main__t	   verbosityi   (   t
   __future__R    t   mmtbx.geometryR   t   unittestt   TestCaseR   R   R=   RF   RQ   t
   TestLoadert   loadTestsFromTestCaset   suite_altloc_strategyt   suite_spheret#   suite_overlap_interaction_predicatet   suite_linear_spheres_indexert   suite_hash_spheres_indexert	   TestSuiteR\   R`   R   t   TextTestRunnert   run(    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/geometry/tests/tst_clash.pyt   <module>   s4   ,r£)3						