ó
ąxTc           @   s  d  d l  m Z d  d l m Z d  d l m Z 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 Z d   Z d	 Z e j d
 e e d  Z d e j f d     YZ d e f d     YZ e d k r e e j d  n  d S(   i˙˙˙˙(   t   division(   t   program_result(   t   Sorryt	   multi_out(   t   runtime_utils(   t   easy_pickle(   t   AutoNc          C   s;   d d l  m }  |  d t d t d t d t d t d d	  S(
   Ni˙˙˙˙(   t    generate_master_phil_with_inputst   enable_automatic_twin_detectiont    enable_pdb_interpretation_paramst   enable_stop_for_unknownst   enable_unmerged_datat
   enable_cdlt   phil_stringsy  
molprobity {
  outliers_only = True
    .type = bool
  keep_hydrogens = Auto
    .type = bool
    .help = Keep hydrogens in input file (instead of re-generating them with       Reduce).  If set to Auto, the behavior will depend on whether the       neutron scattering table is used (regardless of whether we actually       have experimental data).
  nuclear = False
    .type = bool
    .short_caption = "Use nuclear hydrogen positions"
  min_cc_two_fofc = 0.8
    .type = float
  n_bins = 10
    .type = int
    .short_caption = Number of resolution bins
  use_pdb_header_resolution_cutoffs = False
    .type = bool
    .short_caption = Use resolution cutoffs in PDB header
  count_anomalous_pairs_separately = False
    .type = bool
    .expert_level = 2
  rotamer_library = *500 8000
    .type = choice
    .help = Library of rotamer probabilities (Top500 or Top8000)
    .expert_level = 2
  flags
    .expert_level = 3
  {
    include scope mmtbx.validation.molprobity.master_phil_str
  }
  ligand_selection = None
    .type = atom_selection
    .expert_level = 3
}
output {
  quiet = False
    .type = bool
  probe_dots = True
    .type = bool
    .short_caption = Save Probe dots for Coot
  kinemage = False
    .type = bool
    .short_caption = Save Kinemage file for KiNG
  percentiles = False
    .type = bool
    .help = Show percentile rankings for summary statistics
  coot = True
    .type = bool
    .help = Write Coot script
  maps = Auto
    .type = bool
    .short_caption = Save map coefficients
    .help = Write map coefficients (if experimental data supplied)
  map_options
    .short_caption = Advanced options for map coefficients
  {
    fill_missing_f_obs = True
      .type = bool
    exclude_free_r_reflections = False
      .type = bool
  }
  prefix = None
    .type = str
    .style = hidden
  pickle = False
    .type = bool
    .style = hidden
  wxplots = False
    .type = bool
    .help = Display plots in wxPython
    .style = hidden
  gui_dir = None
    .type = path
    .short_caption = Output directory
    .help = Output directory (Phenix GUI only).
    .style = output_dir
  include scope libtbx.phil.interface.tracking_params
}
(   t   mmtbx.command_lineR   t   Truet   FalseR   (   R   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyt   get_master_phil   s    Rs   phenix.molprobity model.pdb [data.mtz] [options ...]

Run comprehensive MolProbity validation plus R-factor calculation (if data
supplied).
s   phenix.molprobityc      +   C   sř  t  j j d d d t j j  } | d  k r@ t d d   n< t  j j d  sf t  j j d  r| | r| t d   n  d	 d  l	 } d	 d  l
 } | j j d
 |  d t   d t d t d t d t d t d |  } | j } | j }	 | j j t k r|	 d  k	 rt | j _ n- | j j t k rB|	 d  k rBt d   n  | j j t k ro| j j d k | j _ n  | j j j d | j j j d d | j  }
 t j j  t j j! | j j j d   d } | j j" d  k ríd | j _" n  d  } | j j# s| j j$ r| j j" d } n  | j% } | j j j d | j d | j& d |	 d | j j' d | j( d | j) d | j% d | j* d  | j+ j, d! |
 d" | j j d# | j j- d$ | d% | j j. d& | j j/ d' | j j0 d( | j j1 d) | j j2 d* | j j j d d+ | j j3 d, | j j4  } d  } | j j5 st6   } | j7 d- |  t8 | j j" d. d/  } | j7 d0 |  | j9 d | d' | j j0 d1 | j j:  | j;   | d2 IJ| d3 | j j" IJ| j j$ r | j j<   d4 k r| d  k	 sďt=  d	 d  l> } d5 | j j" } | j$ j j? d6 | d | j d7 | j) d8 | d" | j j d9 |  } t8 | d/  } | j@ |  | j;   | j j5 s| d: | IJqq | d; IJn  | j jA rětB jC d< | j j" |  | j j5 sě| d= | j j" IJqěn  | j jD r5d> | j j" } | jE |  | j j5 s5| d? | IJq5n  | j j t k r:d	 d  lF } d	 d  lG } d@ | j j" } | j jH jI d |	 dA | j jJ jK dB | j jJ jL  \ } } d  } |	 jM   jN   rŰ| j jH jO |	  } n  | jP jQ d* | dC | dD | dE |  | dF | IJq:n& | d2 IJ| jR d | d1 | j j:  | j jS rĄy d	 d  lT } Wn t k
 rw} t dG   qĄX| jU jV d  } | jW   | jX   n  | rą| | f StY dH dI dJ | j jZ dK t j[   dL | dM | dN | j j j d g  S(O   Nt   relative_paths   chem_data/rotarama_datat   tests6   Rotamer and Ramachandran distributions not available; s&   you will need these to run MolProbity.t   reducet   probes#   Reduce and/or Probe not configured.i˙˙˙˙t   argst   master_philt   require_datat   create_fmodelt   process_pdb_filet   usage_stringt   prefer_anomaloust   outs&   Map output requires experimental data.t   neutront   pdb_filei    t   pdb_hierarchyt
   molprobitys
   _probe.txtt   xray_structuret   fmodelt   flagst   crystal_symmetryt   geometry_restraints_managert   raw_datat   unmerged_datat   all_chain_proxiest   header_infot   keep_hydrogenst   nucleart   save_probe_unformatted_filet   min_cc_two_fofct   n_bins_datat   outliers_onlyt!   use_pdb_header_resolution_cutoffst    count_anomalous_pairs_separatelyt	   file_namet   ligand_selectiont   rotamer_libraryt   stdouts   .outt   wt   txt_outt   show_percentilest    s   Results written to %s.outi   s   %s.kint   resultt   geometryt
   probe_filet   pdbIDs   Wrote kinemage to %ss2   Kinemage output not available for multiple MODELs.s   %s.pkls   Saved result to %s.pkls
   %s_coot.pys   Wrote script for Coot: %ss   %s_maps.mtzt   fill_missing_f_obst   exclude_free_r_reflectionst
   fwt_coeffst   delfwt_coeffst   anom_coeffss   Wrote map coefficients to %ss   wxPython not available.t   program_names   phenix.molprobityt	   job_titlet	   directoryt   map_filet   other_resultt   other_files(\   t   libtbxt   envt   find_in_repositoriest   ost   patht   isdirt   Nonet   ImportErrort
   has_modulet   mmtbx.validation.molprobityR   t   command_linet   load_model_and_dataR   R   R   R   t   paramsR#   t   outputt   mapsR   R   R!   R+   t   inputt   scattering_tablet
   validationt   pdb_header_infot   pdbR3   R    t   splitextt   basenamet   prefixt
   probe_dotst   kinemageR'   R"   R$   R%   R<   t   unmerged_i_obst   processed_pdb_fileR)   R,   R.   t   n_binsR0   R1   R2   R4   R5   t   quietR   t   registert   opent   showt   percentilest   closet   models_sizet   AssertionErrort   mmtbx.kinemage.validationt$   export_molprobity_result_as_kinemaget   writet   pickleR   t   dumpt   coott   write_coot_scriptt   mmtbx.maps.utilst   iotbx.map_toolst   utilst   get_maps_from_fmodelt   map_optionsR?   R@   t   f_obst   anomalous_flagt   get_anomalous_mapt	   map_toolst   write_map_coeffst   show_summaryt   wxplotst	   wxtbx.appt   appt   CCTBXAppt   display_wx_plotst   MainLoopR;   RE   t   getcwd(   R   R   RD   t   ignore_missing_modulest   return_input_objectst   rotarama_dirt   mmtbxt   cmdlineRV   R#   R*   t
   pdb_prefixR=   R'   R[   RG   t   out2t   ft   kin_filet   kin_outt	   coot_filet   iotbxt   two_fofc_mapt   fofc_mapt   anom_mapt   wxtbxt   eR   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyt   runp   s   												

			



t   launcherc           B   s   e  Z d    Z RS(   c         C   s9   t  j |  j  t  j |  j  t d |  j d t j  S(   NR   R   (   RM   t   mkdirt
   output_dirt   chdirR   R   t   sysR6   (   t   self(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyR     s    (   t   __name__t
   __module__R   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyR     s   R;   c           B   s5   e  Z d  Z e d    Z e d    Z d   Z RS(   s$   
  Wrapper object for Phenix GUI.
  c         C   s   |  j  S(   N(   RH   (   R   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyR[     s    c         C   s   |  j  d S(   Ni    (   RI   (   R   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyR     s    c         C   s   |  j  j   S(   N(   R[   t   get_statistics_for_phenix_gui(   R   (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyt   get_final_stats  s    (   R   R    t   __doc__t   propertyR[   R   R˘   (    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyR;     s   t   __main__i   (   t
   __future__R    t   libtbx.program_utils.resultR   t   libtbx.utilsR   R   RJ   R   R   R   t   libtbx.load_envt   os.pathRM   R   R   R   R6   R   R   t   target_with_save_resultR   R;   R   t   argv(    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/molprobity.pyt   <module>   s$   	`