ó
„™xTc           @   sa   d  d l  m Z d  d l Z d  d l Z d  d l Z d „  Z e d k r] e e j d ƒ n  d S(   iÿÿÿÿ(   t   divisionNc   
   	      s^  t  |  ƒ d k r! t d ƒ ‚ n  t j j j ‰  t d d d d d g ƒ } x|  D]} t j j j d | ƒ } | j j	 ƒ  j
 ƒ  x³ | j j ƒ  D]¢ } x™ | j ƒ  D]‹ } x‚ | j ƒ  D]t ‰ ‡  ‡ f d	 †  } | ƒ  r¹ xP ˆ j ƒ  D]? } x6 | j ƒ  D]( } | j | k rú | j d
 | ƒ qú qú Wqç Wq¹ q¹ Wq¦ Wq“ Wd | }	 | j j d |	 ƒ qR Wd  S(   Ni    s*   Please specify one or more pdb file names.s    N  s    CA s    C  s    O  s    CB t	   file_namec             s.   x' ˆ j  ƒ  D] }  |  j ˆ  k r t Sq Wt S(   N(   t   atom_groupst   resnamet   Truet   False(   t   ag(   t   aa_resnamest   rg(    sZ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/pdb_truncate_to_ala/v3_better.pyt   have_amino_acid   s    t   atomt   v3_truncated_to_ala_(   t   lent   RuntimeErrort   iotbxt   pdbt   amino_acid_codest   one_letter_given_three_lettert   sett	   hierarchyt   inputt   overall_countst   showt   modelst   chainst   residue_groupsR   t   atomst   namet   remove_atomt   write_pdb_file(
   t   argst   ala_atom_namesR   t   pdb_objt   modelt   chainR	   R   R
   t
   output_pdb(    (   R   R   sZ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/pdb_truncate_to_ala/v3_better.pyt   run   s$    	*
t   __main__i   (	   t
   __future__R    t	   iotbx.pdbR   t   iotbx.pdb.amino_acid_codest   sysR$   t   __name__t   argv(    (    (    sZ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/examples/pdb_truncate_to_ala/v3_better.pyt   <module>   s   	