ó
ŹxTc           @   sš   d  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 m Z m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z e j d  Z d   Z e d k rģ e e j d  n  d S(   sµ   
A script to open a model and its data and dump out all information about its
ions sites to a pickle file.

Run this module with:

phenix.python -m mmtbx.ions.svm.dump_sites [args]
i’’’’(   t   divisionN(   t   easy_pickle(   t   make_header(   t   ions(   t   ChemicalEnvironmentt   ScatteringEnvironment(   t   WATER_RES_NAMES(   t   iterate_sites(   t   load_model_and_data(   t   master_philc         C   s%  d } t  d |  d t   d | d t d t d t d t d	 d
 d |  	} | j } t | _ t d d | t j j d | j	 d | j
 d | j d | j j d | d | j d | j d |  } | j d |  t |  } t j j | j j j d  d d } | d I| IJt j | |  d S(   sĢ   
  Main entry point to this script.

  Parameters
  ----------
  args : list of str
      List of arguments, should not include the first argument with the
      executable name.
  out : file, optional
  sś   phenix.python -m mmtbx.ions.svm.dump_sites model.pdb data.mtz [options ...]

Utility to dump information about the properties of water and ion sites in a
model. This properties include local environment, electron density maps, and
atomic properties.
t   argsR	   t   outt   process_pdb_filet   create_fmodelt   prefer_anomaloust    set_wavelength_from_model_headert   set_inelastic_form_factorst   sasakit   usage_strings   Inspecting sitest   pdb_hierarchyt   fmodelt   geometry_restraints_managert
   wavelengtht   paramst   verboset   nproct   logi    s
   _sites.pkls
   Dumping toN(   R   R	   t   TrueR   t   use_svmR   R   t   identifyt   create_managerR   R   t   geometryt   inputR   t   debugR   t"   show_current_scattering_statisticst
   dump_sitest   ost   patht   splitextt   pdbt	   file_nameR   t   dump(   R
   R   R   t   cmdlineR   t   managert   sitest   out_name(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/ions/svm/dump_sites.pyt   _main   s8    										'c         C   sŌ   t  |  j d t j t d t } g  } x„ | D] } |  j | j  } |  j d | j  } t	 | j |  j
 | j d d |   } t | j |  d | d | j d f d	 | j d f } | j | | f  q/ W| S(
   s8  
  Iterate over all the ions and waters built into the model and dump out
  information about their properties.

  Parameters
  ----------
  manager : mmtbx.ions.identify.manager

  Returns
  -------
  list of tuple of mmtbx.ions.environment.ChemicalEnvironment,   mmtbx.ions.environment.ScatteringEnvironment
  t
   res_filtert   split_sitest   mFot   far_distance_cutoffg      @t
   fo_densityt   fofc_densityi    t   anom_density(   R   R   R   t	   SUPPORTEDR   R   t	   map_statst   i_seqt   get_map_gaussian_fitR   t   find_nearby_atomsR   t   fofct   anomt   append(   R+   t   atomst
   propertiest   atomR7   R3   t   chem_envt   scatter_env(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/ions/svm/dump_sites.pyR#   O   s(    			t   __main__i   (   t   __doc__t
   __future__R    R$   t   syst   libtbxR   t   libtbx.str_utilsR   t   mmtbxR   t   mmtbx.ions.environmentR   R   t   mmtbx.ions.identifyR   t   mmtbx.ions.svm.utilsR   t   mmtbx.command_lineR   t   mmtbx.command_line.water_screenR	   t   stdoutR.   R#   t   __name__t   argv(    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/ions/svm/dump_sites.pyt   <module>	   s   6	,