ó
šxTc           @   sH   d  d l  m Z d  d l m Z d  d l Z d  d l Z d d „ Z d S(   iÿÿÿÿ(   t   division(   t   SorryNc      	   C   sæ  | d k r t j } n  d d l m } d d l m } d d l } | j |  d d ƒ} | j	 d ƒ | j
 j } d }	 xJ | D]B }
 |
 j ƒ  j ƒ  } | d k r¬ |
 } q | d k r |
 }	 q q W| d k sÝ |	 d k rì t d	 ƒ ‚ n  | j ƒ  r| j ƒ  } n  |	 j ƒ  r"|	 j ƒ  }	 n  | j |	 ƒ } |	 j | ƒ }	 | j ƒ  |	 j ƒ  k s^t ‚ | j d
 | d |	 d | d | ƒ } | j } | j d d d | j j ƒ  ƒ } | j ƒ  } t j j |  ƒ d d } | j d | ƒ | S(   s  
  Run simple solvent-flipping in mmtbx.density_modification on Phaser output.
  f_obs will be None if molecular replacement was run, since the output MTZ
  file will include anisotropy-corrected amplitudes.  Unfortunatley the EP
  mode does not currently output these data.
  iÿÿÿÿ(   t   density_modification(   t   file_readerNt
   force_typet   hkls   F,SIGFs   HLA,HLB,HLC,HLDs'   Missing F-obs or HL coefficients array.t   f_obst   hl_coeffs_startt   paramst   logt   column_root_labelt   FWTt   label_decoratori    s   _dm.mtzt	   file_name(   t   Nonet   syst   stdoutt   mmtbxR   t   iotbxR   t	   iotbx.mtzt   any_filet   assert_file_typet   file_servert   miller_arrayst   infot   label_stringR   t   anomalous_flagt   average_bijvoet_matest
   common_sett   indicest   AssertionErrort   map_coeffs_in_original_settingt   as_mtz_datasett   mtzt   ccp4_label_decoratort
   mtz_objectt   ost   patht   splitextt   write(   t   phases_fileR   R   R	   R   R   R   t
   phaser_outR   t	   hl_coeffst   arrayt   labelst   run_dmt
   map_coeffst   mtz_datasetR#   t   mtz_out(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/phenix_interface/dm.pyt   run_density_modification   sJ    					(	   t
   __future__R    t   libtbx.utilsR   t   os.pathR$   R   R   R1   (    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/phenix_interface/dm.pyt   <module>   s   