ó
Ž™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 m Z d  d	 l m Z d  d l Z d  d l Z d
 „  Z d d d d „ Z d „  Z e d k rÞ e ƒ  n  d S(   iÿÿÿÿ(   t   divisionN(   t   random_structure(   t   miller(   t   crystal(   t   sgtbx(   t   flex(   t	   show_diff(   t   StringIOc       
   C   sy  t  j d ƒ }  t  j d  ƒ } t  j |  | t ƒ } t  j d! ƒ } t j d t j d d" d
 d ƒ d t  j d# d$ g ƒ d t	 ƒ } t
 ƒ  } | j d | ƒ j d | ƒ t | j ƒ  d ƒ sÂ t ‚ t
 ƒ  } | j d | ƒ j d | d t	 ƒ t | j ƒ  d ƒ s	t ‚ xs | j d | ƒ | g D]Y } t
 ƒ  } | j d | ƒ j ƒ  j d | d | d t ƒ t | j ƒ  d ƒ s"t ‚ q"Wx‰ | j d | t j d ƒ | t j d g D]Y } t
 ƒ  } | j d | ƒ j ƒ  j d | d | d t	 ƒ t | j ƒ  d ƒ s®t ‚ q®Wxg | j d | ƒ | g D]M } t
 ƒ  } | j d | ƒ j d | d | ƒ t | j ƒ  d ƒ s$t ‚ q$Wd  S(%   Ni
   i   içÿÿÿic  g333333Ó?gÍÌÌÌÌÌì?t   crystal_symmetryt	   unit_celliZ   t   space_group_symbolt   P1t   indicesi   i   i   iýÿÿÿi   iúÿÿÿt   anomalous_flagt   datat   outsJ      1   2   3 4999.99    1.00  -25.00
  -3   4  -6 9999.99    1.00   -5.00
t   scale_amplitudessJ      1   2   3   10.00    1.00  -25.00
  -3   4  -6   20.00    1.00   -5.00
t   phasest
   phases_degsJ      1   2   3 4999.99    1.00  -25.00
  -3   4  -6 9999.99    1.00  355.00
i´   t   figures_of_meritsJ      1   2   3 4999.99    0.30  -25.00
  -3   4  -6 9999.99    0.90   -5.00
(   i
   i   (   içÿÿÿic  (   g333333Ó?gÍÌÌÌÌÌì?(   i
   i
   i
   iZ   iZ   iZ   (   i   i   i   (   iýÿÿÿi   iúÿÿÿ(   R   t   doublet   polart   TrueR   t   setR   t   symmetryt   miller_indext   FalseR   t   arrayt   as_phases_phsR   t   getvaluet   AssertionErrort
   amplitudest   matht   pi(   t   at   pt   ct   ft   sR   R   R   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/regression/tst_phases.pyt   exercise_basic   sF    						"	5		"i
   g      ø?i    c      
   C   sÿ   t  j |  d d g | d d d d d t ƒ} d s: | rR | j ƒ  | j ƒ  Hn  d	 GH| j d
 d d d ƒ } t d d ƒ j | ƒ d s‘ | r• Hn  | j d | d t ƒ j	 ƒ  } d s¿ | rÍ | j ƒ  Hn  d GH| j
 d t d d ƒ ƒ d s÷ | rû Hn  d  S(   Nt   elementst   Sit   volume_per_atomiè  t   min_distanceg      @t   general_positions_onlyi    s   Writing tmp.pdbt   remarks   random structuret   resnamet   RNDs   tmp.pdbt   wt   d_minR   s   Writing: tmp.phsR   s   tmp.phs(   R   t   xray_structureR   t   show_summaryt   show_scattererst   as_pdb_filet   opent   writet   structure_factorst   f_calcR   (   t   space_group_infot
   n_elementsR1   t   verboset	   structureR&   R9   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/regression/tst_phases.pyt   generate_random_f_calc<   s4    	

			
c          C   sž   t  ƒ  t t j ƒ d k r• d }  g  } x= t j d D]. } | j ƒ  d k rW d }  q6 | j | ƒ q6 Wx* | D] } t t j | ƒ d |  ƒqo Wn  d GHd  S(   Ni   i    s	   --verboseR<   t   OK(	   R'   t   lent   syst   argvt   lowert   appendR>   R   R:   (   R<   t   argst   arg(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/regression/tst_phases.pyt   run\   s    	 t   __main__(   t
   __future__R    t   iotbx.pdb.xray_structuret   iotbxt   cctbx.developmentR   t   cctbxR   R   R   t   cctbx.array_familyR   t   libtbx.test_utilsR   t	   cStringIOR   R    RA   R'   R>   RG   t   __name__(    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/regression/tst_phases.pyt   <module>   s"   	1	