ó
³™xTc           @   s  d  d l  m Z d  d l m Z d  d l m Z d  d l Z d  d l m Z m 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 d  d
 l m Z d  d l Z d  d l Z e
 j j d ƒ Z d „  Z d „  Z e d k r
e e j d ƒ n  d S(   iÿÿÿÿ(   t   division(   t   crystal(   t   sgtbxN(   t   Sorryt	   multi_out(   t   crystal_symmetry_from_any(   t   xray_structure(   t   pdb(   t   StringIO(   t   f_models÷  sfcalc{
  input{
    unit_cell=None
    .type=unit_cell
    space_group=None
    .type=space_group
    model{
      file_name=None
      .type=path
    }
  }
  parameters{
    d_min = 2.0
    .type=float
    overall{
      b_cart{
        b_11 = 0
        .type=float
        b_22 = 0
        .type=float
        b_33 = 0
        .type=float
        b_12 = 0
        .type=float
        b_13 = 0
        .type=float
        b_23 = 0
        .type=float
      }
      k_overall = 0.1
      .type=float
    }
    solvent{
      k_sol = 0.3
      .type=float
      b_sol = 56.0
      .type=float
    }
    output_type = complex *amplitudes intensities
    .type=choice
  }
  output{
    logfile=sfcalc.log
    .type=str
    hklout=sfcalc.mtz
    .type=str
  }
}
c           C   s	   d GHd  S(   Ns   
No help
  (    (    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/examples/sfcalc.pyt
   print_helpD   s    c         C   s  t  |  ƒ d k r t ƒ  nðd |  k r2 t ƒ  nÚd |  k rH t ƒ  nÄd |  k r^ t ƒ  n®t ƒ  } d |  k r� | j d d d t j ƒ n  t ƒ  } t ƒ  } | j d d	 d | ƒ g  } t j d
 d ƒ } | d IJ| d IJ| d IJ| d IJ| Jx1|  D])} d  } t
 } t j j | ƒ r‹y; t j j d | ƒ } | d  k	 r`| j | ƒ t } n  Wqêt k
 rw‚  qêt k
 r‡qêXn_ y8 | j d | ƒ } | d  k	 rÂ| j | ƒ t } n  Wn$ t k
 rÙ‚  n t k
 rén X| s| d IJ| d I| IJ| d IJ| Jt d | ƒ ‚ qqWt j d | ƒ }	 |	 j ƒ  }
 d  } d  } |
 j j j j d  k	 r’t j d |
 j j j j ƒ } n  t j  d |
 j j j! d |
 j j j" ƒ } t j# d  | | g d  g ƒ } | j$ ƒ  | j! ƒ  d  k rt d ƒ ‚ n  | j" ƒ  d  k r&t d ƒ ‚ n  | j! ƒ  |
 j j _! t% j& d | j" ƒ  ƒ |
 j j _" | d IJt j' d |
 ƒ } | j( d | ƒ | d IJd  } |
 j j j j d  k	 rÉt) j d |
 j j j j ƒ } | j* d | ƒ } | d IJ| d  IJ| j$ ƒ  | J|
 j j+ j, j- } | j. | j/ | j0 | j1 | j2 | j3 g } t4 | j5 d! |
 j j+ j6 d" t
 ƒ j7 ƒ  ƒ } | j8 d# d$ d% d& ƒ } t9 j: d' | d( | d) d* d+ | d, | d- |
 j j+ j; j< d. |
 j j+ j; j= ƒ } | j9 ƒ  } | j> d/ | j? ƒ  |
 j j+ j, j@ ƒ } d  } d  } |
 j j+ jA d0 k r5| } d1 } n  |
 j j+ jA d2 k r_t4 | ƒ } d1 } n  |
 j j+ jA d3 k r•t4 | ƒ } | jB ƒ  } d4 } n  | jC d5 | ƒ } | jD ƒ  jE d |
 j jF jG ƒ n  tH |
 j jF jI d6 ƒ } | d7 |
 j jF jI IJ| J| | jJ ƒ  IJd  S(8   Ni    s   --helps   --hs   -hs   --quiett   labelt   stdoutt   file_objectt
   log_buffert
   home_scopet   sfcalcs   #phil __OFF__s   =================s        SFCALC      t	   file_namet   args2   ##----------------------------------------------##s   ## Unknown file or keyword:s   Unknown file or keyword: %st   sourcest	   unit_cellt   space_group_infos   Unit cell not defineds   Space group not definedt   groups   #phil __ON__t   python_objectt   outs   #phil __END__t   crystal_symmetrys   Atomic model summarys   ====================t   d_mint   anomalous_flagt   fractiongš™™™™™¹?t   max_freeiÿàõR   t   r_free_flagst   target_namet   ls_wunit_k1t   f_obst   b_cartt   k_solt   b_solt   datat   complext   FMODELt
   amplitudest   intensitiest   IMODELt   column_root_labelt   ws   writing log file with name %s(K   t   lenR
   R   t   registert   sysR   R   t   master_paramst!   command_line_argument_interpretert   Nonet   Falset   ost   patht   isfilet   iotbxt   philt   parset   appendt   Truet   KeyboardInterruptt	   Exceptiont   processR   t   fetcht   extractR   t   inputt   modelR   R   t   extract_fromR   t   symmetryR   t   space_groupt   select_crystal_symmetryt   show_summaryR   R   t   formatt   showR   t   xray_structure_simplet
   parameterst   overallR"   t   b_11t   b_22t   b_33t   b_12t   b_13t   b_23t   abst   structure_factorsR   t   f_calct   generate_r_free_flagsR	   t   managert   solventR#   R$   t   arrayR%   t	   k_overallt   output_typet	   f_as_f_sqt   as_mtz_datasett
   mtz_objectt   writet   outputt   hkloutt   opent   logfilet   getvalue(   t   argst   logt   string_buffert   string_buffer_plotst   phil_objectst   argument_interpreterR   t   command_line_paramst   arg_is_processedt   effective_paramst   paramst   hkl_xst   pdb_xst   phil_xst   combined_xst
   new_paramst	   pdb_modelRB   R"   t   dummyt   flagst   fmodelt   calc_data_with_solvent_contribt   resultR   t   mtz_datasett   logger(    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/examples/sfcalc.pyR   J   sö    



					



    

		
!




							t   __main__i   (   t
   __future__R    t   cctbxR   R   t   cctbx.xray.structure_factorst   libtbx.utilsR   R   t
   iotbx.philR7   R   t	   iotbx.pdbR   R   t	   cStringIOR   t   mmtbxR	   R/   R4   R8   R9   R0   R
   R   t   __name__t   argv(    (    (    sC   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/examples/sfcalc.pyt   <module>   s"   	1			�