ó
«™xTc           @   s¾  d  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 d	 l m Z d d
 l m Z d d l m Z d d l Z d d l Z d d l m Z d d l Z d d l m Z d d l m Z d d l m Z m Z d d l m Z m Z m Z d d l m Z d d l m  Z  d d l! Z d d l" m Z d d l# Z# d d l$ Z$ d Z% d Z& d Z' d Z( e j) j* d d e+ ƒZ, e- d „ Z. d „  Z/ d e	 j0 j1 e j2 j3 f d „  ƒ  YZ2 d e	 j0 j1 f d „  ƒ  YZ4 d  e	 j0 j1 f d! „  ƒ  YZ5 d" e	 j0 j1 f d# „  ƒ  YZ6 d$ „  Z7 d% e8 e- e- d& „ Z9 e- e$ j: d' „ Z; d( e  j< f d) „  ƒ  YZ= d* „  Z> e- d+ „ Z? d, e@ f d- „  ƒ  YZA d S(.   s"   
Main program driver for Xtriage.
iÿÿÿÿ(   t   division(   t   data_statistics(   t   relative_wilson(   t   pair_analyses(   t   twin_analyses(   t   matthewsN(   t   reflection_file_reader(   t   reflection_file_utils(   t   crystal_symmetry_from_any(   t   pdb(   t   flex(   t   crystal(   t   Sorryt	   multi_out(   t   StringIOt   make_big_headert   wordwrap(   t   null_out(   t   runtime_utils(   R   i   g333333Ó?gffffffæ?gÍÌÌÌÌÌì?sæ  scaling {
input {
  asu_contents
    .help = "Defines the ASU contents"
    .short_caption = ASU contents
  {
    sequence_file = None
      .type = path
      .help = File containing protein or nucleic acid sequences.  Values for         n_residues and n_bases will be extracted automatically if this is         provided.
      .style = file_type:seq input_file seq_file
    n_residues=None
      .type=float
      .help="Number of residues in structural unit"
      .short_caption = Number of residues
    n_bases=None
      .type=float
      .help="Number of nucleotides in structural unit"
      .short_caption = Number of nucleotides
    n_copies_per_asu=None
      .type=float
      .help="Number of copies per ASU. If not specified, Matthews analyses is performed"
      .short_caption = Number of copies in ASU
  }

  xray_data
   .help="Defines xray data"
    .style = auto_align
  {
    file_name=None
      .type=path
      .help="File name with data"
      .short_caption = Reflections
      .style = bold noauto file_type:hkl input_file process_hkl         update_d_max_min child:fobs:obs_labels child:fcalc:calc_labels         child:space_group:space_group child:unit_cell:unit_cell         child:d_min:high_resolution child:d_max:low_resolution
    obs_labels=None
      .type=strings
      .help="Labels for observed data"
      .short_caption = Data labels
      .input_size = 160
      .style = bold renderer:draw_xtriage_hkl_label_widget         OnChange:auto_update_label_choice parent:file_name:file_name         child:d_min:high_resolution child:d_max:low_resolution
    calc_labels=None
      .type=strings
      .help="Lables for calculated data"
      .short_caption = Fcalc labels
      .input_size = 160
      .style = bold renderer:draw_xtriage_hkl_label_widget
    unit_cell=None
      .type=unit_cell
      .help="Unit cell parameters"
      .style = bold
    space_group=None
      .type=space_group
      .help="space group"
      .style = bold
    high_resolution=None
      .type=float
      .help="High resolution limit"
      .input_size = 64
      .style = bold renderer:draw_resolution_widget
    low_resolution=None
      .type=float
      .help="Low resolution limit"
      .input_size = 64
      .style = bold renderer:draw_resolution_widget
    skip_sanity_checks = False
      .type = bool
      .help = Disable guards against corrupted input data.
      .expert_level = 3
    reference
      .help = "A reference data set. For the investigation of possible reindexing options"
      .short_caption = Reference data
      .style = noauto
    {
      data
        .help="Defines an x-ray dataset"
        .short_caption = X-ray data
        .style = box auto_align
      {
        file_name=None
          .type = path
          .help = "File name"
          .short_caption = Reference x-ray file
          .style = bold file_type:hkl process_hkl input_file update_d_max_min                    child:fobs:labels child:space_group:space_group                    child:unit_cell:unit_cell
        labels=None
          .type=strings
          .help="Labels"
          .input_size = 160
          .short_caption = Data labels
          .style = bold renderer:draw_xtriage_hkl_label_widget                    parent:file_name:file_name
        unit_cell=None
          .type=unit_cell
          .help=""Unit cell parameters"
        space_group=None
          .type=space_group
          .help="Space group"
      }
      structure{
         file_name=None
         .type=path
         .help="Filename of reference PDB file"
         .short_caption = Reference PDB file
         .style = file_type:pdb noauto input_file OnChange:extract_symmetry
      }
    }
  }


  parameters
   .help="Basic settings"
  {
    reporting
      .help="Some output issues"
    {
      verbose=1
        .type=int
        .help="Verbosity"
      log=logfile.log
        .type=str
        .help="Logfile"
        .style = hidden
      loggraphs = False
        .type = bool
    }

    merging
      .short_caption = Merging options
      .style = menu_item
    {
      n_bins = 10
        .type = int
        .short_caption = Number of bins for merging
      skip_merging = False
        .type = bool
        .expert_level = 1
    }

    misc_twin_parameters
      .help="Various settings for twinning or symmetry tests"
      .short_caption = Other settings
      .style = menu_item auto_align
    {
      missing_symmetry
         .help = "Settings for missing symmetry tests"
      {
        sigma_inflation = 1.25
         .type=float
         .help="Standard deviations of intensities can be increased to make point group determination more reliable."
       }

       twinning_with_ncs
       .help="Analysing the possibility of an NCS operator parallel to a twin law."
       {
         perform_analyses = False
         .type = bool
         .help = "Determines whether or not this analyses is carried out."
         .short_caption = Analyze twinning with NCS
         n_bins = 7
         .type = int
         .help = "Number of bins used in NCS analyses."
         .short_caption = Number of bins
       }

       twin_test_cuts
       .help = "Various cuts used in determining resolution limit for data used in intensity statistics "
        .short_caption = Twin test cutoffs
       .style = box auto_align
       {
         low_resolution=10.0
         .type=float
         .help="Low resolution"
         high_resolution=None
         .type=float
         .help = "High resolution"
         isigi_cut=3.0
         .type=float
         .help="I/sigI ratio used in completeness cut "
         completeness_cut=0.85
         .type=float
         .help='''Data is cut at resolution where intensities with
            I/sigI greater than isigi_cut are more than
            completeness_cut complete'''
       }
       apply_basic_filters_prior_to_twin_analysis=True
         .type=bool
         .help="Keep data cutoffs from the basic_analyses module (I/sigma,Wilson scaling,Anisotropy) when twin stats are computed."

     }
   }
   optional {
     include scope mmtbx.scaling.massage_twin_detwin_data.output_params_str
     include scope mmtbx.scaling.massage_twin_detwin_data.master_params
   }

   expert_level=1
    .type=int
    .expert_level=10
    .help="Expert level"
}
gui
  .help = GUI-specific parameters, not applicable to command-line version.
{
  result_file = None
    .type = path
    .help = Pickled result file for Phenix GUI
  output_dir = None
    .type = path
    .style = output_dir
    .short_caption = Output directory
  include scope libtbx.phil.interface.tracking_params
}
}
t   process_includesc            sp   ˆ d  k r t j ‰ n  d ‰  ‡  ‡ f d †  } ˆ ˆ  IJ| |  ƒ | d ƒ | d ƒ | d ƒ ˆ ˆ  IJd  S(   Ns=   #############################################################c            s`   t  d t ˆ  ƒ t |  ƒ d ƒ } t | d ƒ } | | } ˆ d d | |  d | f IJd  S(   Ni    i   i   s
   ##%s%s%s##t    (   t   maxt   lent   int(   t   st   bt   lt   r(   t   hashest   out(    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   print_centered	  s    #
t    s.   P.H. Zwart, R.W. Grosse-Kunstleve & P.D. Adams(   t   Nonet   syst   stdout(   t   applR   R   (    (   R   R   sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   print_banner  s    




c         C   s   d t  ƒ  GHd  S(   Nsœ  
--------------------------------------------------------------------------------
Usage: %(appl)s file_name=myfile.sca <options>

%(appl)s performs a variety of twinning and related test on the given
x-ray data set. See CCP4 newletter number 42, July 2005 for more information.
(http://www.ccp4.ac.uk/newsletters/newsletter42/newsletter42.pdf)


The program options are summarized below

1. scope: asu_contents
   keys: * n_residues :: Number of residues per monomer/unit
         * n_bases :: Number of nucleotides per monomer/unit
         * n_copies_per_asu :: Number of copies in the ASU.

   These keywords control the determination of the absolute scale.
   If the number of residues/bases is not specified, a solvent content of 50%%
   is assumed.


2a.scope: xray_data
   keys: * file_name :: file name with xray data.
         * obs_labels :: labels for observed data is format is mtz of XPLOR/CNS
         * calc_labels :: optional; labels for calculated data
         * unit_cell :: overrides unit cell in reflection file (if present)
         * space_group :: overrides space group in reflection file (if prersent)
         * high_resolution :: High resolution limit of the data
         * low_resolution :: Low resolution limit of the data

   Note that the matching of specified and present labels involves a sub-string
   matching algorithm. See 'Example usage'.


2b.scope: xray_data.reference : A reference data set or structure.
   keys:  data.file_name :: file name for xray data
          structure.file_name :: file name of a PDB.
                                 Specification of a reference structure
                                 triggers RvsR cacluations.

3. scope: parameters.misc_twin_parameters.missing_symmetry
   keys: * sigma_inflation :: Sigma inflation value in scoring function.

   sigma_intensity_in_scoring_function = sigma_intensity*sigma_inflation

   Larger values of sigma inflation will tend to result in the point group
   selection algorithm to favour higher symmetry. If data is processed
   reasonably, the default should be fine.

4. scope: parameters.misc_twin_parameters.twinning_with_ncs
   keys: * perform_test :: can be set to True or False
         * n_bins :: Number of bins in determination of D_ncs

   The perform_test is by default set to False. Setting it to True triggers the
   determination of the twin fraction while taking into account NCS parallel to
   the twin axis.


5. scope: parameters.misc_twin_parameters.twin_test_cuts
   keys: * high_resolution : high resolution for twin tests
         * low_resolution: low resolution for twin tests
         * isigi_cut: I/sig(I) threshold in automatic determination
                      of high resolution limit
         * completeness_cut: completeness threshold in automatic
                             determination of high resolution limit

   The automatic determination of the resolution limit for the twinning test
   is determined on the basis of the completeness after removing intensities for
   which I/sigI<isigi_cut. The lowest limit obtain in this way is 3.5A.
   The value determined by the automatic procedure can be overruled by
   specification of the high_resolution keyword. The low resolution is set to
   10A by default.


6. scope: parameters.reporting
   keys: * verbose :: verbosity level.
         * log :: log file name

7. scope: xray_data
   keys: * file_name :: file name with xray data.
         * obs_labels :: labels for observed data is format is mtz of XPLOR/CNS
         * calc_labels :: optional; labels for calculated data
         * unit_cell :: overrides unit cell in reflection file (if present)
         * space_group :: overrides space group in reflection file (if prersent)
         * high_resolution :: High resolution limit of the data
         * low_resolution :: Low resolution limit of the data

   Note that the matching of specified and present labels involves a sub-string
   matching algorithm. See 'Example usage'.


Example usage:

  The commands
    %(appl)s xray_data.file_name=my_refl.mtz
    %(appl)s my_refl.mtz
  are equivalent.

  The commands
    %(appl)s my_refl.mtz obs=F_HG,SIGF_HG data.high=2.0 log=log.log perform=True
    %(appl)s my_refl.mtz obs=HG data.high=2.0 log=log.log perform=True
  are equivalent if the substring 'HG' is unique in the mtz file. If the labels contain character such as
  '(', use quoation marks: obs='F_HG(+)'.


--------------------------------------------------------------------------------

(   t   vars(   R#   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt
   print_help  s    lt   merging_statisticsc           B   s/   e  Z d  Z d „  Z e d „  ƒ Z d „  Z RS(   sr   
  Subclass of iotbx merging statistics class to override the show() method
  and use the Xtriage output style.
  c         C   ss  | j  d ƒ | j d ƒ | j d ƒ | j d ƒ t ƒ  } |  j j d | d d ƒ | j | j ƒ  ƒ |  j j	 ƒ  j
 ƒ  j ƒ  d k } |  j j d	 k rµ | s| j d
 ƒ qn] |  j t k rÔ | j d ƒ n> |  j t k ró | j d ƒ n |  j t k r| j d ƒ n  | j d ƒ | j |  j d t ƒ| j d ƒ | j |  j d t ƒ| j d t j j ƒ d  S(   Ns   Statistics for data mergings   Overall statisticssÝ  Because unmerged intensities were supplied as input, Xtriage has calculated
statistics for merging to assess the usefulness and internal consistency of
the data (both overall and as a function of resolution).  The merged data will
be used for all subsequent steps.  Although some of the other analyses
performed later are partially redundant with these, the statistics
displayed here are the most useful for calculating the information content
and expectations for resolution.
s±   Note that completeness statistics are calculated with Friedel mates (I+ and I-)
treated as redundant observations; completeness for anomalous data may be
lower than shown here.
R   t   prefixs       i   gš™™™™™É?s¿   The overall R-merge is greater than 0.2, suggesting that the choice of space
group may be incorrect.  We suggest that you try merging in lower symmetry
to see if this improves the statistics.s¯   The correlation of half-datasets (CC1/2)in the outer resolution shell suggests
that the useful resolution range extends significantly beyond the cutoff used
in the input data.s¤   The correlation of half-datasets (CC1/2)in the outer resolution shell suggests
that the useful resolution range may extend beyond the cutoff used in the input
data.s™   The correlation of half-datasets (CC1/2)in the outer resolution shell suggests
that the useful resolution range may be lower than that of the input data.s&   Multiplicity, completeness, and signalt   plot_buttons   Dataset consistencys   References:
(   t   show_headert   show_sub_headert	   show_textR   t   overallt   show_summaryt
   show_linest   getvaluet   crystal_symmetryt   space_group_infot   typet   numbert   r_merget   warnt   cc_one_half_outert   CC_ONE_HALF_OUTER_HIGHt   CC_ONE_HALF_OUTER_MEDt   CC_ONE_HALF_OUTER_POORt
   show_tablet   signal_tablet   Truet   quality_tablet   iotbxR'   t   citations_str(   t   selfR   t   tmp_outt   is_p1(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt
   _show_implŠ  s8    	!


c         C   s   |  j  d j S(   Niÿÿÿÿ(   t   binst   cc_one_half(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR7   »  s    c         C   sµ   |  j  j d k rd |  j j ƒ  j ƒ  j ƒ  d k } | sM d d d d f g Sd d d d f g Sn  |  j t k r‡ d d	 d
 d f g S|  j t k  rª d d d d f g Sd g Sg  S(   Ngš™™™™™É?i   i   s2   The merging statistics indicate that the data may s%   be assigned to the wrong space group.s   Dataset consistencys3   The merging statistics are unusually poor, but the s<   space group is P1, suggesting problems with data processing.s3   The resolution of the data may be useful to higher s%   resolution than the given resolution.s7   The resolution of the data may be lower than the given s   resolution.i    s3   The resolution limit of the data seems appropriate.(   i    s3   The resolution limit of the data seems appropriate.s   Dataset consistency(	   R-   R5   R1   R2   R3   R4   R7   R9   R:   (   RA   RC   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   summarize_issues¿  s"    ! (   t   __name__t
   __module__t   __doc__RD   t   propertyR7   RG   (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR'   „  s   	1t   data_summaryc           B   s#   e  Z d  Z e d „ Z d „  Z RS(   sI   
  Basic info about the input data (somewhat redundant at the moment).
  c         C   sç   | j  ƒ  |  _  | j ƒ  |  _ | j ƒ  j ƒ  |  _ | j ƒ  |  _ | |  _ | j ƒ  |  _	 |  _
 | j ƒ  |  _ | j ƒ  |  _ |  _ | j ƒ  |  _ d  |  _ | j ƒ  } |  j rã | j ƒ  |  _
 | j ƒ  |  _ | j ƒ  |  _ n  d  S(   N(   t   infoR2   t   space_groupt	   unit_cellt
   parameterst   observation_typet   obs_typet
   was_mergedt   sizet	   n_indicest   n_indices_mergedt   anomalous_flagt   completenesst   completeness_mergedt	   d_max_minR    t   anomalous_completenesst   average_bijvoet_mates(   RA   t   miller_arrayRS   t   non_anom(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   __init__Ø  s    			c      	   C   s   | j  d ƒ | j d ƒ |  j r3 | j d ƒ n  t |  j d d  ƒ } t |  j d d „  ƒ } d t | ƒ f d t | ƒ  ƒ f d	 t |  j ƒ f d
 d |  j	 f d t |  j
 ƒ f d d |  j f d t |  j ƒ f g } |  j rV| j d t |  j ƒ f d d |  j d f d t |  j ƒ f d d |  j d f d d |  j d f g ƒ n3 | j d t |  j ƒ f d d |  j d f g ƒ | j | d d ƒd  S(   Ns
   Input datat   Summarysb   The original dataset contained unmerged intensities; the statistics below
are for the merged data.t   sourcet   label_stringc           S   s   d  S(   N(   R    (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   <lambda>ñ  s    s
   File name:s   Data labels:s   Space group:s
   Unit cell:s"   %.6g, %.6g, %.6g, %.6g, %.6g, %.6gs
   Data type:s   Resolution:s   %g - %gs
   Anomalous:s&   Number of reflections (non-anomalous):s   Completeness (non-anomalous):s   %.2f%%id   s   Number of reflections (all):s   Completeness (all):s   Anomalous completeness:s   Number of reflections:s   Completeness:t   indenti   (   R*   R+   RS   R,   t   getattrRM   R    t   strRN   RO   RR   RZ   RW   t   extendRV   RY   RU   RX   R[   t   show_text_columns(   RA   R   Ra   Rb   t   lines(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRD   é  s6    	
	(   RH   RI   RJ   t   FalseR_   RD   (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRL   Ô  s   t   xtriage_analysesc           B   s  e  Z d  Z e Z d d d d d d d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z e d „  ƒ Z e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z RS(   sö  
  Run all Xtriage analyses for experimental data, with optional Fcalc or
  reference datasets.

  :param miller_obs: array of observed data, should be intensity or amplitude
  :param miller_calc: array of calculated data
  :param miller_ref: array with 'reference' data, for instance a data set with
                     an alternative indexing scheme
  :param text_out: A filehandle or other object with a write method
  :parma params: An extracted PHIL parameter block, derived from master_params
  c         C   s€  | |  _  | d  k	 s t ‚ | j ƒ  r6 | j ƒ  } n  d „  } | | ƒ } | j ƒ  }	 | | ƒ } | | ƒ } t | d | d  k	 ƒ|  _ | d k r¢ t ƒ  } n  | d  k rÉ t j d g  ƒ j	 ƒ  } n  | j
 j j j sè t | ƒ n  d  |  _ | d  k	 râ| j ƒ  rây¢ t d | d | j ƒ  d | j
 j j j d | j
 j j j d	 | j
 j j j j d
 | ƒ |  _ |  j j d | ƒ | d IJ| d IJ| t j j IJ| d IJWqât k
 rÞ}
 | d IJ| d t |
 ƒ IJqâXn  t d d | ƒd } t } | j
 j j j  d  k	 s.| j
 j j j! d  k	 r\t" } | j
 j j j# d  k	 r÷| d IJq÷n› | j
 j j j# d  k	 r÷| d | j
 j j j# IJt j$ j% d | j
 j j j# d
 | ƒ } | d  k	 r÷| j  | j
 j j _  | j! | j
 j j _! t" } q÷n  t& j' d | d | j
 j j j  d | j
 j j j! ƒ } | |  _& |  j& j d | ƒ | j  | j
 j j _  | j! | j
 j j _! | j( } | j
 j j j) d  k	 rÃ| j
 j j j) } | d IJ| d I| IJn | | j
 j j _) t* j+ d | ƒ j d | ƒ |  _+ d  |  _, | j- ƒ  r8t* j. d | d |  j ƒ j d | ƒ |  _, n  t* j/ d | d | j
 j j j  d | j
 j j j! d | j
 j j j) ƒ |  _/ |  j/ j d | ƒ d  |  _0 | d  k	 rC| j1 ƒ  d k  rCy% t0 j0 d | d | ƒ j2 ƒ  |  _0 WqCt3 k
 r}
 | d IJ| t |
 ƒ IJ| d IJqCt k
 r?}
 d  GH‚  | d IJqCXn  | j4 ƒ  | j
 j j j5 } | j6 j d  k r‰|  j+ j7 ƒ  | j6 _ n  | j8 r¿|  j/ j9 } | j ƒ  } |  j/ j: j ƒ  } n  | d IJt; j< | j= ƒ  j> ƒ  ƒ | j6 j k rt; j< | j= ƒ  j> ƒ  ƒ | j
 j j _ n  | j6 j } | d  k r;d! } n  | } d | d" d# } | j6 j } | } d | d" d# } d  |  _? | j@ ƒ  } | jA ƒ  } | d$ k rt d% d | ƒtB jB d | d& | d' | d( t" d | d | d) | d* |	 ƒ |  _? |  j? j | ƒ | j4 ƒ  n6 | jC ƒ  jD ƒ  s(t ‚ | d IJ| d+ IJ| d IJ| d  k	 r|tE jF | | d | j
 j j jG ƒ|  _H n  d  S(,   Nc         S   sA   |  d  k r d  S|  j ƒ  } |  j ƒ  j ƒ  }  |  j ƒ  j | ƒ S(   N(   R    RM   t   merge_equivalentst   arrayt   remove_systematic_absencest   set_info(   R]   RM   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   process_input_array&  s
     RS   t   silentt   sourcest   i_obsR1   t   d_mint   d_maxt   n_binst   logR   R   s   References:s1   WARNING: calculation of merging statistics faileds     error: %ss   Basic statisticsg      ð?s!     warning: ignoring sequence files/     determining composition from sequence file %st	   file_namet
   n_residuest   n_basess-   Number of copies per asymmetric unit provideds"    Will use user specified value of R]   t   merging_statst   n_copies_solcg      @t
   miller_obst   miller_calcs6   *** Error calculating relative Wilson plot - skipping.s   RELATIVE WILSON ERRORg        g�íµ ÷Æ°>g       @i    s   Twinning and symmetry analysest   d_star_sq_low_limitt   d_star_sq_high_limitt	   normaliset   additional_parameterst   original_datas-   Centric space group - skipping twin analyses.(I   t   log_file_nameR    t   AssertionErrort   is_unmerged_intensity_arrayt	   deep_copyRL   R   t   master_paramst   fetcht   extractt   scalingt   inputt	   xray_datat   skip_sanity_checkst!   check_for_pathological_input_dataR{   t   is_xray_intensity_arrayR'   R1   t   high_resolutiont   low_resolutionRP   t   mergingRv   t   showR?   R@   t	   ExceptionRf   R   Rj   t   asu_contentsRy   Rz   R=   t   sequence_filet   bioinformaticst   composition_from_sequence_fileR   t   matthews_ruppt   n_copiest   n_copies_per_asuR   t   data_strength_and_completenesst   anomalous_infoRW   t	   anomaloust   wilson_scalingR   Rt   t   summaryR   t   flusht   misc_twin_parameterst   twin_test_cutst   high_resolution_for_twin_testst*   apply_basic_filters_prior_to_twin_analysist   miller_array_filteredt   normalised_millerR
   t   mint
   d_spacingst   datat   twin_resultst   select_acentricRT   R   RN   t
   is_centricR   t
   reindexingRx   t   reference_analyses(   RA   R}   R~   t
   miller_reft   paramst   text_outt   unmerged_obsR„   Rp   t   miller_originalt   eR|   t
   nres_knownt   seq_compt   matthews_resultst   twin_paramst
   new_millert   normalised_arrayt$   default_high_reso_limit_wilson_ratioR€   t#   default_low_reso_limit_wilson_ratioR   t	   acentricst   n_acentrics(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR_     s    					

				
						
	
$			


c         C   s5  |  j  j | ƒ |  j d  k	 r2 |  j j | ƒ n  t | t j j ƒ rZ t d d | ƒn  |  j	 j | ƒ |  j
 j | ƒ |  j j | ƒ |  j d  k	 r¬ |  j j | ƒ n  |  j d  k	 rÎ |  j j | ƒ n  |  j d  k	 rt | t j j ƒ rt d d | ƒn  |  j j | ƒ n  |  j ƒ  } | j | ƒ d  S(   Ns   Basic analysesR   s   Twinning and symmetry(   RL   R”   R{   R    t
   isinstancet   mmtbxR‹   t   printed_outputR   R   R�   R    R   Rž   R¬   RG   (   RA   R   R¡   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRD   Ô  s$    c         C   s
   |  j  j S(   sA   
    Convenience method for retrieving the number of copies.
    (   R   R›   (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   matthews_n_copiesè  s    c         C   s   |  j  } t | j d d ƒ S(   sM   
    Convenience method for retrieving a conservative resolution cutoff.
    t   completeness_cutN(   R�   Re   t   data_strengthR    (   RA   t   ds(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   resolution_cutî  s    	c         C   s#   |  j  d k	 r |  j  j j ƒ  St S(   sP   
    Convenience method for indicating whether the data are likely twinned.
    N(   R¬   R    t   twin_summaryt   has_twinningRj   (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt
   is_twinnedõ  s    c         C   s   t  |  j d d ƒ S(   s‡   
    Convenience method for retrieving the recommended resolution cutoff for
    anomalous substructures search.  Used in AutoSol.
    t	   low_d_cutN(   Re   Rž   R    (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt$   resolution_limit_of_anomalous_signalý  s    c         C   s   |  j  j ƒ  S(   N(   R�   t   i_over_sigma_outer_shell(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRÎ     s    c         C   s
   |  j  j S(   s0   Convenience method for isotropic Wilson B-factor(   R    t   iso_b_wilson(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRÏ     s    c         C   s
   |  j  ƒ  S(   s3   Shortcut to resolution_limit_of_anomalous_signal().(   RÍ   (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRÌ     s    c         C   s    |  j  j j } t | d d !ƒ S(   sg   
    Convenience method for retrieving the minimum anisotropic B_cart tensor.
    Used in AutoSol.
    i    i   (   R    t   aniso_scale_and_bt   b_cartR©   (   RA   RÑ   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   aniso_b_min  s    c         C   s1   |  j  j j } t | d d !ƒ t | d d !ƒ S(   si   
    Convenience method for retrieving the range of anisotropic B_cart tensors.
    Used in AutoSol.
    i    i   (   R    RÐ   RÑ   R   R©   (   RA   RÑ   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   aniso_range_of_b  s    c         C   sF   |  j  j j } t | d d !ƒ t | d d !ƒ t | d d !ƒ d S(   sŒ   
    Ratio of the maximum difference between anisotropic B_cart tensors to the
    mean of the tensors.  Used in PDB validation server.
    i    i   (   R    RÐ   RÑ   R   R©   t   sum(   RA   RÑ   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   aniso_b_ratio$  s    c         C   s   |  j  j j ƒ  S(   su   
    Number of centric and acentric outliers flagged by Wilson plot analysis.
    Used in PDB validation server.
    (   R    t   outlierst
   n_outliers(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   number_of_wilson_outliers-  s    c         C   s   |  j  j j S(   si   
    <|L|> from the L test for abnormal intensity distributions.  Used in PDB
    validation server.
    (   R¬   t   l_testt   mean_l(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   l_test_mean_l5  s    c         C   s   |  j  j j S(   si   
    <L^2> from the L test for abnormal intensity distributions.  Used in PDB
    validation server.
    (   R¬   RÙ   t   mean_l2(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   l_test_mean_l_squared=  s    c         C   s   |  j  j j ƒ  S(   sg   
    Estimated twin fraction from the most worrysome twin law.  Used by PDB
    validation server.
    (   R¬   RÉ   t   max_twin_fraction(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   max_estimated_twin_fractionG  s    c         C   s   |  j  j j ƒ  S(   sq   
    Plain-English explanation of Patterson analysis for TNCS detection.  Used
    by PDB validation server.
    (   R¬   RÉ   t   patterson_verdict(   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRà   O  s    c         K   s#   |  j  d k	 r |  j  j | �  Sd S(   sØ   
    Suggest resolution cutoffs based on selected statistics (if merging was
    included in analyses).  See
    :py:class:`iotbx.merging_statistics.dataset_statistics` for underlying
    function documentation.
    N(   R{   R    t   estimate_d_min(   RA   t   kwds(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRá   W  s    c         C   s¡   g  } |  j  d  k	 r1 | j |  j  j j ƒ  ƒ n  | j |  j j ƒ  ƒ |  j d  k	 ro | j |  j j ƒ  ƒ n  | j |  j j ƒ  ƒ |  j d  k	 r— n  t	 | ƒ S(   N(
   R¬   R    Rg   RÉ   RG   R    R{   R�   Rž   R¡   (   RA   t   issues(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRG   b  s    N(   RH   RI   RJ   R=   t
   new_formatR    R_   RD   RÄ   RÈ   RË   RÍ   RK   RÎ   RÏ   RÌ   RÒ   RÓ   RÕ   RØ   RÛ   RÝ   Rß   Rà   Rá   RG   (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRk     s4   ³								
	R¡   c           B   s,   e  Z e d  „ Z e d „  ƒ Z d „  Z RS(   c         C   s)   | |  _  | r% |  j  j d „  ƒ n  d  S(   Nc         S   s   t  | d |  d ƒ S(   Ni    (   t   cmp(   t   aR   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRc   r  s    (   t   _issuest   sort(   RA   Rã   Rè   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR_   o  s    	c         C   s   t  |  j ƒ S(   N(   R   Rç   (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt
   n_problemst  s    c         C   sÆ   | j  d ƒ t } |  j d k rŸ t | d ƒ rD | j |  j ƒ qŸ xX |  j D]J \ } } } | d k r t } | j | ƒ qN | j t	 | d d ƒƒ qN Wn  | sµ | j d ƒ n | j d ƒ d  S(	   Ns   Xtriage summaryi    t   show_issuesi   t	   max_charsiN   s±   
No obvious problems were found with this dataset.  However, we recommend that
you inspect the individual results closely, as it is difficult to automatically
detect all issues.sf   
Please inspect all individual results closely, as it is difficlut to
automatically detect all issues.(
   R*   Rj   Ré   t   hasattrRê   Rç   R=   R6   R”   R   (   RA   R   t   have_problemst   severityt   messaget   linkto(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRD   x  s     
(   RH   RI   R=   R_   RK   Ré   RD   (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR¡   n  s   c         C   s'  |  j  ƒ  } | j ƒ  } | d k rb |  j ƒ  j ƒ  rb t d d d d t |  j ƒ  ƒ ƒ ‚ n# | t k  r… t d d | ƒ ‚ n  |  j ƒ  } | d k  r¸ t d	 d
 | d ƒ ‚ n  |  j	 ƒ  \ } } | d | d k s| d | d k s| d | d k r#t d d | | f ƒ ‚ n  d  S(   Ni    s8   No acentric reflections present in the data.  Since the s<   space group %s is not centric, this is probably an error in s?   the input file.  Please check your data processing and/or file s   conversion.s8   Only %d acentric reflections are present in these data; s.   this usually indicates a corrupted input file.gš™™™™™¹?s5   Data are unusually incomplete (%.1f%%); this usually s;   indicates a corrupted input file or data processing errors.id   i   i   s5   These data appear to be limited to a single plane of s2   reciprocal space (max/min Miller indices: %s, %s).(
   R­   RT   RN   R®   R   Rf   R2   t   MIN_ACENTRICSRX   t   min_max_indices(   R]   R¿   RÀ   t   cmplt   min_mit   max_mi(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR�   �  s&    (s   phenix.xtriagec   0      C   s*  | d  k r t j } n  t ƒ  } | j d d d | ƒ t ƒ  } t ƒ  } | j d d d | ƒ t j j d |  d t	 d d d	 d
 d d d d d d d d ƒ } | j
 }	 |	 j ƒ  }
 |
 j j j j d  k rÚ t d ƒ ‚ n  |
 j j j j } |
 j j j j j } |
 j j j } |
 j j j j d  k rS| d IJ| d IJ| d IJ| d IJn  |
 j j j j d  k rzt d ƒ ‚ n  t j d |
 j j j j ƒ } | d  k	 r¿| j ƒ  } | j ƒ  } n$ |
 j j j j } |
 j j j j } d  | | | g k r�| d IJ| j j d  k	 r9| d IJt j d | j j ƒ } n  | d  k r�|
 j j j j j j d  k	 r�t j d |
 j j j j j j ƒ } q�n  | d  k rê|
 j j j j d  k rÀt d ƒ ‚ n  |
 j j j j d  k rbt d ƒ ‚ qbnx | j ƒ  d  k r&|
 j j j j d  k r&t d ƒ ‚ q&n  | j ƒ  d  k rb|
 j j j j d  k rbt d ƒ ‚ qbn  |
 j j j j d  k r•| j ƒ  |
 j j j _ n  |
 j j j j d  k rÈ| j ƒ  |
 j j j _ n  t	 j d |
 ƒ } |
 j j j j j d  k r=| J| J| d! IJ| d" IJ| j d# | d$ |
 j j j  ƒ | d% IJn  t! j" d& |
 j j j j d' t# |
 j j j j ƒ ƒ } | j ƒ  j$ ƒ  r©t% j& d( d) t# | j ƒ  ƒ ƒ n  t' j( d* | d+ t) d, g  ƒ } d  } } | j* d |
 j j j j d- |
 j j j j+ d. t) d/ d0 d1 d2 ƒ } | j, ƒ  } | j- rõ| j. ƒ  rõt/ j0 d |
 j j j j ƒ } | j1 ƒ  d  k	 sjt2 ‚ | j3 d* | d3 t4 ƒ } xp | D]e } | j, ƒ  j5 | j5 k r‰| j6 ƒ  rî| } | d4 IJ| d5 | j, ƒ  j7 ƒ  IJ| d4 IJPqîq‰q‰Wn  | j8 ƒ  s5t9 | ƒ } d6 d7 l: m; } | j< | j= ƒ  ƒ } n  | j> ƒ  } | j? ƒ  d  k rbt d8 ƒ ‚ n  | j@ | jA ƒ  d\ k ƒ } | jB ƒ  r˜t9 | ƒ } n  |
 j j j jC d  k	 rÑ| jD d9 |
 j j j jC ƒ } n  |
 j j j jE d  k	 r
| jD d: |
 j j j jE ƒ } n  | jF ƒ  sL| jG d; | jA ƒ  d< | j ƒ  d= d  ƒ j< | ƒ } n  | jH d> t) d? | ƒ } d  } d  } d  } |
 j j j j } |
 j j j jI d  k	 rº| jJ d |
 j j j j d- |
 j j j jI d@ t4 d/ d0 d1 dA ƒ } | j8 ƒ  s| jG d< tK j9 | j ƒ  ƒ ƒ j< | ƒ } n  | j. ƒ  rP| dB |
 j j j jI IJ| jL ƒ  } n  | jH d> t) d? | ƒ } | jM ƒ  r’| jM ƒ  s­| jN ƒ  } q­n | jM ƒ  r­| jO ƒ  } n  | jP ƒ  n	| j j d  k	 rÃ	tQ jR jS | j j ƒ sót dC ƒ ‚ n  | d  k s	t2 ‚ t jT j d | j j dD t) ƒ } | jU ƒ  jV ƒ  | jW d* | jX ƒ  ƒ } | } | jY ƒ  su	| jZ ƒ  j[ ƒ  } n  t\ j] j^ dE | dF | ƒ } | j_ } t9 | j_ ƒ jH d> t) d? | ƒ jP ƒ  } n  d  }  d  }! |
 j j j j j j d  k	 rd  }" d  }# |
 j j j j j j d  k	 r2
|
 j j j j j j }" n  |
 j j j j j j d  k	 rk
|
 j j j j j j }# n  d  }$ |" d  k	 rª
|# d  k	 rª
t! j" d& |" dG |# j` ƒ  ƒ }$ n  |$ d  k rÝ
t j d |
 j j j j j j ƒ }$ n  |$ d  k r| dH IJt dI ƒ ‚ n  t' j( d* |$ d+ t) d, g  ƒ } d  }! | j* d |
 j j j j j j d- |
 j j j j j j5 d. t) d/ dJ d1 d- ƒ }! |! j, ƒ  } |! j> ƒ  }! |! j@ |! jA ƒ  d] k ƒ }! |! j@ |! j ƒ  d  k ƒ }! |! j. ƒ  rÝ|! jL ƒ  }! n |! jB ƒ  røt9 |! ƒ }! n  |! jH d> t) d? | ƒ }! n  | ja ƒ  }% d  }& | j8 ƒ  s7t2 ‚ | J| J| dK IJ| J| jb dL | ƒ | jc dM | ƒ t) }' t) }( t4 }) |
 j j j j j j d  k	 r¦t) }) n  td dN | dO | dP |! dQ |
 dR | dS | dT |
 j j j j je ƒ }& |
 j j j j je d  k	 r7tf |
 j j j j je dU ƒ }* |* jg | jh ƒ  ƒ n  |
 j j ji jj d  k	 r½d6 dV lk ml }+ |+ jm dW |% dX |
 j j ji d# | ƒ }, |
 j j ji }- |, jn d |- jj dY |- jo dZ |- jp ƒ n  | d  k	 rìd6 d[ l% mq }. |. jr | |% ƒ n  |
 j j j j js r&t\ j jt |* ƒ }/ |& j d# |/ ƒ n  |& S(^   Nt   labelR"   t   file_objectt
   log_buffert   argst   master_philt   pdb_file_defs5   scaling.input.xray_data.reference.structure.file_namet   seq_file_defs(   scaling.input.asu_contents.sequence_filet   reflection_file_defs!   scaling.input.xray_data.file_namet   unit_cell_defs!   scaling.input.xray_data.unit_cellt   space_group_defs#   scaling.input.xray_data.space_groupt   usage_strings9   phenix.xtriage [options] reflection_file parameters [...]s   No reflection file in input.s/   ##-------------------------------------------##s/   ## WARNING:                                  ##s/   ## Number of residues unspecified            ##s   No reflection file definedRx   s5   Cell and/or symmetry not specified in reflection files   Using reference PDB filesY   No space group info available.
Use keyword 'xray_data.space_group' to specify space groupsg   
No unit cell info available.
Use keyword 'xray_data.unit_cell' to specify unit_cell
                  sU   No unit cell info available.
  Use keyword 'xray_data.unit_cell' to specify unit_cells[   No space group info available.
  Use keyword 'xray_data.space_group' to specify space_groupt   python_objecti    s   Effective parameters: s   #phil __ON__R   t   expert_levels   #phil __END__RO   t   space_group_symbols9   The specificed space group (%s) is centric; Xtriage will s-   still run, but many analyses will be skipped.R1   t   force_symmetryt   reflection_filest   labelst   ignore_all_zerost   parameter_scopes   scaling.input.xray_datat   parameter_namet
   obs_labelsRl   R   s    Also reading unmerged data as %siÿÿÿÿ(   t   observation_typessC   Observation type of data unkown. Please check input reflection fileRu   Rt   t   indicesR«   t   sigmast   integral_onlyRw   t"   convert_to_amplitudes_if_necessaryt   calc_labelss   Converting %s to amplitudess2   Can't open reference structure - not a valid file.t   raise_sorry_if_format_errort   xray_structuret   f_obsRN   s7   No reference unit cell and space group could be deduceds;   Please provide unit cell and space group for reference datas&   scaling.input.xray_data.reference.datas2   Symmetry, cell and reflection file content summaryRM   t   fR}   R~   R±   R²   R³   R´   R„   t   w(   t   massage_twin_detwin_dataR]   RP   t   output_typet   label_extension(   t   easy_pickle(   i    i    i    (   i    i    i    (u   R    R!   R"   R   t   registerR   R?   t   philt   process_command_line_with_filesRˆ   t   workRŠ   R‹   RŒ   R�   Rx   R   t	   referenceRP   t	   reportingt   verboseR–   Ry   R   t   extract_fromR2   RO   RN   t	   structureR«   t   formatR”   R  R   t   symmetryRf   R®   t   libtbxR6   R   t   reflection_file_serverR=   t   get_xray_dataR
  RM   t   mergedR�   R   t   any_reflection_filet	   file_typeR…   t   as_miller_arraysRj   R  R†   Rb   t   is_real_arrayt   abst
   cctbx.xrayR  t   set_observation_typet	   amplitudet
   map_to_asuRQ   t   selectR  t   is_complex_arrayR’   t   resolution_filterR‘   t   sigmas_are_sensiblet   customized_copyt   eliminate_sys_absentR  t   get_amplitudesR
   t	   f_sq_as_fRW   t   generate_bijvoet_matesR\   t#   set_observation_type_xray_amplitudet   ost   patht   isfileR	   t   atomst(   set_chemical_element_simple_if_necessaryt   xray_structure_simpleR1   t   is_unique_set_under_symmetryRl   Rm   RÂ   t   utilst   fmodel_from_xray_structuret   f_modelt   groupR‡   Ro   t   show_comprehensive_summaryRk   Rw   t   opent   writeR0   t   optionalt   hkloutt   mmtbx.scalingR  t   massage_datat
   write_datat   hklout_typeR  R  t   dumpt	   loggraphst   loggraph_output(0   Rù   t   command_namet   return_resultR   t   data_file_nameRw   t   string_buffert   string_buffer_plotst   cmdlinet   effective_paramsR²   t   reference_paramsR   t   scopeR1   RN   RO   t
   new_paramst   xray_data_serverR]   t   unmerged_arrayRM   t
   hkl_in_rawt
   raw_arraysRm   R  t   f_calc_millert   f_calc_miller_complext   reference_structuret   pdb_int
   miller_tmpt   tmp_objR¬   t   reference_arrayt	   user_cellt
   user_groupt   reference_symmetryt   raw_datat   xtriage_resultst   minimal_passt	   twin_passt   reference_passt   output_fileR  t   massaged_obst   params2R  t	   graph_out(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   run¥  s   					


	

		!

				
					

														
					
						c         C   s•   |  j  d | d | ƒ }  | d k	 r‘ d } |  j ƒ  r? d } n |  j ƒ  rT d } n  | d k ro t d ƒ ‚ n  |  j d | ƒ j ƒ  j | ƒ n  |  S(   sz   
  Encapsulates all operations required to convert the original data to a
  different symmetry as suggested by Xtriage.
  R  Rw   t   Ft   Is)   Only amplitudes and intensites supported.t   column_root_labelN(   t   change_symmetryR    t   is_xray_amplitude_arrayR�   t   RuntimeErrort   as_mtz_datasett
   mtz_objectRI  (   R]   R  Rx   Rw   Rw  (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRx  è  s    					t   launcherc           B   s   e  Z d  „  Z RS(   c         C   s<   t  j |  j ƒ t  j |  j ƒ t d t |  j ƒ d d ƒ S(   NRù   RU  s   xtriage_data.pkl(   R<  t   mkdirt
   output_dirt   chdirRt  t   listRù   (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRt  þ  s    (   RH   RI   Rt  (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR}  ý  s   c         C   s¥   g  } g  } |  d  k	 r› |  j d  k	 r@ | j |  j d f ƒ n  |  j d  k	 rl | j d d |  j f ƒ n  |  j d  k	 r› | j d d |  j f ƒ q› n  | | f S(   Ns   Log file and graphss    Limit of useful anomalous signals   %.2fs   Wilson B(   R    R„   t   appendRÌ   RÏ   (   t   resultt   output_filest   stats(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt
   finish_job  s    	 c         C   sš  |  j  j j j d  k r' t d ƒ ‚ n  |  j  j j j d  k rN t d ƒ ‚ n? |  j  j j j |  j  j j j k r� t d d d d ƒ ‚ n  |  j  j j j } |  j  j j j	 } | d  k	 rõ | d  k	 rõ | | k rõ t d d | | f ƒ ‚ qõ n  |  j  j j j
 d  k s%|  j  j j j d  k r4t d	 ƒ ‚ n  |  j  j j j
 j ƒ  } |  j  j j j } | j | ƒ s„t d
 d d ƒ ‚ n  |  j  j j j j j } | d  k	 rÒt j j | ƒ rÒt d d | ƒ ‚ n  |  j  j j j d  k	 r0|  j  j j j d  k	 s|  j  j j j d  k	 r0t d d ƒ ‚ q0n  |  j  j j d  k rTt d ƒ ‚ n  |  j  j j j j } | j d  k	 r–| j d k r–t d ƒ ‚ n  t S(   Ns(   You must supply a reflection file first!s$   Please select labels for input data.s6   You may not select the same array labels for both the sC   experimental data and F(calc).  (It is okay to run Xtriage without sC   F(calc) data if it is not available - most analyses do not require s   this information.)s7   The specified high-resolution cutoff (%.3f) is greater s&   than the low-resolution cutoff (%.3f)!s+   Missing or incomplete symmetry information.s1   Unit cell parameters are not consistent with the s?   currently set space group.  Please make sure that the symmetry s!   information is entered correctly.s;   A path was defined for the reference PDB file (%s), but it s4   could not be recognized as a file or does not exist.s9   Please leave the number of residues and bases blank when s   providing a sequence file.s#   Please specify an output directory.g      à?s5   The twin fraction (if defined) must be less than 0.5.(   R‹   RŒ   R�   Rx   R    R   R
  R  R‘   R’   RN   RO   RF  t   is_compatible_unit_cellR  R"  R<  R=  R>  R–   R—   Ry   Rz   t   guiR  RJ  R$  t   twinning_parameterst   fractionR=   (   R²   t   callbackRt   Ru   RN   RO   t   ref_structureRº   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   validate_params  sN    t   xtriage_summaryc           B   sJ   e  Z d  Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   s€   
  Old result class, minus initialization.  Provides backwards compatibility
  with pickle files from Phenix 1.9 and earlier.
  c         C   s'   t  |  d ƒ r |  j |  j f Sd Sd  S(   Nt   rel_wilson_caption(   NN(   Rì   R�  t   rel_wilson_plotR    (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   get_relative_wilsonE  s    c         C   s   t  |  d d  ƒ S(   NR{   (   Re   R    (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   get_merging_statisticsK  s    c         C   s   t  |  d d  ƒ S(   Nt	   data_file(   Re   R    (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   get_data_fileN  s    c         C   s   t  |  d d  ƒ S(   Nt   original_is_intensity_array(   Re   R    (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   original_intensities_flagQ  s    c         C   s.   t  |  d d  ƒ } t  |  d d  ƒ } | | f S(   Nt   completeness_overallt   completeness_binned(   Re   R    (   RA   R-   t   binned(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   get_completenessT  s    c         C   s   t  |  d d  ƒ S(   Nt   centric_flag(   Re   R    (   RA   (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyR®   Y  s    (   RH   RI   RJ   Rj   Rä   R‘  R’  R”  R–  Rš  R®   (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyRŽ  ?  s   					(B   RJ   t
   __future__R    RL  R   R   R   R   R   RÂ   t   mmtbx.utilsR?   R   R   R   t   iotbx.merging_statisticst   iotbx.bioinformaticsR	   t
   iotbx.philt   cctbx.array_familyR
   t   cctbxR   t   libtbx.utilsR   R   t   libtbx.str_utilsR   R   R   R   R%  R   t   libtbx.callbackst	   cStringIOR<  R!   Rñ   R:   R9   R8   R  t   parseR=   Rˆ   R    R$   R&   R‹   t   xtriage_analysisR'   t   dataset_statisticsRL   Rk   R¡   R�   Rj   Rt  R"   Rx  t   target_with_save_resultR}  R†  R�  t   objectRŽ  (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/xtriage.pyt   <module>   sb   	Ý	nO8ÿ c!	ÿ C	.