ó
±™xTc           @   sÈ   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
 d  d l	 m Z d  d l m Z d Z d Z d	 „  Z e j d
 „ Z e d k rÄ e e j d ƒ n  d S(   iÿÿÿÿ(   t   divisionN(   t   Sorry(   t   reflection_file_reader(   t   combine_unique_pdb_files(   t   flexsÚ  
phenix.map_value_at_point: tool to compute map value at a given point using
eight-point interpolation.

Inputs:
  - MTZ file containing Fourier map coefficients;
  - label selecting which map coefficients should be used (in case there are
    multiple choices in input file, there is no need to provide label otherwise);
  - the coordinates of points at which the map value will be computed can be
    defined in two ways: either providing a triplet of xyz coordinates using
    'point' keyword, or giving a PDB file in the command line in which case the
    atomic coordinates will serve as points;
  - optionally the 'resolution_factor' can be specified. It defines the map
    calculation grid step as grid_step=resolution_factor*d_min
  - optionally, type of map scaling can be defined: sigma or volume scaled
    (sigma is the default).

Usage examples:
  1. phenix.map_value_at_point map_coeffs.mtz point="0.5 1.2 3" point="0.53 3.3 2.5" label="2mFo-DFc"
  2. phenix.map_value_at_point map_coeffs.mtz model.pdb
  3. phenix.map_value_at_point map_coeffs.mtz model.pdb point="1 2 3" resolution_factor=0.3

  IMPORTANT: point must be a triplet of Cartesian coordinates (not fractional)!

Output:
  list of map values at specified points.
s¬   label = None
  .type = str
point = None
  .type = floats(3)
  .multiple = True
resolution_factor = 0.25
  .type = float
scale = *sigma volume
  .type = choice(multi=False)
c         C   s:   |  d IJt  j j t ƒ } | j d d d |  ƒ |  J| S(   Ns   Default params::
t   prefixs     t   out(   t   iotbxt   philt   parset   master_params_strt   show(   t   logt   parsed(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/map_value_at_point.pyt   defaults6   s
    
c         C   s¼  t  |  ƒ d k r- | t IJt d | ƒ d  St d | ƒ } t j j d |  d t j d | ƒ } | j j	 ƒ  } | j
 } d  } t  | j ƒ d k rå t d | j ƒ } | j ƒ  t j j d d  d t j | j ƒ ƒ } | j ƒ  } n  t  | ƒ d k rt d	 ƒ ‚ n  t  | ƒ d k r't d
 ƒ ‚ n  | j }	 |	 d  k rKt d ƒ ‚ n  | d j ƒ  }
 t j d |
 ƒ j ƒ  } t  | ƒ d k r¡| j d  k r¡| d } ný t  | ƒ d k rÑ| j d  k rÑt d ƒ ‚ nÍ t  | ƒ d k r=| j d  k	 r=| d } | j ƒ  j d j ƒ  | j j ƒ  k ržt d | j ƒ ‚ qžna t  | ƒ d k rž| j d  k	 ržx= | D]2 } | j ƒ  j d j ƒ  | j j ƒ  k rePqeqeWn  | j  ƒ  s¹t d ƒ ‚ n  d GH| j! d d ƒ Ht  | j" ƒ d k rÿ| d  k rÿt d ƒ ‚ n³| j# d | j$ ƒ } | j% d k r5| j& ƒ  d GHn | j' ƒ  d GH| j( ƒ  } d GHx» | j" D]° } | j) ƒ  j* | ƒ } d j+ g  | D] } t, d | ƒ j- ƒ  ^ q‡ƒ } d j+ g  | D] } t, d | ƒ j- ƒ  ^ q¹ƒ } t, d | j. | ƒ ƒ j- ƒ  } d | | | f GHq_W| d  k	 r²x� | D]… } | j) ƒ  j* | j/ ƒ } d j+ g  | j/ D] } t, d | ƒ ^ qTƒ } t, d | j. | ƒ ƒ j- ƒ  } | j0 ƒ  Gd | | f GHq&Wn  Hd GHd  S(   Ni    R   t   argst   master_paramsi   t
   file_namest   source_infot   liness   No reflection file found.s$   More than one reflection file found.s   No crystal symmetry found.t	   file_namesO   Multiple data columns found in input file. Use label keyword to select the one.sB   Specified label 'label=%s' does not match any label in input file.s*   Data must be complex type (real provided).s1   Input reflection data (Fourier map coefficients):R   s     s(   No points given to compute map value at.t   resolution_factort   sigmas   Using sigma scaled map.
s   Using volume scale map.
s   Map values at specified points:t   ,s   %10.3fs6     Input point: (%s) Fractionalized: (%s) Map value: %ss   %8.3fs   Point: %s Map value: %ss	   All done.(1   t   lent   legendR   t   mmtbxt   utilst   process_command_line_argst   syst   stdoutt   paramst   extractt   reflection_filest   Nonet   pdb_file_namesR   t   report_non_uniqueR   t   pdbt   inputR   t
   std_stringt   raw_recordst   atoms_with_labelsR   t   crystal_symmetryR   R   t   any_reflection_filet   as_miller_arrayst   labelt   infot   labelst   lowert   is_complex_arrayt   show_comprehensive_summaryt   pointt   fft_mapR   t   scalet   apply_sigma_scalingt   apply_volume_scalingt   real_map_unpaddedt	   unit_cellt   fractionalizet   joint   strt   stript   eight_point_interpolationt   xyzt   quote(   R   R   R   t   processed_argsR   R!   R)   t   pdb_combinedt   pdb_inpR*   t   reflection_file_namet   miller_arrayst   maR4   t   map_3dR3   t
   point_fract   pt   point_formattedt   point_frac_formattedt	   map_value(    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/map_value_at_point.pyt   run=   sŽ    
	
		!!!
(!(!

22/ t   __main__i   (   t
   __future__R    R   t   mmtbx.utilsR   t   libtbx.utilsR   t
   iotbx.philR   t	   iotbx.pdbR   R   t   scitbx.array_familyR   R   R
   R   R   RM   t   __name__t   argv(    (    (    sS   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/command_line/map_value_at_point.pyt   <module>   s   	S