ó
‚™xTc           @   s·   d  d l  m Z d  d l m Z m Z m Z d  d l Z d  d l Z d  d l	 m
 Z
 d  d l Z d  d l Z e j j d d e ƒZ e j d „ Z e d k r³ e e j d	 ƒ n  d S(
   iÿÿÿÿ(   t   division(   t   Sorryt   Usaget   show_development_warningN(   t   StringIOs  
data_file_1 = None
  .type = path
data_file_2 = None
  .type = path
labels_1 = None
  .type = str
labels_2 = None
  .type = str
include scope iotbx.command_line.patterson_map.patterson_map_phil_str
relative_diff_limit = 0.1
  .type = float
map_file_name = iso_diff.ccp4
  .type = path
t   process_includesc      	   C   s‰  t  d | ƒ t |  ƒ d k s+ d |  k rJ t d t j d d ƒ ƒ ‚ n  d d l m } d d	 l m } d d  l	 } g  } d  } } xë |  D]ã } t j j | ƒ r1| j | ƒ }	 |	 j d
 k rÖ | j |	 j ƒ qp|	 j d k r| d  k rú |	 } q.| d  k r|	 } q.t d ƒ ‚ qpt d | ƒ ‚ q� y | j t j j | ƒ ƒ Wq� t k
 ro}
 t d ƒ ‚ q� Xq� Wt j d | ƒ j ƒ  } | j d  k	 r°| j | j ƒ } n  | j d  k	 rÔ| j | j ƒ } n  d  | | g k rýt d d d ƒ ‚ n  | j j ƒ  } | j | ƒ \ } } | j | ƒ \ } } t ƒ  } | j d | ƒ | s[| rxt d d | j  ƒ  ƒ ‚ n7 | s„| r¯t j! d d d d d d | j  ƒ  ƒ n  | j" d d  d | d | j# d | ƒ } | j" d d  d | d | j$ d | ƒ } d  | | g k st% ‚ | d IJ| d IJ| j& d  | d d ƒ | d IJ| d! IJ| j& d  | d d ƒ | d IJ| j' d" | ƒ } | j( | | ƒ j) ƒ  } | j( | | ƒ j) ƒ  } | j* d# | ƒ \ } } | d$ IJ| j+ d# | ƒ } d d% l, m- } | d& | j. | j/ ƒ  ƒ | j. | j/ ƒ  ƒ f IJ| j' d | j/ ƒ  | j/ ƒ  ƒ } | j0 d  k	 r| j1 | j/ ƒ  d k ƒ } | j2 d# | ƒ } | j' d | j/ ƒ  | j/ ƒ  ƒ } | j1 | j/ ƒ  | j0 k  ƒ } t | j/ ƒ  ƒ t | j/ ƒ  ƒ } | d k r| d' | IJqn  | d( | j. | j/ ƒ  ƒ IJ| j3 d | d) | d* t4 ƒ } | j5 d  k rad+ | _5 n  | j6 d | j5 ƒ | d, | j5 IJd  S(-   Nt   outi    s   --helps@  cctbx.isomorphous_difference_patterson xtal1.mtz xtal2.mtz [options]

Calculate an isomorphous difference Patterson map from two datasets.  You may
specify both in a single MTZ file if you want, but you must manually specify
the data_file_1 and data_file_2 parameters.  Output is a CCP4-format map.

Full parameters:
%s
t   prefixs     iÿÿÿÿ(   t   patterson_map(   t   file_readert   philt   hkls0   No more than two reflection files are supported.s2   The file format for '%s' is not a supported input.s   Unrecognized argument '%s'.t   sourcess;   You must provide two datasets for this program to run.  If sF   they are different arrays within a specific file, you need to specify sD   the parameters explicitly, i.e. 'data_file_1=NAME data_file_2=NAME'.s7   Incompatible space groups in input files:
%s
All files sC   must have the same point group (and ideally the same space group). t   messaget   warnt   datas9   Crystal symmetry mismatch:
%s
Calculations will continue sB   using the symmetry in the PDB file first reflection file, but the s+   maps should be treated with some suspicion.t	   file_namet   hkl_int   expected_labelst    s,   Data array #1 (will use symmetry from here):t   fs   Data array #2:t   crystal_symmetryt   others   Scaling second dataset...(   t   flexs      max(F1) = %.2f  max(F2) = %.2fs4   Discarded %d reflections with excessive differences.s     max(delta_F) = %.2ft   paramst	   normalizes   iso_diff.ccp4s   Wrote %s(7   R   t   lenR   t   master_philt   as_strt   iotbx.command_lineR   t   iotbxR	   t   iotbx.symmetryt   Nonet   ost   patht   isfilet   any_filet	   file_typet   appendt   file_objectR   t   libtbxR
   t   parset   RuntimeErrort   fetcht   extractt   data_file_1t   data_file_2t   symmetryt   managert   process_reflections_fileR   t   showt   getvaluet	   call_backt   extract_datat   labels_1t   labels_2t   AssertionErrort   show_summaryt   customized_copyt   prepare_f_obst   average_bijvoet_matest   common_setst
   multiscalet   scitbx.array_familyR   t   maxR   t   relative_diff_limitt   selectt
   common_sett   calculate_patterson_mapt   Falset   map_file_namet   as_ccp4_map(   t   argsR   R   R	   R   R   R-   R.   t   argR   t   eR   t   symm_managert   sg_err_1t   uc_err_1t   sg_err_2t   uc_err_2t   out_tmpt   obs_1t   obs_2t   f_obs_1t   f_obs_2R   t   delta_ft   f_obs_1_non_zerot   delta_f_non_zerot   relative_difft   n_discardedt   map(    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/isomorphous_difference_patterson.pyt   run   s¼    	
									





"	"		
t   __main__i   (   t
   __future__R    t   libtbx.utilsR   R   R   t   libtbx.callbacksR(   t   libtbx.philt	   cStringIOR   R!   t   sysR
   R)   t   TrueR   t   stdoutR[   t   __name__t   argv(    (    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/isomorphous_difference_patterson.pyt   <module>   s   	m