ó
±™xTc           @   sÁ   d  d l  m Z d  d l 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 Z d  d l m Z e	 j j d ƒ Z d d „ Z e d k r½ e d	 e j d
 ƒ n  d S(   iÿÿÿÿ(   t   divisionN(   t   print_statistics(   t   Sorry(   t   reflection_file_utilssª  
  pdb_file = None
    .type = path
  map_coefficients_file = None
    .type = path
  label = None
    .type = str
  ccp4_map_file = None
    .type = str
  selection = all
    .type = str
  selection_radius = 3.0
    .type = float
  box_cushion = 3.0
    .type = float
  resolution_factor = 1./4
    .type = float
  output_format = *xplor *mtz *ccp4
    .type=choice(multi=True)
  output_file_name_prefix=None
    .type = str
c         C   s�  d } | d  k r t j } n  t j | d | ƒd | } t |  ƒ d k rf | GHt j d d ƒ d  St j	 j
 d |  d t ƒ } | j j ƒ  } t | j ƒ d	 k r´ t d
 ƒ ‚ n  t j d d | ƒt j j d | j d ƒ } | j ƒ  } | j ƒ  } | j ƒ  d  }	 | j d  k ršt | j ƒ d	 k r>t d ƒ ‚ n  t j d | j d d | j d d d | ƒ }	 |	 j d | j ƒ }
 |
 j ƒ  |
 j ƒ  } n5 t j d d | ƒ| j } | j d d ƒ | j  } | j! d | j" ƒ } | j d | ƒ t j d d | ƒ| d | j# IJ| j$ ƒ  j# d | j# ƒ } | d | j% t& ƒ | j' ƒ  f IJt j d d | ƒ| j( ƒ  } | j) | ƒ } | j* d | j+ d | ƒ } t j	 j, d | d | d | j- ƒ  d  | j. d | ƒ } t/ j0 j1 | j d ƒ d!  } | j2 d  k rd" | } n d# | j2 } | j3 d | ƒ d$ | j4 k r„| j2 d  k rVd% | } n d& | j2 } | d' | IJ| j5 d | ƒ n  d( | j4 k rÝ| j2 d  k r¯d) | } n d* | j2 } | d+ | IJ| j6 d | ƒ n  d, | j4 k r‡| j2 d  k rd- | } n d. | j2 } | d/ | IJ|	 d  k	 r>|	 j7 ƒ  } n' t j	 j8 d | j9 d0 | j: j; ƒ  ƒ } | j< d1 | d | j d | ƒ n  | Jd  S(2   NsD   phenix.map_box: extract box with model and map around selected atomst   outsm   
%s.

Usage:
  phenix.map_box model.pdb map_coefficients.mtz selection="chain A and resseq 1:10"

Parameters:i    t   prefixs     t   argst   master_paramsi   s   PDB file is needed.s	   pdb modelt	   file_names'   Map or map coefficients file is needed.t   labelt   typet   complext   logt   resolution_factors   CCP4 mapt   crystal_symmetryt   fs   atom selections    Selection string: selection='%s't   strings'     selects %d atoms from total %d atoms.s=   extracting box around selected atoms and writing output filest   radiust	   selectiont   xray_structuret   pdb_hierarchyt   map_datat   box_cushioniüÿÿÿs
   %s_box.pdbs   %s.pdbt   ccp4s   %s_box.ccp4s   %s.ccp4s(   writing map to CCP4 formatted file:   %st   xplors   %s_box.xplors   %s.xplors(   writing map to X-plor formatted file: %st   mtzs
   %s_box.mtzs   %s.mtzs(   writing map coefficients to MTZ file: %st	   unit_cellt   d_min(=   t   Nonet   syst   stdoutR   t   make_headert   lent   master_philt   showt   mmtbxt   utilst   process_command_line_argst   paramst   extractt   pdb_file_namesR   t   make_sub_headert   iotbxt   pdbt   inputt   construct_hierarchyt   atomst   reset_i_seqt   ccp4_mapt   reflection_file_namesR   t   extract_miller_array_from_fileR	   t   fft_mapR   t   apply_sigma_scalingt   real_map_unpaddedt   show_summaryt   datat   extract_xray_structureR   R   t   atom_selection_cachet   countt   Truet   sizet
   sites_cartt   selectt   selection_withint   selection_radiust    extract_box_around_model_and_mapt	   as_doubleR   t   ost   patht   basenamet   output_file_name_prefixt   write_pdb_filet   output_formatt   write_ccp4_mapt   write_xplor_mapR   t   d_min_from_mapt   map_boxt   xray_structure_boxR   t   map_coefficients(   R   R   t   ht   default_messaget   inputsR&   t   pdb_inpR   t	   pdb_atomst	   map_coeffR3   R   R0   R   R   t   sites_cart_allR=   t   boxt   output_prefixR   R   (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/map_box.pyt   run#   s¬     
	
			
								 t   __main__R   i   (   t
   __future__R    t   mmtbx.utilsR#   t   mmtbx.refinementR   t	   iotbx.pdbR*   t   libtbx.philt   libtbxt   libtbx.utilsR   RC   R   R   t   philt   parseR!   R   RX   t   __name__t   argv(    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/map_box.pyt   <module>   s   		f