ó
‚™xTc           @   sù   d  d l  m Z d  d l 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 m Z d  d
 l m Z d  d l Z d  d l Z e j j d d ƒ Z d d „ Z e d k rõ e e j d ƒ n  d S(   iÿÿÿÿ(   t   division(   t   pdbN(   t   option_parser(   t   euclidean_model_matching(   t   sgtbx(   t   matrix(   t   Sorry(   t   show_string(   t   approx_equalt   input_stringsR  reference {
  file_name=None
    .type=path
  atom_selection=None
    .type=str
}
other {
  file_name=None
    .type=path
  atom_selection=None
    .type=str
}
output {
  file_name=None
    .type=path
  atom_selection=None
    .type=str
}
crystal_symmetry {
  unit_cell=None
    .type=unit_cell
  space_group=None
    .type=space_group
}
s#   iotbx.pdb.superpose_centers_of_massc   &   	   C   s†  t  |  ƒ d k r d g }  n  t d d | ƒ j ƒ  j ƒ  j d |  ƒ } | j d  k	 r„ t j d | j d | j	 ƒ t
 j d ƒ n  t j ƒ  } g  } g  } g  } xD| j D]9} t } t j j | ƒ r{d  }	 y t j j d | ƒ }	 Wn$ t k
 rÿ ‚  n/ t k
 rn Xt  |	 j ƒ d k r.d  }	 n  |	 d  k	 rP| j |	 ƒ t } q{t j d | ƒ r{| j | ƒ t } q{n  | s¬ y | j d	 | ƒ }	 Wn; t k
 rÔ}
 t j j | ƒ sÁ‚  n  t d
 | ƒ ‚ qåX| j |	 ƒ q¬ q¬ Wt j d | | ƒ } | j ƒ  }	 x[ |	 j |	 j  |	 j! g D]A } | j" d  k r$t  | ƒ d k r$| d | _" | d } q$q$Wt  | ƒ d k r°t d d j# g  | D] } t$ | ƒ ^ qŽƒ ƒ ‚ n  |	 j! j" d  k r'|	 j  j" d  k	 r't j j% |	 j  j" ƒ } | j& ƒ  j' d ƒ r| d  } n  | d 7} | |	 j! _" n  |	 j( j) d  k rQ| j* j) ƒ  |	 j( _) n  |	 j( j+ d  k r{| j* j, ƒ  |	 j( _+ n  t j- d |	 ƒ } | j ƒ  d GH|	 j j" d  k r½t d ƒ ‚ n  |	 j  j" d  k rÞt d ƒ ‚ n  |	 j! j" d  k rÿt d ƒ ‚ n  g  } g  } g  } xÏ |	 j |	 j  g D]» } t j. j/ d | j" ƒ } | j. j0 ƒ  | _0 | j | ƒ | j | j0 j1 ƒ  ƒ | d } | j2 d  k	 r½| j. j3 ƒ  j4 | j2 ƒ } | j5 | ƒ } n  d G| j6 ƒ  GH| j | j7 ƒ  ƒ q$W| j* } xD | D]< } | j/ j( ƒ  } | d  k	 ró| j8 d | d t ƒ } qóqóW| j) ƒ  d  k rTt d ƒ ‚ n  | j, ƒ  d  k rut d ƒ ‚ n  | j9 ƒ  | j: ƒ  } | j; d | ƒ } t< j= d | j, ƒ  d t d  t ƒ } g  | D]% } | j) ƒ  j> | j? ƒ  | ƒ ^ qÈ} t@ jA | jB ƒ  jC | d ƒ | d | jD ƒ } | jE ƒ  jF | jG ƒ  ƒ } d! G| jH ƒ  jI ƒ  GH| jJ ƒ  jK ƒ  tL jM | jN ƒ  ƒ } d" d j# g  | jO D] } d# | ^ qŠƒ GHg  | D] } | j) ƒ  j> | ƒ ^ qª} | | d } | j) ƒ  jP | ƒ }  d$ GHd% d j# g  | d D] }! d& |! ^ qƒ GHd' d j# g  | d D] }! d& |! ^ q4ƒ GHd( d j# g  |  D] }! d& |! ^ q]ƒ GHd) | jQ ƒ  GHtR | j) ƒ  jS | d | ƒ | jQ ƒ  ƒ s¶tT ‚ | j) ƒ  j> d* | d ƒ }" | |" }# | j) ƒ  jP d+ |# ƒ }$ | d j0 jU d, |$ ƒ | d j. }% |	 j! j2 d  k	 rZ|% j3 ƒ  j4 |	 j! j2 ƒ } |% j5 d- | ƒ }% n  |% jV d |	 j! j" d. | d/ t d0 d ƒ d  S(1   Ni    s   --helpt   usages;   %s [options] [reference_file] [other_file] [parameter_file]t   argst   expert_levelt   attributes_levelt	   file_namet   args   Unknown file format: %st   sourcesi   s   Too many PDB file names: %ss   , s   .pdbiüÿÿÿs   _superposed.pdbt   python_objects   #phil __OFF__s2   Required file name is missing: reference.file_names.   Required file name is missing: other.file_names/   Required file name is missing: output.file_nameiÿÿÿÿs   Number of selected sites:t   other_symmetryt   forces]   Unknown unit cell parameters.
  Use --unit_cell or --symmetry to supply unit cell parameters.s_   Unknown space group symmetry.
  Use --space_group or --symmetry to supply symmetry information.t   cb_opt   space_group_infot   use_k2lt   use_l2ns   Rotation in fractional space:s%   Translation in fractional space: (%s)s   %.6gs   Centers of mass:s                  Reference: (%s)s   %8.2fs             Original other: (%s)s     Symmetry related other: (%s)s0   Cartesian distance between centers of mass: %.4ft
   sites_cartt
   sites_fract   new_xyzt   atom_selectiont   crystal_symmetryt
   append_endt   atoms_reset_serial_first_value(W   t   lenR   t   enable_show_defaultst   enable_symmetry_comprehensivet   processR   t   Nonet   master_paramst   showR   t   syst   exitt!   command_line_argument_interpreterR   t   Falset   ost   patht   isfilet   iotbxt   philt   parset   KeyboardInterruptt   RuntimeErrort   objectst   appendt   TrueR   t   is_pdb_fileR   t   fetcht   extractt	   referencet   othert   outputR   t   joinR   t   basenamet   lowert   endswithR   t	   unit_cellt   symmetryt   space_groupR   t   formatt	   hierarchyt   inputt   atomst   extract_xyzR   t   atom_selection_cachet	   selectiont   selectt   sizet   meant   join_symmetryt   show_summaryt'   change_of_basis_op_to_reference_settingt   change_basisR   t   euclidean_match_symmetryt   fractionalizet   cR   t   min_sym_equiv_distance_infot   special_position_settingst   sym_equiv_sitest   continuous_shift_flagst   inverset   applyt   sym_opt   rt   as_xyzt   as_rationalt   as_floatR   t   colt   continuous_shiftst   tt   orthogonalizet   distR   t   distancet   AssertionErrort   set_xyzt   write_pdb_file(&   R   t   command_namet   command_linet   parameter_interpretert   parsed_paramst   pdb_file_namest   command_line_paramsR   t   arg_is_processedt   paramst   et   phil_paramst   param_groupt   st   namet   pdb_objst   sites_cartst   centers_of_masst   pdb_objt	   sites_selt   selR   t   crystal_symmetry_from_pdbt   cb_op_to_reft   sym_reft   match_symmetryt   center_cartt   centers_fract	   dist_infoRY   R`   t   sym_center_fract   sym_center_cartt   vt   sites_frac_othert   sites_frac_other_superposedt   sites_cart_other_superposedt   pdb_hierarchy(    (    s^   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/pdb.superpose_centers_of_mass.pyt   run(   s&    			
   		 	) 


		
		/)%!!"
		t   __main__i   (   t
   __future__R    R-   R   t
   iotbx.philt   iotbx.option_parserR   t   cctbxR   R   t   scitbxR   t   libtbx.utilsR   t   libtbx.str_utilsR   t   libtbx.test_utilsR   R&   R*   R.   R/   R$   Rˆ   t   __name__t   argv(    (    (    s^   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/pdb.superpose_centers_of_mass.pyt   <module>   s   	Â