ó
‘™xTc           @   sx   d  d l  m Z d  d l Z d  d l m Z d  d l Z d  d l Z e j	 j
 d ƒ Z d d e j d „ Z d „  Z d S(   iÿÿÿÿ(   t   divisionN(   t   SorrysX  
convert
  .short_caption = mmCIF/PDB conversion
  .caption = This tool will convert between the two supported model formats:     files in PDB format will be output as mmCIF and vice-versa.  Note that     many of the tools in Phenix support both formats, and phenix.refine can     output mmCIF files directly if desired.
  .style = auto_align box caption_img:icons/custom/phenix.pdbtools.png
{
  file_name = None
    .type = path
    .short_caption = Model file
    .style = file_type:pdb bold input_file
  output_file = None
    .type = path
    .short_caption = Output file
    .style = new_file
}
c         C   sÿ  | j  j d  k	 s t ‚ | j  j } t j j | ƒ s< t ‚ d d l m } d d  l	 } | d | ƒ } | j
 ƒ  } | j ƒ  } t j j t j j | ƒ ƒ d }	 | j d k ri| d | IJ| j j j ƒ  }
 | j  j d  k rõ |	 d | j  _ n, | j  j j d ƒ r!t d	 d
 d ƒ ‚ n  | j d | j ƒ  ƒ |
 |	 <t | j  j d ƒ } | |
 IJ| j ƒ  nŒ | j  j d  k rŽ|	 d | j  _ n, | j  j j d ƒ rºt d d d ƒ ‚ n  t | j  j d ƒ } | | j d | j ƒ  ƒ IJ| j ƒ  | j  j S(   Niÿÿÿÿ(   t   pdb_input_from_anyt	   file_namei    t   pdbs   Converting %s to mmCIF format.s   .cifs   .pdbs5   The output format is mmCIF, but the specified output sB   file name ends with .pdb.  Please use .cif or similar as the file s
   extension.t   crystal_symmetryt   wbs3   The output format is PDB, but the specified output sB   file name ends with .cif.  Please use .pdb or similar as the file (   t   convertR   t   Nonet   AssertionErrort   ost   patht   existst	   iotbx.pdbR   t	   iotbx.cift   file_contentt   construct_hierarchyt   splitextt   basenamet   file_formatt   cift   modelt   output_filet   endswithR   t   as_cif_blockR   t   opent   closet   as_pdb_string(   t   argst   paramst   outR   R   t   iotbxR   t	   pdb_inputt	   hierarchyR   t
   cif_objectt   f(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/gui_tools/cif_conversions.pyt   run   sD    "	

c         C   s™   |  j  j d  k r! t d ƒ ‚ nt |  j  j d  k	 r• t j j |  j  j ƒ \ } } t j j |  j  j ƒ \ } } | | k r• t d d d ƒ ‚ q• n  t S(   Ns   No model file specified!s7   The file extensions for the input and output files are sC   identical, but the format will change.  Please use .pdb if you are s;   converting an mmCIF file, or .cif if converting a PDB file.(	   R   R   R   R   R   R
   R   R   t   True(   R   t   baset   extt   base2t   ext2(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/gui_tools/cif_conversions.pyt   validate_paramsD   s    (    (   t
   __future__R    t
   iotbx.philR   t   libtbx.utilsR   t   os.pathR
   t   syst   philt   parset   master_philR   t   stdoutR$   R*   (    (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/gui_tools/cif_conversions.pyt   <module>   s   		%