ó
‚™xTc           @   s°   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m	 Z	 d  d l
 Z
 d  d l Z e j j d ƒ Z d d „ Z e d k r¬ e e
 j d ƒ n  d S(	   iÿÿÿÿ(   t   divisionN(   t   Usaget   format_cpu_timess§   
join_fragment_files {
  reset_atom_serial = True
    .type = bool
  model_file = None
    .type = path
    .multiple = True
  format = mmcif pdb
    .type = choice
}
s   iotbx.pdb.join_fragment_filesc      
      si  d d l  m } ‡  f d †  } t |  ƒ d k s@ |  d g k rwt j j d ƒ } | d  k r} t |  ƒ d k rl| ƒ  qlnï xì t  j j j	 ƒ  D]Ø } d G| GH| j
 ƒ  } t  j j d g  | D]) } t j j | | d	 d
 !d | ƒ ^ q¾ ƒ j } d | d | d f }	 d G|	 GHt |	 d ƒ }
 |
 d j | j ƒ IJ|
 j | j d t ƒ ƒ t |  ƒ d k r� Pq� q� Wt ƒ  GHnîg  } g  } t j ƒ  } d  } x¯ |  D]§ } t j j | ƒ r$| j | ƒ } | j d k rÿ| j | ƒ | j | j d d | ƒ ƒ qC| j d k rC| j | j ƒ qCqœ| j d | ƒ } | j | ƒ qœWt j d | ƒ } | j ƒ  } | j j } t | ƒ d k  r�| ƒ  n  t  j j d | ƒ } | j } | j j  rÄ| j! ƒ  n  | j j" d  t# j$ d f k rd j | j ƒ GHt% j& j | j d t ƒ ƒ nS | j j" d k ret  j' j( j' ƒ  } | j) d | j* ƒ | d <| j+ d t% j& ƒ n  d  S(   Niÿÿÿÿ(   t   file_readerc              s   t  d ˆ  ƒ ‚ d  S(   Nsx   %s file1.pdb file2.pdb [...]

or define the environment variable
  PDB_MIRROR_PDB
to join all fragment files in the PDB.(   R   (    (   t   command_name(    sX   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/pdb.join_fragment_files.pyt   usage   s    i    s
   --exerciset   PDB_MIRROR_PDBs   PDB code group:t
   file_namesi   i   s   pdb%s.ent.gzs	   %s_%s.pdbs
     writing:t   ws   
t
   append_endt   pdbt   args   model_file="%s"t   philt   sourcesi   t   mmcift   crystal_symmetryt   combinedt   out(,   t   iotbxR   t   lent   ost   environt   gett   NoneR
   t   pdb_codes_fragment_filest
   splitlinest   splitt   join_fragment_filest   patht   joint   joinedt   opent   infot   writet   as_pdb_stringt   TrueR   t   master_philt!   command_line_argument_interpretert   isfilet   any_filet	   file_typet   appendt   processt   file_objectt   fetcht   extractt
   model_filet   reset_atom_serialt   atoms_reset_serialt   formatt   libtbxt   Autot   syst   stdoutt   cift   modelt   as_cif_blockR   t   show(   t   argsR   R   R   t   pdb_mirror_pdbt   linet   codest   codeR   t   file_name_outR   R   R   t   interpretert   input_file_typeR   t
   input_filet   arg_philt	   work_philt   work_paramst   resultt
   cif_object(    (   R   sX   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/pdb.join_fragment_files.pyt   run   sh    ! 	9	   
		t   __main__i   (   t
   __future__R    t	   iotbx.pdbR   t   iotbx.cif.modelt
   iotbx.philR2   t   libtbx.utilsR   R   R4   R   R   t   parseR$   RH   t   __name__t   argv(    (    (    sX   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/command_line/pdb.join_fragment_files.pyt   <module>   s   	
	>