ó
Ñ™xTc           @   sZ   d  d l  m Z d  d l m Z d  d l Z d  d l Z d  d l Z	 d d d d „ Z d S(   iÿÿÿÿ(   t   division(   t   flexNg      ø?i2   c         C   sõ  t  j j d | ƒ } t j j } d „  }	 xÄ|  j ƒ  D]¶}
 x­|
 j ƒ  D]Ÿ} x–| j ƒ  D]ˆ} x| j	 ƒ  D]q} xh| j
 ƒ  D]Z} | j ƒ  } | d | j ƒ d k rƒ t | ƒ d k rƒ | d  k	 rî | d | j | j | j f IJn  | j ƒ  } |	 | | | ƒ } | d  k	 r)| d | IJn  | } | j ƒ  } d d	 d
 g } x| D]} x
| D]} xù | D]ñ } t j | | | f g | j ƒ  ƒ } | | } | j ƒ  j | ƒ t j j j j d | d | d d  d d d | d | d | ƒ } | j } t j t j | | j ƒ  ƒ ƒ } |	 | | | ƒ } | | k rk| | k  rk| j ƒ  } | } qkqkWq^WqQW| j ƒ  j | ƒ |	 | | | ƒ } t j t j | | j ƒ  ƒ ƒ } | d  k	 rÝ| d | IJ| d | IJqÝqƒ qƒ Wqp Wq] WqJ Wq7 Wd  S(   Nt   max_iterationsc         S   s=   | j  | ƒ } d } x! | D] } | |  j | ƒ 7} q W| S(   Ni    (   t   fractionalizet   eight_point_interpolation(   t
   target_mapt
   sites_cartt	   unit_cellt
   sites_fract   resultt	   site_frac(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/refinement/real_space/fit_water.pyt   target   s
    t   namet   common_wateri   s   chain %s resname %s resseq %ss     target_start: %6.4fg333333Ó¿i    g333333Ó?t   residuet   density_mapt   geometry_restraints_managert   real_space_target_weightt   real_space_gradients_deltat   lbfgs_termination_paramsR   s     target_final: %6.4fs     dist. moved : %6.4f(    t   scitbxt   lbfgst   termination_parameterst   iotbxt   pdbt   common_residue_names_get_classt   modelst   chainst   residue_groupst
   conformerst   residuest   atomst   resnamet   lent   Nonet   idt   resseqt   extract_xyzt	   deep_copyR   t   vec3_doublet   sizet   set_xyzt   mmtbxt
   refinementt
   real_spacet
   rigid_bodyt   refinet   sites_cart_residuet   meant   sqrtt   dot(   t   pdb_hierarchyR   R   R   t   max_allowed_shiftR   t   logR   t	   get_classR   t   modelt   chaint   residue_groupt	   conformerR   R   t   sites_cart_startt   target_startt   target_currentt   sites_cart_bestt   shift_ranget   x_shiftt   y_shiftt   z_shiftt   shiftR   t	   minimizedt   distance_movedt   tt   target_final(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/refinement/real_space/fit_water.pyt   run   sd    		*
		(   t
   __future__R    t   cctbx.array_familyR   t&   mmtbx.refinement.real_space.rigid_bodyR*   t   scitbx.lbfgsR   t	   iotbx.pdbR   R"   RH   (    (    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/refinement/real_space/fit_water.pyt   <module>   s   