ó
Æ™xTc           @   s�  d  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 Z d d	 l m Z d d
 l m Z d d l m Z m Z m Z d d l m 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 m Z d d l m  Z  d d l m! Z! d d l" Z# d d l$ Z$ d d l% Z% d d l& Z& d d l' Z# d Z( e j) j* e( d e+ ƒZ, e j) j* d e( d e+ ƒZ- d e. f d „  ƒ  YZ/ d „  Z0 e1 d „ Z2 d „  Z3 e4 d „ Z5 e1 e1 e1 d „ Z6 d „  Z7 e1 e1 e1 d „ Z8 d „  Z9 d „  Z: d  e& j; e+ d! „ Z< d" f  d# „  ƒ  YZ= e1 d$ „ Z> d% „  Z? d& e! j@ f d' „  ƒ  YZA d S((   sì   
Common manipulations of (macromolecular) model files.  This module is used
as a standalone program, phenix.pdbtools, but some components are also used
in phenix.refine, and it is also a dumping ground for individual related
functions.
iÿÿÿÿ(   t   divisionN(   t
   rigid_body(   t   utils(   t   flex(   t   iotbx_option_parser(   t   show_string(   t   pdb(   t   crystal(   t   Sorryt   null_outt    check_if_output_directory_exists(   t   crystal_symmetry_from_any(   t   monomer_library(   t   model_statistics(   t   easy_run(   t   combine_unique_pdb_files(   t   runtime_utilss  selection = None
  .type = atom_selection
  .help = Selection for atoms to be modified
  .short_caption = Modify atom selection
  .input_size=400
  .style = bold noauto
adp
  .help = Scope of options to modify ADP of selected atoms
  .multiple = True
  .short_caption=Modify ADPs
  .style = auto_align menu_item parent_submenu:model_modifications noauto
{
  atom_selection = None
    .type = atom_selection
    .help = Selection for atoms to be modified. \
            Overrides parent-level selection.
    .short_caption = Modify ADPs for selection
    .input_size=400
    .style  = bold
  randomize = False
    .type = bool
    .help = Randomize ADP within a certain range
    .short_caption=Randomize ADPs
  set_b_iso = None
    .type = float
    .help = Set ADP of atoms to set_b_iso
    .short_caption=Set isotropic B to
    .input_size = 64
  convert_to_isotropic = False
    .type = bool
    .help = Convert atoms to isotropic
  convert_to_anisotropic = False
    .type = bool
    .help = Convert atoms to anisotropic
  shift_b_iso = None
    .type = float
    .help = Add shift_b_iso value to ADP
    .short_caption=Increase B_iso by
  scale_adp = None
    .type = float
    .help = Multiply ADP by scale_adp
    .short_caption=ADP scale factor
}
sites
  .help = Scope of options to modify coordinates of selected atoms
  .multiple = True
  .short_caption=Modify coordinates
  .style = auto_align noauto menu_item parent_submenu:model_modifications
{
  atom_selection = None
    .type = atom_selection
    .help = Selection for atoms to be modified. \
            Overrides parent-level selection.
    .input_size=400
    .short_caption = Modify sites for selection
    .style = bold
  shake = None
    .type = float
    .help = Randomize coordinates with mean error value equal to shake
    .short_caption = Randomize coordinates (mean value)
  switch_rotamers = max_distant min_distant exact_match fix_outliers
    .type=choice(multi=False)
  translate = 0 0 0
    .type = floats(size=3)
    .optional = False
    .help = Translational shift (x,y,z)
  rotate = 0 0 0
    .type = floats(size=3)
    .optional = False
    .help = Rotational shift (x,y,z)
  euler_angle_convention = *xyz zyz
    .type = choice
    .help = Euler angles convention to be used for rotation
}
occupancies
  .help = Scope of options to modify occupancies of selected atoms
  .multiple = True
  .short_caption=Modify occupancies
  .style  = noauto menu_item parent_submenu:model_modifications
{
  atom_selection = None
    .type = atom_selection
    .help = Selection for atoms to be modified. \
            Overrides parent-level selection.
    .input_size=400
    .short_caption = Modify sites for selection
    .style = bold
  randomize = False
    .type = bool
    .help = Randomize occupancies within a certain range
    .short_caption = Randomize occupancies
  set = None
    .type = float
    .help = Set all or selected occupancies to given value
    .short_caption=Set occupancies to
    .input_size = 64
  normalize = False
    .type = bool
    .help = Reset the sum of occupancies for each residue to 1.0.  Note that       this will be performed before any atoms are removed.
    .short_caption = Reset total occupancy to 1
}
rotate_about_axis
  .style = box auto_align
{
  axis = None
    .type = str
  angle = None
    .type = float
  atom_selection = None
    .type = str
}
change_of_basis = None
  .type = str
  .short_caption = Change of basis operator
  .help = Apply change-of-basis operator (e.g. reindexing operator) to     the coordinates and symmetry.  Example: 'a,c,b'.
renumber_residues = False
  .type = bool
  .help = Re-number residues
increment_resseq = None
  .type = int
  .help = Increment residue number
  .short_caption = Increment residue numbers by
truncate_to_polyala = False
  .type = bool
  .help = Truncate a model to poly-Ala.
  .short_caption = Truncate to poly-Ala
  .style = noauto
remove_alt_confs = False
  .type = bool
  .help = Deletes atoms whose altloc identifier is not blank or 'A', and     resets the occupancies of the remaining atoms to 1.0.
  .short_caption = Remove alternate conformers
  .style = noauto
always_keep_one_conformer = False
  .type = bool
  .help = Modifies behavior of remove_alt_confs so that residues with no     conformer labeled blank or A are not deleted.  Silent if remove_alt_confs     is False.
set_chemical_element_simple_if_necessary = None
  .type = bool
  .short_caption = Guess element field if necessary
  .help = Make a simple guess about what the chemical element is (based on           atom name and the way how it is formatted) and write it into output file.
set_seg_id_to_chain_id = False
  .type = bool
  .short_caption = Set segID to chain ID
  .help = Sets the segID field to the chain ID (padded with spaces).
  .style = noauto
clear_seg_id = False
  .type = bool
  .short_caption = Clear segID field
  .help = Erases the segID field.
  .style = noauto
convert_semet_to_met = False
  .type = bool
  .short_caption = Convert SeMet residues to Met
  .style = noauto
rename_chain_id
  .help = Rename chains
  .short_caption = Rename chain ID
  .style = box
{
  old_id = None
    .type = str
    .input_size = 50
    .short_caption = Old ID
  new_id = None
    .type = str
    .input_size = 50
    .short_caption = New ID
}
set_charge
  .short_caption = Set atomic charge
  .style = box auto_align
{
  charge_selection = None
    .type = atom_selection
    .short_caption = Atom selection
  charge = None
    .type = int(value_max=7,value_min=-3)
}
output
  .help = Write out file with modified model (file name is defined in           write_modified)
  .style = noauto
{
  file_name=None
    .type=path
    .input_size=400
    .short_caption = Output model file
    .help = Default is the original file name with the file extension             replaced by "_modified.pdb".
    .style = bold new_file file_type:pdb
  format = *pdb mmcif
    .type = choice
    .help = Choose the output format of coordinate file (PDB or mmCIF)
}
remove_first_n_atoms_fraction = None
  .short_caption = Remove first N atoms (fraction)
  .type = float
random_seed = None
  .type = int
  .help = Random seed
t   process_includessè  use_neutron_distances = False
  .type = bool
  .help = Use neutron X-H distances (which are longer than X-ray ones)
modify
  .short_caption = Modify starting model
  .style = menu_item scrolled auto_align
{
remove = None
  .type = atom_selection
  .help = Selection for the atoms to be removed
  .short_caption=Remove atom selection
  .input_size=400
  .style = bold noauto
keep = None
  .type = atom_selection
  .help = Select atoms to keep
  .short_caption=Keep only atom selection
  .input_size=400
  .style = bold noauto
put_into_box_with_buffer = None
  .type = float
  .help = Move molecule into center of box.
%s
move_waters_last = False
  .type = bool
  .short_caption = Move waters to end of model
  .help = Transfer waters to the end of the model.  Addresses some     limitations of water picking in phenix.refine.
}
input {
  pdb
  {
    include scope mmtbx.utils.pdb_params
  }
  monomer_library {
    include scope mmtbx.utils.cif_params
  }
  crystal_symmetry
    .help = Unit cell and space group parameters
    .short_caption = Crystal symmetry
    .style = hidden
  {
    unit_cell=None
      .type=unit_cell
      .style = noauto
    space_group=None
      .type=space_group
      .style = noauto
  }
}
model_statistics = None
  .type = bool
  .style = hidden
stop_for_unknowns = True
  .type = bool
  .short_caption = Stop for residues missing geometry restraints
include scope mmtbx.monomer_library.pdb_interpretation.grand_master_phil_str
include scope libtbx.phil.interface.tracking_params
t   modifyc           B   s­   e  Z d d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c   	      C   s•  | |  _  | j |  _ |  j  d  k r3 t j |  _  n  | |  _ | |  _ | |  _ t |  _	 d  |  _
 d  |  _ t |  _ |  j j d  k	 r­ t j |  j j ƒ t j |  j j ƒ n  y |  j j } Wn* t k
 rÓ ‚  n t k
 ré d  } n Xy |  j j } Wn* t k
 r‚  n t k
 r&d  } n X| j d  k	 rÒ| d | j IJd d l m } | j | j ƒ } |  j j | ƒ |  _ |  j j ƒ  j |  j j ƒ  ƒ | d IJ|  j j ƒ  j d | d d ƒ t  |  _ n  | d  k	 rt j! d t" j# d	 t d
 | d | g d | ƒ d ƒ |  _
 n  | d  k	 ret j! d t" j# d	 t d
 | d | g d | ƒ d ƒ |  _ n  |  j
 d  k	 r¨|  j d  k	 r¨t$ d t% | ƒ t% | ƒ f ƒ ‚ n  |  j d  k	 rê|  j
 d  k sÌt& ‚ t j! d |  j j' ƒ |  _
 n  t j! d t" j# d	 t d
 | d |  j j( g d | ƒ d ƒ |  _) |  j* ƒ  |  j+ ƒ  |  j, ƒ  |  j- ƒ  |  j. ƒ  y |  j/ ƒ  Wn$ t k
 r€‚  n t k
 r�n Xd  S(   Ns&   Applying change-of-basis operator '%s'iÿÿÿÿ(   t   sgtbxs   New symmetry:t   ft   prefixs     t   flagst
   iselectiont   all_chain_proxiest   selection_stringst   xray_structurei    sf   Ambiguous selection: 'keep' and 'remove' keywords cannot be used simultaneously:
  keep=%s
  remove=%s(0   t   logt   pdb_hierarchyt   Nonet   syst   stdoutR   R   t   paramst   Falset   _occupancies_modifiedt   remove_selectiont   keep_selectiont   xray_structure_was_replacedt   random_seedt   randomt   seedR   t   set_random_seedt   removet   KeyboardInterruptt	   Exceptiont   keept   change_of_basist   cctbxR   t   change_of_basis_opt   change_basist   atomst   set_xyzt
   sites_cartt   crystal_symmetryt   show_summaryt   Truet   smart_selectionR   t   get_atom_selectionsR   R   t   AssertionErrorR   t	   selectiont   top_selectiont&   _process_remove_first_n_atoms_fractiont   _rotate_about_axist   _process_adpt   _process_sitest   _process_occupanciest   _put_in_box(	   t   selfR   R    R   R   t   params_remove_selectiont   params_keep_selectionR   t   cb_op(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   __init__2  s–    	 							   
   


										




   c         C   s¬   |  j  j d  k	 r¨ |  j j ƒ  } t | j ƒ  |  j  j ƒ } t j | t	 ƒ j
 t j | j ƒ  | t ƒ ƒ } |  j d  k	 r� | |  j j @} n  t j d | ƒ |  _ n  d  S(   NR   (   R    t   remove_first_n_atoms_fractionR   R   t
   scattererst   intt   sizeR   t   boolR!   t   concatenateR7   R#   R   R8   (   RC   RI   t   n_removet   sel(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR=   v  s    c         C   sJ   |  j  j d  k	 rF |  j j d |  j  j ƒ } |  j j | j ƒ  ƒ n  d  S(   Nt   buffer_size(   R    t   put_into_box_with_bufferR   R   t1   orthorhombic_unit_cell_around_centered_scattererst   replace_scatterersRI   (   RC   t   result(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRB   €  s    c         C   s!   |  j  d | | j ƒ  f IJd  S(   Ns   %s: selected atoms: %s(   R   t   format_summary(   RC   t   textR;   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   _print_action‡  s    
c         C   s  x|  j  j D] } | j d  k r. |  j } n@ t j d t j d t	 d |  j
 d | j g d |  j ƒ d ƒ } | j rŠ |  j d | ƒ n  | j r¦ |  j d | ƒ n  |  j d | d | j ƒ |  j d | d	 | j ƒ |  j d | d
 | j ƒ | j r |  j d | ƒ q q Wd  S(   NR   R   R   R   R   i    R;   t   b_isot   factort   shift(   R    t   adpt   atom_selectionR   R<   R   R8   R   R9   R!   R   R   t   convert_to_isotropict   _convert_to_isotropict   convert_to_anisotropict   _convert_to_anisotropict
   _set_b_isot	   set_b_isot
   _scale_adpt	   scale_adpt   _shift_b_isot   shift_b_isot	   randomizet   _randomize_adp(   RC   R[   R;   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR?   ‹  s$    						c         C   s0   |  j  d d d | ƒ |  j j d | j ƒ d  S(   NRV   s   Converting to isotropic ADPR;   (   RW   R   R]   t   indices(   RC   R;   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR^      s    	c         C   s0   |  j  d d d | ƒ |  j j d | j ƒ d  S(   NRV   s   Converting to anisotropic ADPR;   (   RW   R   R_   R   (   RC   R;   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR`   ¦  s    	c         C   sI   | d  k	 rE |  j d d | d | ƒ |  j j d | d | j ƒ n  d  S(   NRV   s    Setting all isotropic ADP = %.3fR;   t   value(   R   RW   R   Rb   R   (   RC   R;   RX   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRa   ¬  s
    	
c         C   sI   | d  k	 rE |  j d d | d | ƒ |  j j d | d | j ƒ n  d  S(   NRV   s&   Multiplying all ADP with factor = %.6gR;   RY   (   R   RW   R   Rd   R   (   RC   R;   RY   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRc   ³  s
    	
c         C   sI   | d  k	 rE |  j d d | d | ƒ |  j j d | d | j ƒ n  d  S(   NRV   s   Adding shift = %.2f to all ADPR;   t   b_shift(   R   RW   R   t   shift_usRi   (   RC   R;   RZ   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRe   º  s
    	
c         C   s0   |  j  d d d | ƒ |  j j d | j ƒ d  S(   NRV   s   Randomizing ADPR;   (   RW   R   t	   shake_adpR   (   RC   R;   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRh   Á  s    	c         C   sÓ   xÌ |  j  j D]¾ } | j d  k r. |  j } n@ t j d t j d t	 d |  j
 d | j g d |  j ƒ d ƒ } |  j d | d | j ƒ |  j d | d	 | j ƒ |  j d | d
 | j d | j d | j ƒ q Wd  S(   NR   R   R   R   R   i    R;   t   rms_differencet   modet	   translatet   rotatet   euler_angle_convention(   R    t   sitesR\   R   R<   R   R8   R   R9   R!   R   R   t   _shake_sitest   shaket   _switch_rotamerst   switch_rotamerst	   _rb_shiftRp   Rq   Rr   (   RC   Rs   R;   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR@   Ç  s     						c         C   s¨   | d  k r d  S|  j d d | d | ƒ t j j j ƒ  } |  j j ƒ  j |  j j	 ƒ  ƒ t
 j d |  j d | d | j ƒ |  _ |  j j d |  j j ƒ  j ƒ  ƒ d  S(   NRV   s   Switching rotamers; mode = %sR;   R   Ro   R4   (   R   RW   t   mmtbxR   t   serverR   R2   R3   R   R4   R   Rw   R   t   set_sites_cartt   extract_xyz(   RC   R;   Ro   t   mon_lib_srv(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRv   Ú  s     	
		c         C   sI   | d  k	 rE |  j d d | d | ƒ |  j j d | d | j ƒ n  d  S(   NRV   s   Shaking sites (RMS = %.3f)R;   Rn   (   R   RW   R   t   shake_sites_in_placeR   (   RC   R;   Rn   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRt   è  s    	
c   	      C   sœ  g  | D] } t  | ƒ ^ q } g  | D] } t  | ƒ ^ q& } t | ƒ d k rc t d | ƒ ‚ n  t | ƒ d k rˆ t d | ƒ ‚ n  | d d k sè | d d k sè | d d k sè | d d k sè | d d k sè | d d k r˜|  j d d d | ƒ | d	 k r:t j j d
 | d d | d d | d ƒ } n- t j j d
 | d d | d d | d ƒ } |  j j	 d | j
 ƒ  j ƒ  d | d | j ƒ n  d  S(   Ni   s   Wrong value: translate= i    i   i   RV   s   Rigid body shiftR;   t   zyzt   phit   psit   thet   rott   trans(   t   floatt   lenR   RW   t   scitbxR   t
   rb_mat_zyzt
   rb_mat_xyzR   t   apply_rigid_body_shiftt   rot_matt   as_mat3Ri   (	   RC   R;   Rp   Rq   Rr   t   iR„   Rƒ   t   rot_obj(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRx   ñ  s0      00	



c            sm  ‡  f d †  } xWˆ  j  j D]I} | j d  k r= ˆ  j } n@ t j d t j d t	 d ˆ  j
 d | j g d ˆ  j ƒ d ƒ } | j r¼ ˆ  j d d	 d
 | ƒ | ƒ  ˆ  j j d
 | j ƒ n  | j d  k	 rˆ  j d d | j d
 | ƒ | ƒ  ˆ  j j d | j d
 | j ƒ n  | j r ˆ  j d d d
 | ƒ | ƒ  t d ˆ  j d
 | j d ˆ  j d ˆ  j ƒ q q Wd  S(   Nc              s2   ˆ  j  r d  Sˆ  j r% t d ƒ ‚ n	 t ˆ  _ d  S(   Ns,   Can't modify occupancies (already modified).(   R<   R"   R   R7   (    (   RC   (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   check_if_already_modified  s
    	 	R   R   R   R   R   i    RV   s   Randomizing occupanciesR;   s   Setting occupancies to: %8.3fRj   s    Resetting total occupancy to 1.0t	   hierarchyR   (   R    t   occupanciesR\   R   R<   R   R8   R   R9   R!   R   R   Rg   RW   t   shake_occupanciesR   t   sett   set_occupanciest	   normalizet   normalize_occupanciesR   R   (   RC   R�   t   occR;   (    (   RC   s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRA   
  sB    												c         C   sD   |  j  d  k	 r@ |  j  j d k r@ |  j  j d |  j d d ƒ n  d  S(   Ni    t   outt   labels   Atoms to be kept: (   R#   R   t   selected_sizeR6   R   (   RC   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt$   report_number_of_atoms_to_be_removed5  s
    	c      	   C   sù  |  j  j } |  j j ƒ  } | j | j | j g j d  ƒ d k rõg  } y1 x* | j j	 ƒ  D] } | j
 t | ƒ ƒ q[ WWnj t k
 rå t j d t d |  j d | j d |  j ƒ d } g  | j | ƒ j ƒ  D] } | ^ qÐ } n Xt | ƒ d k rt d t | j ƒ ƒ ‚ n  t j j | d  ƒ } t j j | d ƒ } | j d	 | d
 | j d t ƒ }	 t j d t d |  j d | j d |  j ƒ d } | j t ƒ d k rÃt d t | j ƒ ƒ ‚ n  |	 | j | ƒ }
 |  j j | j | |
 ƒ ƒ n  d  S(   Ni    R   R   R   R   i   s(   Bad selection rotate_about_axis.axis: %si   t   pointt   anglet   degs/   Empty selection rotate_about_axis.selection: %s(   R    t   rotate_about_axisR   R4   t   axisR\   R�   t   countR   t   splitt   appendR…   R,   R   R9   R!   R   t   selectt	   as_doubleR†   R   t   strR‡   t   matrixt   colt#   rt_for_rotation_around_axis_throughR7   R{   t   set_selected(   RC   t   raapR4   R    t   aRO   R�   t   p1t   p2t   raat   sites_cart_rotated(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR>   <  s>    '			,					N(   t   __name__t
   __module__R   RG   R=   RB   RW   R?   R^   R`   Ra   Rc   Re   Rh   R@   Rv   Rt   Rx   RA   R›   R>   (    (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR   1  s$   D	
															+	c         C   sž   | d | j  IJ| d | j IJd } xV |  j ƒ  D]H } x? | j ƒ  D]1 } | j | j  k rH | j | _ | d 7} qH qH Wq5 W| d k rš | d IJn  d  S(   Ns   old_id= '%s's   new_id= '%s'i    i   sJ   WARNING: no chain id renamed: check input PDB file or renaming parameters.(   t   old_idt   new_idt   modelst   chainst   id(   R�   R    R   t   countert   modelt   chain(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   rename_chain_id^  s    c         C   sd  t  | t ƒ s t ‚ | d
 k r0 t d ƒ ‚ n  t | ƒ d k rQ t d ƒ ‚ n  | d
 k ri t ƒ  } n  |  j ƒ  } | j | ƒ j	 ƒ  } t
 | ƒ d k r¯ t d | ƒ ‚ n  | d k rÄ d } n) | d k  rã d t | ƒ } n
 d | } | j ƒ  } xd | D]\ }	 | |	 }
 |
 j | ƒ | |	 j ƒ  d } | | | |	 _ | d	 |
 j ƒ  | f IJq Wd
 S(   s  
  Set the charge for selected atoms.  Note that both the hierarchy and the
  xray_structure must be passed here - in the context of the pdbtools app,
  the scattering_type attributes will override the atom's element and charge
  when the structure is written out.
  s8   You must specify an atom selection to apply a charge to.i
   s-   The charge must be in the range from -9 to 9.i    s;   No atoms selected for charge modification (selection = %s).s     s   %1d-s   %1d+s     %s : set charge to %sN(   t
   isinstanceRJ   R:   R   R   t   absR	   t   atom_selection_cacheR;   R   R†   RI   t
   set_charget   element_and_charge_symbolst   scattering_typet   id_str(   R�   R   t	   pdb_atomsR;   t   chargeR   t	   sel_cachet   iselRI   t   i_seqt   atomt   elem_symbol(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   set_atomic_chargek  s0     	

c            sí   d d l  } | j j j ‰  t d d d d d g ƒ } x° |  j ƒ  D]¢ } x™ | j ƒ  D]‹ } x‚ | j ƒ  D]t ‰ ‡  ‡ f d †  } | ƒ  ri xP ˆ j ƒ  D]? } x6 | j	 ƒ  D]( } | j
 | k rª | j d	 | ƒ qª qª Wq— Wqi qi WqV WqC Wd S(
   sŒ   
  Remove all protein sidechain atoms beyond C-alpha (as well as all hydrogens).
  Does not change the chemical identity of the residues.
  iÿÿÿÿNs    N  s    CA s    C  s    O  s    CB c             s.   x' ˆ j  ƒ  D] }  |  j ˆ  k r t Sq Wt S(   N(   t   atom_groupst   resnameR7   R!   (   t   ag(   t   aa_resnamest   rg(    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   have_amino_acidœ  s    RÈ   (   t   iotbx.pdb.amino_acid_codesR   t   amino_acid_codest   one_letter_given_three_letterR“   Rµ   R¶   t   residue_groupsRË   R2   t   namet   remove_atom(   R�   t   iotbxt   ala_atom_namesR¹   Rº   RÐ   RÍ   RÈ   (    (   RÎ   RÏ   s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   truncate_to_poly_ala‘  s    	c         C   s  xÚ|  j  ƒ  D]Ì} xÃ| j ƒ  D]µ} x�| j ƒ  D]s} | j ƒ  } t | ƒ d k s] t ‚ | r?t | ƒ d k rŽ | d j d k rŽ q3 n  g  } xQ | D]I } | j d k r¶ q› n  t j | j	 ƒ  j
 ƒ  ƒ } | j | | f ƒ q› W| j d „  ƒ x( | d D] \ } }	 | j d | ƒ qW| d \ }
 }	 d |
 _ q3 x9 | D]1 } | j d k rn| j d | ƒ qFd | _ qFWt | j ƒ  ƒ d k r3 | j d | ƒ q3 q3 Wt | j ƒ  ƒ d k r  | j d | ƒ q  q  Wq W|  j	 ƒ  } t j | j ƒ  d	 ƒ } | j | ƒ d
 S(   s  
  Remove all alternate conformers from the hierarchy.  Depending on the
  value of always_keep_one_conformer, this will either remove any atom_group
  with altloc other than blank or 'A', or it will remove any atom_group
  beyond the first conformer found.
  i    i   t    c         S   s   t  | d |  d ƒ S(   Ni   (   t   cmp(   R¬   t   b(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   <lambda>¼  s    t
   atom_groupt   At   residue_groupRº   g      ð?N(   RÚ   Rß   (   Rµ   R¶   RÔ   RË   R†   R:   t   altlocR   t   meanR2   t   extract_occR£   t   sortt   remove_atom_groupt   remove_residue_groupt   remove_chaint   doubleRK   t   set_occ(   R�   t   always_keep_one_conformerR¹   Rº   Rà   RË   t   atom_groups_and_occupanciesRÞ   t   mean_occR—   t   single_confR2   t   new_occ(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   remove_alt_confs§  s<    %c      
   C   s”  | d k r t ƒ  } n  xA|  j ƒ  D]3} x*| j ƒ  D]} x| j ƒ  D]} | j ƒ  j ƒ  } | d k	 r– | j | ƒ } | j t	 ƒ s– qK q– n  | j
 ƒ  }	 d }
 xš |	 D]’ } | j ƒ  j ƒ  } t | ƒ d k rì | j | ƒ q¯ n  | j j ƒ  d k rq¯ n  | j | d ƒ s3t d | j ƒ  ƒ ‚ n  |
 | d 7}
 q¯ W|
 d k rn| d | j ƒ  |
 f IJn  d |
 } t } t |	 ƒ } xÃ |	 D]» } | j ƒ  } | j j ƒ  d k sÄ| d k rð| d IJ| j t j t | ƒ d ƒ ƒ q‘| s‘| j ƒ  } | j | t j t | ƒ | ƒ ƒ | d | j | d j f IJt	 } q‘q‘WqK Wq8 Wq% W|  j ƒ  j ƒ  } | d k	 r�| j ƒ  j | ƒ n  d S(	   s�   
  Reset the sum of occupancies for each residue_group to 1.0.  This will fail
  if any (selected) atom_group has non-uniform occupancies.
  i    RÚ   s+   Non-uniform occupancies for atom_group '%s'g      ð?s$     residue_group '%s': occupancy=%.2fs$       altloc ' ': set occupancy to 1.0s&       altloc '%s': set occupancy to %.2fN(   R   R	   Rµ   R¶   RÔ   R2   t   extract_i_seqR¤   t   all_eqR7   RË   Rã   R†   Rå   Rá   t   stripR   RÂ   R!   Ré   R   Rè   R—   RI   R”   (   R�   R;   R   R   R¹   Rº   Rà   t   i_seqst   selection_rgRË   t   occupancy_sumRÞ   t   atom_occt   gapt   resett   n_groupsR2   R—   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR–   Ï  sV     	
!
"#c   	      C   sÜ   d } | j  ƒ  } xÃ t |  j ƒ  ƒ D]¯ \ } } | j j ƒ  d k r% | j j ƒ  d k r% | j ƒ  } | j d k rÔ | d 7} d | _ d | _ d | _ | | } d | _	 x  | j ƒ  D] } t
 | _ q» WqÔ q% q% W| S(	   sZ   
  Change the chemical identity of MSE residues to MET, without changing
  coordinates.
  i    t   SEt   MSEi   t   METs    SD s    St   S(   RI   t	   enumerateR2   RÕ   Rò   t   elementt   uppert   parentRÌ   RÁ   R!   t   hetero(	   R   R   t   n_mseRI   RÇ   RÈ   RÞ   t	   scatterert   ag_atom(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   convert_semet_to_met   s    *
			
	c      	   C   s…  | d  k r t ƒ  } n  d  } | d  k	 rN |  j ƒ  } | j | ƒ j ƒ  } n  x0|  j ƒ  D]"} x| j ƒ  D]} | d  k	 r | j ƒ  j ƒ  } | j	 | ƒ }	 t
 |	 ƒ d k r¹ qn q t
 |	 ƒ t
 | ƒ k r | d | j t
 |	 ƒ t
 | ƒ f IJqn q n  | d  k r?d }
 xd | j ƒ  D] } |
 | _ |
 d 7}
 qWqn x7 | j ƒ  D]) } | j ƒ  } | | 7} d | | _ qLWqn Wq[ Wd  S(   Ni    sR   Warning: chain '%s' is only partially selected (%d out of %d) - will not renumber.i   s   %4d(   R   R	   R¾   R;   R   Rµ   R¶   R2   Rð   t   intersectionR†   R·   RÔ   t   resseqt   resseq_as_int(   R   t   renumber_fromR\   R   t   selected_i_seqsRÅ   R¹   Rº   t   chain_i_seqsR  R¸   RÏ   R  (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   renumber_residues  s2     &		
c      	   C   sl   | d k s t  ‚ | d k rC |  j d | d | d t d d ƒ n% | d k rh |  j d | d | ƒ n  d  S(	   NR   t   mmcift	   file_nameR5   t
   append_endt   atoms_reset_serial_first_valuei   (   s   pdbR  (   R:   t   write_pdb_fileR7   t   write_mmcif_file(   R   R5   R  t   output_format(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   write_model_file1  s    	
	c         C   s¥  t  |  j ƒ  ƒ d k r+ t d d ƒ ‚ n  |  j ƒ  } | j d ƒ } | j t ƒ } | d k ru | d IJ|  | f S| d | IJ|  j | ƒ } |  j | ƒ } | j | ƒ } | j | ƒ }	 x3 | j ƒ  j	 ƒ  D] }
 | j ƒ  j
 |
 j ƒ  ƒ qÔ W|	 j | j ƒ  ƒ t  |	 j ƒ  ƒ t  | j ƒ  ƒ k oEt  |  j ƒ  ƒ k n sPt ‚ xD t | j ƒ  |	 j ƒ  ƒ D]' \ } } | j ƒ  | j k slt ‚ qlW| |	 f Sd S(	   sg  
  Re-arranges the PDB hierarchy so that waters are located at the end of the
  atom list.  This is done automatically in phenix.refine if water picking is
  enabled, but the routine here is more flexible.  (Note that there is some
  overlap in functionality with mmtbx.command_line.sort_hetatms, but the
  latter module is significantly more complicated.)
  i   s1   Rearranging water molecules is not supported for s   multi-MODEL structures.s   resname HOH or resname WATi    s   No waters found, skippings   %d atoms will be moved.N(   R†   Rµ   R   R¾   R;   R¡   R7   R¤   t
   only_modelR¶   t   append_chaint   detached_copyt   add_scatterersRI   R2   R:   t   zipRÂ   R™   (   R   R   R˜   RÅ   t	   water_selt   n_waterst   hierarchy_watert   hierarchy_non_watert	   xrs_watert   xrs_non_waterRº   RÈ   t   scat(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   move_waters<  s.    

7s   phenix.pdbtoolsc         C   s™  t  j |  d | d | ƒ} t  j d | d d | ƒ t d | d |  d | ƒ } g  } | j } | j j j } | j j j }	 | j	 j
 j }
 | d  k rR|	 d k r­ d } n |	 d	 k rÂ d
 } n  t |
 ƒ d k rõ t j j |
 d ƒ d | } qRt |
 ƒ d k r(t j j |
 d ƒ d | } qRt j j | j d ƒ } | d | } n  | j ƒ  | j j } | j j d t ƒ } | j } | j } | d  k rªt d ƒ ‚ n  | j r^t } t j j d d d t j j ƒ } | d  k sùt j j d ƒ rt } n  t  j  d d | ƒ| j j! d t d | j" j# ƒ } t$ j% j& d | d t ƒ } | j' j( ƒ  } | } | } | j) ƒ  } | j* j+ j, r©| j- | ƒ } | j- | ƒ } n  t j. d | d | d | ƒ } | J| j/ d | d d ƒ t  j  d d | ƒt$ j0 j& d  | d | j d | d | ƒ } | j1 d | d! t ƒ | J| d" | j2 ƒ  IJ| d# IJ| Jd  S| j* j+ j3 r|	 d	 k rˆt d$ ƒ ‚ n  t  j  d% d | ƒt |
 ƒ d k r¼t d& ƒ ‚ n  | j d }
 t j j4 |
 ƒ sît d' |
 ƒ ‚ n  t5 j6 d( |
 | f ƒ | d) | IJ| g St  j  d* d | ƒt7 j | ƒ j/ d | ƒ | j j8 r‚t  j  d+ d | ƒ| d, IJ| j9 ƒ  j8 ƒ  n  | j j: j; | j j: j< g j= d  ƒ d k rät  j  d- d | ƒt: d. | d/ | j j: d | ƒ n  | j j> sü| j j? r=t  j  d0 d | ƒt? d | d1 | j j> d2 | j j@ d | ƒ n  | j jA rž| j jB rht d3 d4 ƒ ‚ n  xb | j9 ƒ  D]" } | jC ƒ  } d5 | jD | _E quWn/ | j jB rÍx  | j9 ƒ  D] } d6 | _E q·Wn  | j jF rïtF d | d  | ƒ n  | j jG jH d  k	 rDtI d. | d7 | d  | d8 | j jG jH d9 | j jG jJ d | ƒ n  t  j  d: d | ƒt d  | d/ | j d; | d | ƒ } | jK ƒ  | jL rš| j } n  tM | jN d< d  ƒ } | d  k	 rÜ| j- | ƒ } | j- | ƒ } n  | j jO rBt  j  d= d | ƒ| j9 ƒ  } | jP ƒ  tQ d. | ƒ | j9 ƒ  } | j- | jR ƒ  ƒ } n  | j jS rËt  j  d> d | ƒ| j9 ƒ  } | jP ƒ  tS d. | d? | j jT ƒ | j9 ƒ  } | j- | jR ƒ  ƒ } | jU d@ ƒ | dA IJn  | j jV rt  j  dB d | ƒtW | | d | ƒ\ } } n  t  j  dC d | ƒ| dD I| IJ| jX | dE t ƒ| jY ƒ  } | jZ r\d  } n  t[ | | dF | dG |	 ƒ| j\ | ƒ t  j  dH d | ƒ| S(I   NR˜   t   replace_stderrR   RV   s'     %s tools for PDB model manipulations.t   command_namet   argsR   R  t   cifi   i    s
   _modified.t   _et_al_modifiedR6   s   Cannot extract xray_structure.t   relative_paths   chem_data/rotarama_datat   testt   probes   Geometry statisticst   show_energiest   params_editst   geometryt   normalizationR   t   molprobity_scorest   restraints_managerR   RÚ   s   ADP statisticsR   t   paddeds   Mean(|Bi-Bj|): %-6.2fs1     Bi and Bj are B-factors of bonded atoms i and js:   mmcif format not currently supported with the option add_hs   Adding hydrogen atomss   Multiple input PDB files found.s   File %s does not exist.s   phenix.reduce %s > %ss*   Output model file name (with H added): %s
s   Complete set of parameterss   Restore 77-78 columns�     Make a simple guess about which chemical element should be in 77-78 column,
  and outputs and new file with this column filled.s   Rename chain idR�   R    s   Re-numbering residuesR
  R\   s5   Parameter conflict - set_seg_id_to_chain_id=True and s<   clear_seg_id=True.  Please choose only one of these options.s   %-4ss       RÃ   R;   RÄ   s(   Performing requested model manipulationsR   R   s   Truncating to poly-Alas    Removing alternate conformationsRê   g      ð?s   All occupancies reset to 1.0.s   Moving waters to end of models   Writing output models   Output model file name: t   assert_identical_id_strR  R  t   Done(]   R   t   set_logt   print_programs_start_headert   interpreterR    R   t   outputR  t   formatt   inputR   R   R†   t   ost   patht   basenamet   pdb_file_namest   set_ppft   processed_pdb_fileR   R   R!   R   RÃ   R   R   R7   t   libtbxt   envt   find_in_repositoriest   isdirt
   has_modulet   print_headert   geometry_restraints_managert   geometry_restraintst   editsRy   t
   restraintst   managert   pdb_inpt   construct_hierarchyt   hd_selectiont   command_linet   optionst   ignore_hydrogensR¤   R-  t   showR¹   t   show_adp_statisticst   rms_b_iso_or_b_equiv_bondedt   add_ht   isfileR   t   got   master_paramst(   set_chemical_element_simple_if_necessaryR2   R»   R³   R´   R¡   t   increment_resseqR  R;   t   set_seg_id_to_chain_idt   clear_seg_idt   fetch_labelst   chain_idt   segidR  R¿   t   charge_selectionRÊ   RÄ   R›   R%   t   getattrR#   t   truncate_to_polyalat   reset_i_seqRÙ   Rð   Rï   Rê   R”   t   move_waters_lastR"  t   adopt_xray_structureR5   t   fake_crystal_symmetryR  R£   (   R%  R$  R˜   R#  R   t   command_line_interpretert   output_filesR    t   ofnR  t   ifnt   extt   pdboutR   R   R   RÃ   t   use_molprobityt   rotarama_dirR-  R0  t   pht   rmt
   not_hd_selt   msoR¹   RÈ   t   labelsRT   R;   R5   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   run]  sN   			 	 	 ! !
										
  !



		
	

		R6  c           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sÖ  | |  _  | |  _ | |  _ t |  _ t j j ƒ  |  _ t j j ƒ  |  _ d  |  _
 g  |  _ g  |  _ g  |  _ d  |  _ d  |  _ |  j ƒ  |  j j |  j
 j j j ƒ |  j rGt d |  j ƒ } | j d |  j ƒ t | j ƒ d k rö t d ƒ ‚ n  t j j d d  d t j | j ƒ d t ƒ } | j ƒ  j  d d	 ƒ j! ƒ  |  _! n  |  j d
 IJ|  j! j" d |  j d d ƒ |  j! j# ƒ  |  j
 j j! _# |  j! j$ ƒ  |  j
 j j! _% |  j! j% ƒ  j& ƒ  |  _' |  j Jt d |  j ƒ } | j d |  j ƒ t | j ƒ d k rt d ƒ ‚ n  t j j d d  d t j | j ƒ d t ƒ |  _( x‘ |  j
 j j j D]} } t) j* j+ | ƒ rQ| |  j k rQt, j j j- d | ƒ } t | ƒ d k rÎ|  j j. | | f ƒ |  j j. | ƒ qÎqQqQWd  S(   Nt
   file_namesR˜   i    s   No coordinate file given.t   source_infot   linest   raise_sorry_if_format_errorRP   i
   s5   Working crystal symmetry after inspecting all inputs:R   R   s     R  (/   R$  R%  R   R!   Re  R   Rz   R}   t   ener_libR   R    R=  t   cif_file_namest   cif_objectsR?  t   processed_pdb_file_referencet   process_argst   extendR9  R   R  R   t   report_non_uniqueR†   t   unique_file_namesR   R×   R   t
   std_stringt   raw_recordsR7   t   xray_structure_simplet*   cubic_unit_cell_around_centered_scatterersR5   R6   t	   unit_cellt   space_group_infot   space_groupt   build_derived_point_groupt   point_groupRK  R:  R;  RU  Ry   t   read_cifR£   (   RC   R$  R%  R   t   pdb_combinedRK  R  t
   cif_object(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRG     sX    										
		!c         C   s‘   t  j d |  j d |  j j j d |  j j d |  j j d |  j d |  j	 d |  j j
 d |  j d	 |  j ƒ 	} | j d
 |  j ƒ \ |  _ |  _ d  S(   NR5   t   pdb_parameterst   pdb_interpretation_paramst   stop_for_unknownsR   R}   t   use_neutron_distancesRx  Rz  R=  (   R   t   process_pdb_file_srvR5   R    R9  R   t   pdb_interpretationRŽ  R   R}   R�  Rx  Rz  t   process_pdb_filesR=  R?  RK  (   RC   t   processed_pdb_files_srv(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR>  J  s    						c      	   C   s   |  j  } t | ƒ d k r' d g } n  d d } t j ƒ  } t j d | d d ƒ | j ƒ  } t d d	 |  j d
 d |  j | | f ƒ j	 ƒ  j
 ƒ  j d  d d d d t d d ƒj d  d d d d d ƒj d d d d d ƒj d d d d d ƒj d | ƒ |  _ |  j j d  k	 rTt j d |  j d |  j j d |  j j ƒ t j d ƒ n  t | ƒ d k r´t j d d |  j ƒ|  j d Id j g  | D] } t | ƒ ^ q–ƒ IJn  g  } t j d d ƒ } g  } g  }	 t j d  d |  j ƒx9|  j j  D]+} t }
 t j j | ƒ r—d  } y t j j d! | ƒ } Wn$ t  k
 rN‚  n/ t! k
 r^n Xt | j" ƒ d k r}d  } n  | d  k	 rŸ| j# | ƒ t$ }
 q—t% j& d! | ƒ sÃt% j' d! | ƒ rd" „  } |  j( j# | ƒ t$ }
 t) j* d# | g d$ | d% | ƒ q—y t+ j, j- j. d! | ƒ } Wn$ t  k
 r6‚  q—t/ k
 rFq—Xt | ƒ d k r—|  j0 j# | | f ƒ |  j1 j# t j j2 | ƒ ƒ t$ }
 q—n  |
 sûy | j d& | ƒ } Wn` t3 k
 r} t j j | ƒ sd' | k ré‚  n  t3 d( t | ƒ ƒ ‚ n  t3 d) | ƒ ‚ q&X|	 j# | ƒ qûqûW|  j Jt |	 ƒ d k r„|  j d* IJx1 |	 D]& } | j d |  j d d ƒ |  j JqWWn  t j4 d+ | |	 d, t$ ƒ \ |  _5 } t | ƒ rb|  j d- d. IJ|  j j6 j7 rå|  j d/ In |  j d0 I|  j d1 IJx' | D] } |  j d It8 | ƒ IJqW|  j d- d. IJ|  j J|  j j6 j7 sbt3 d2 ƒ ‚ qbn  |  j5 j9 ƒ  |  _5 t: j; d3 |  j j< d4 t: j< d5 |  j5 j= j> j? d6 |  j5 j= j> j@ ƒ d7 | ƒ |  _> |  j> j? ƒ  d  k sï|  j> jA ƒ  d  k rt$ |  _B |  j d8 IJ|  j d9 IJ|  j Jn  d  S(:   Ni    s   --helps(   See also: http://www.phenix-online.org/
s0   Questions / problems: phenixbb@phenix-online.orgR˜   R   s     t   usages(   %s [options] [pdb_file] [parameter_file]t   descriptions9   Example: %s model.pdb parameters.txt

Full parameters:
%ss   --unused_okt   actiont
   store_truet   defaultt   helps2   Disables detection of unused parameter definitionss   --quiets   Suppress output to screens   --add_hs,   Add H atoms to a model using Reduce program.s   --ignore_hydrogenss8   Do not account for H and D atoms in geometry statistics.R%  t   expert_levelt   attributes_levels   Getting inputss   Command line arguments:t    t
   home_scopet   pdbtoolss   Processing inputsR  c         S   sf   d d l  m } d d l m } x? | j | j f D]+ } y | |  ƒ SWq3 t k
 r] q3 q3 Xq3 Wd  S(   Niÿÿÿÿ(   t   crystal_symmetry_from_cif(   t   crystal_symmetry_from_pdb(   t	   iotbx.cifRŸ  t	   iotbx.pdbR   t   extract_fromR,   (   R  RŸ  R   t   extract_function(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR£  ™  s    	  Rt  t   target_listR¤  t   argt   =s   File not found: %ss   Unknown file format: %ss#   Command line parameter definitions:t   sourcest   track_unused_definitionst   *iO   s   WARNING:s   ERROR:s   Unused parameter definitions:sÎ   Unused parameter definitions:
  Please check the input file(s) for spelling errors and obsolete
  parameter definitions.
  To disable this error message, add
    --unused_ok
  to the command line arguments.t   from_command_linet   from_parameter_fileR„  R…  t   from_coordinate_filess(   *** No input crystal symmetry found. ***s5   Functionality requiring crystal symmetry unavailable.(C   R%  R†   t	   cStringIOt   StringIORW  RQ  t   getvalueR   R$  t   enable_show_defaultst   enable_symmetry_comprehensivet   optionR   R!   t   processRN  Rš  R   R›  R   t   exitR   RE  t   joinR   t!   command_line_argument_interpreterR:  R;  RU  R×   t   philt   parseR+   t   RuntimeErrort   objectsR£   R7   R   t   is_pdb_filet   is_pdb_mmcif_fileR=  R   t   extract_and_appendRy   R   Rz   R‰  R,   Rz  Ry  t   abspathR   t   fetchR    RO  t	   unused_okR¦   t   extractR   t   select_crystal_symmetryt   symmetryR9  R5   R„  R†  R…  Re  (   RC   R%  t   description_see_alsot   phil_outt   phil_help_strR¦  t'   crystal_symmetries_from_coordinate_filet   parameter_interpretert   parsed_paramst   command_line_paramst   arg_is_processedR    R£  R‹  t   et   unused_definitionst   obj_loc(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR|  Y  sò    	 #							"		   					
    	
			(   R±   R²   RG   R>  R|  (    (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR6    s   	7	c         C   s‡   t  |  j j j ƒ d k r* t d ƒ ‚ nY |  j j j d  k	 rƒ t j	 j
 |  j j j ƒ rm t d d ƒ ‚ n  t |  j j j ƒ n  t S(   Ni    s   No PDB file(s) specified.s2   The specified output file is a currently existing s
   directory.(   R†   R9  R   R  R   R   R7  R   R:  R;  RC  R
   R7   (   R    t   callback(    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   validate_paramsã  s    c         C   s   g  } t  |  t ƒ ru x] |  D]R } d  } t j j | ƒ \ } } | d k rU d } n d } | j | | f ƒ q Wn  | g  f S(   Ns   .pdbs   Modified PDB files   Unknown file(   R¼   t   listR   R:  R;  t   splitextR£   (   RT   Rg  R  t	   file_desct   baseRj  (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt
   finish_jobí  s    	t   launcherc           B   s   e  Z d  „  Z RS(   c         C   s   t  d t |  j ƒ ƒ S(   NR%  (   Rs  RÒ  R%  (   RC   (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyRs  û  s    (   R±   R²   Rs  (    (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyR×  ú  s   (B   t   __doc__t
   __future__R    t
   iotbx.philR×   t   mmtbx.refinementR   Ry   R   t   cctbx.array_familyR   t   iotbx.option_parserR   t   libtbx.str_utilsR   t   libtbx.philR@  R   R/   R   t   libtbx.utilsR   R	   R
   R   R   t   mmtbx.restraintst   mmtbx.modelR   R'   R   R¢  R   R   t   scitbx.matrixR‡   R®  R:  R   t   scitbx.rigid_bodyt   modify_params_strR¸  R¹  R7   t   modify_paramsRW  t   objectR   R»   R   RÊ   RÙ   R!   Rï   R–   R  R  R  R"  R   Rs  R6  RÑ  RÖ  t   target_with_save_resultR×  (    (    (    s<   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/pdbtools.pyt   <module>   s^   Ñ	;ÿ .	 	(0			!	´Ñ
	