ó
±™xTc           @   sæ   d  d l  m Z d  d l m Z m Z d  d l m Z m Z d  d l m	 Z	 d  d l
 Z d  d l Z e j j d d e ƒZ e Z d d e j d „ Z d	 „  Z d
 e	 j f d „  ƒ  YZ d „  Z e d k râ e e j d ƒ n  d S(   iÿÿÿÿ(   t   division(   t   make_sub_headert   format_value(   t   Sorryt   Usage(   t   runtime_utilsNs˜  
data = None
  .type = path
  .help = Data file (usually MTZ) containing R-free flags and either the     pre-calculated F(model) array or experimental amplitudes or intensities.
  .style = file_type:hkl input_file bold process_hkl child:ampl:f_obs_labels            child:rfree:r_free_flags.label child:fmodel:f_model_labels            force_data
f_obs_labels = None
  .type = str
  .help = Column labels for experimental data array
  .short_caption = F(obs) labels
  .input_size = 150
  .style = bold renderer:draw_fobs_label_widget
f_model_labels = None
  .type = str
  .short_caption = F(model) labels
  .style = renderer:draw_fmodel_label_widget
  .input_size = 150
r_free_flags.label = None
  .type = str
  .help = Column label for R-free flags
  .short_caption = Free R label
  .style = bold renderer:draw_rfree_label_widget
  .input_size = 150
r_free_flags.test_flag_value = None
  .type = int
  .help = Test flag value.  Not normally required.
model = None
  .type = path
  .help = Model file, required if F(model) is not pre-calculated.
  .style = file_type:pdb input_file
unmerged_data = None
  .type = path
  .help = File containing scaled, unmerged intensities
  .style = bold file_type:hkl OnChange:extract_unmerged_intensities input_file
unmerged_labels = None
  .type = str
  .help = Labels for unmerged intensity array
  .style = bold renderer:draw_unmerged_intensities_widget
  .input_size = 150
n_bins = 20
  .type = int(value_min=5, value_max=50)
  .help = Number of resolution bins
  .input_size = 64
  .style = spinner
include scope iotbx.merging_statistics.sigma_filtering_phil_str
include scope libtbx.phil.interface.tracking_params
loggraph = False
  .type = bool
t   process_includesc         C   s1  |  | g j  d  ƒ d k s! t ‚ |  d  k	 rµ t |  ƒ d k sK d |  k rp t d t j d d d d ƒ ƒ ‚ n  d d  l } | j j	 d	 |  d
 t d d d d ƒ } | j
 j ƒ  } n  d d  l } d d  l } d d l m } d d l m } | j d  k rt d ƒ ‚ n  | j d  k r)t d ƒ ‚ n  | j | j d d ƒ} | j d ƒ d  }	 }
 } g  } g  } g  } | j d  k rþxp | j j D]b } | j ƒ  j ƒ  } | j ƒ  rŠ| j d ƒ sÌ| j d ƒ rì| j | ƒ | j | ƒ qìqŠqŠWt | ƒ d k r"t d d d j | ƒ ƒ ‚ q_t | ƒ d k r‘| d }	 |	 j ƒ  rn|	 j ƒ  } |	 j  ƒ  j! | ƒ }	 n  | d IJ|	 j" d | d d ƒ q_| j j# d | j d | j$ d t% d  d! ƒ } | j& ƒ  rõd d" l' m( } | j) d# | d$ | ƒ }
 q_| }
 na x^ | j j D]P } | j ƒ  j ƒ  } | | j k r| j ƒ  rH| }	 Pq[t d% | ƒ ‚ qqW|	 d  k	 r |
 d  k s}t ‚ x  | j j D]1 } | j ƒ  j ƒ  } | | j$ k rŠ| }
 PqŠqŠWy: | j j* d | j$ d d  d& t+ d' d( d  d! d) t% ƒ }
 Wq t k
 rt d* d+ ƒ ‚ q Xn  |
 j, ƒ  s2t ‚ |
 j ƒ  rb|
 j ƒ  } |
 j  ƒ  j! | ƒ }
 n  | d, IJ|
 j" d | d d ƒ | d! IJ| j j- d | j d- | j. j/ d. | j. j0 d/ t+ d  d! ƒ \ } } | j ƒ  } | j1 d | j ƒ  | k ƒ j! | ƒ } | j ƒ  r%| j  ƒ  j! | ƒ } n  | d0 IJ| j" d | d d ƒ | d! IJ| j2 j3 d1 |
 d | j d2 | j4 d3 | ƒ } | d4 IJ| j" d | d d ƒ | d! IJ|	 d  k rj|
 d  k	 sÄt ‚ | j5 d  k rât d5 ƒ ‚ n  t6 d6 d$ | ƒ| j | j5 d d7 ƒ} | j d7 ƒ | j7 j8 ƒ  } | d  k r;|
 } n^ |
 j8 ƒ  d  k rb|
 j1 d8 | ƒ }
 n7 | j9 |
 ƒ s™| j2 j: d9 d: d; d< d= | d> |
 ƒ n  | j7 j; d8 | ƒ } d d? l< m= } |
 j ƒ  rÙ|
 j  ƒ  }
 n  |
 j> ƒ  }
 |
 j? ƒ  j@ d@ | j? ƒ  ƒ \ }
 } | d1 |
 dA | dB | g dC t% dD dE ƒ } | jA d3 | ƒ | jB ƒ  }	 |	 j1 d | jC jD ƒ } n3 |	 j ƒ  r…|	 j  ƒ  }	 n  |	 j@ d@ | ƒ \ }	 } | jE jF jG dF |	 d1 |
 dA | dG | dH | jH dI | jI ƒ } | jJ d$ | ƒ | jK r| jL d$ | ƒ n  | d! IJ| dJ IJ| dK IJ| d! IJ| S(L   Ni   i    s   --helps5  
  phenix.cc_star model.pdb data.mtz unmerged_data=data.hkl [n_bins=X] [options]
  phenix.cc_star model_refine_001.mtz unmerged_data=data.hkl [...]

Implementation of the method for assessing data and model quality described in:
  Karplus PA & Diederichs K (2012) Science 336:1030-3.

Full parameters:
  %s
  t   prefixt    t   attributes_leveliÿÿÿÿt   argst   master_philt   pdb_file_deft   modelt   reflection_file_deft   data(   t   merging_statistics(   t   file_readers0   Please specify a data file (usually MTZ format).s!   Please specify unmerged_data filet
   force_typet   hkls   F-modelt   FMODELs6   Multiple F(model) arrays found:
%s
Please specify the s   'labels' parameter.s   
s	   F(model):t   fs     t	   file_namet   labelst   ignore_all_zerost   parameter_scopet    (   t   french_wilsont   miller_arrayt   outs,   The data in %s are not of the required type.t"   convert_to_amplitudes_if_necessaryt   parameter_namet   f_obs_labelst   stricts9   You must supply a file containing both F-obs and F-model s2   if you want to use a pre-calculated F-model array.s   F(obs):t   labelt   test_flag_valuet   disable_suitability_tests   R-free flags:t   f_obst   data_labelst   logs   Unmerged intensities:s9   A PDB file is required if F(model) is not pre-calculated.s   Calculating F(model)t   pdbt   crystal_symmetryt   file1s   PDB filet   file2s	   data filet   symm1t   symm2(   t   fmodel_simplet   othert   r_free_flagst   xray_structurest   skip_twin_detectiont   scattering_tablet
   n_gaussiant   f_modelt   unmerged_i_obst   n_binst   sigma_filterings
   Reference:s6     Karplus PA & Diederichs K (2012) Science 336:1030-3.(M   t   countt   Nonet   AssertionErrort   lenR   R   t   as_strt
   iotbx.philt   philt   process_command_line_with_filest   workt   extractt   mmtbx.command_linet   mmtbx.validation.experimentalt   iotbxR   R   R   R   t   unmerged_datat   any_filet   check_file_typet   f_model_labelst   file_servert   miller_arrayst   infot   label_stringt   is_complex_arrayt
   startswitht   appendt   joint   anomalous_flagt   average_bijvoet_matest   set_infot   show_summaryt   get_xray_dataR    t   Truet   is_xray_intensity_arrayt   cctbxR   t   french_wilson_scalet   get_amplitudest   Falset   is_xray_amplitude_arrayt   get_r_free_flagsR0   R"   R#   t   customized_copyt   command_linet   load_and_validate_unmerged_datat   unmerged_labelsR   R   t   file_objectR)   t   is_similar_symmetryt   show_symmetry_errort   xray_structure_simplet   mmtbx.utilsR.   t   eliminate_sys_absentt
   map_to_asut   common_setst   showR5   t   arrayst   free_selt
   validationt   experimentalt   merging_and_model_statisticsR7   R8   t   show_cc_start   loggrapht   show_loggraph(   R
   t   paramsR   RE   t   cmdlinet   mmtbxR   R   t   hkl_inR5   R%   R0   t   f_modelst   data_arraysRI   t   arrayR   RL   t
   data_arrayR   t   array_labelsR#   R6   t   pdb_int   pdb_symmt   xray_structureR.   t   fmodelt   stats(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/cc_star.pyt   run?   sD   !	"	

						

		

			

	
					



c         C   sb   |  j  d  k s |  j d  k r- t d ƒ ‚ n  |  j d  k r^ |  j d  k r^ t d d ƒ ‚ n  t S(   Ns   No experimental data supplied!s8   You must supply either a pre-calculated F(model) array, s   or the current refined model.(   R   R:   R    R   RI   R   RW   (   Rt   (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/cc_star.pyt   validate_paramsô   s    t   launcherc           B   s   e  Z d  „  Z RS(   c         C   s   t  d t |  j ƒ d t j ƒ S(   NR
   R   (   R‚   t   listR
   t   syst   stdout(   t   self(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/cc_star.pyR‚   ý   s    (   t   __name__t
   __module__R‚   (    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/cc_star.pyR„   ü   s   c         C   sa  g  } |  d  k	 rWd t d |  j j ƒ f d t d |  j j ƒ f d t d |  j j ƒ f d t d |  j d j ƒ f d	 t d
 |  j j d ƒ f d t d
 |  j d j d ƒ f d t d |  j j ƒ f d t d |  j d j ƒ f d t d |  j j	 ƒ f d t d |  j d j	 ƒ f d t d |  j j
 ƒ f d t d |  j d j
 ƒ f g } n  g  | f S(   Ns   High resolutions   %.3gt
   Redundancys   %.1fs	   <I/sigma>s   %.2gs   <I/sigma> (high-res)iÿÿÿÿt   Completenesss   %.1f%%id   s   Completeness (high-res)s   CC*s   %.3fs   CC* (high-res)s   CC(work)s   CC(work) (high-res)s   CC(free)s   CC(free) (high-res)(   R:   R   t   overallt   d_mint   mean_redundancyt   i_over_sigma_meant   binst   completenesst   cc_start   cc_workt   cc_free(   t   resultR�   (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/cc_star.pyt
   finish_job   s"    		%t   __main__i   (   t
   __future__R    t   libtbx.str_utilsR   R   t   libtbx.utilsR   R   t   libtbxR   t   libtbx.philR†   R?   t   parseRW   R   t   master_paramsR:   R‡   R‚   Rƒ   t   target_with_save_resultR„   R—   R‰   t   argv(    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/cc_star.pyt   <module>   s   	2µ		