ó
˜™xTc           @   sv  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 d d d d	 d
 d d d d d g Z i d d g d 6d d d d d d d d g d 6d d g d 6d d d d d d g d 6d d g d 6d d d  g d 6d d d g d 6d! d" d# d	 d$ g d	 6d g d 6d% d g d 6d d& d' d( g d 6d g d 6d d) d* g d 6d
 g d
 6d+ d, d- d. g d+ 6d/ g d/ 6d0 g d0 6d1 g d2 6Z	 d1 d3 d4 d5 g Z
 i d6 d 6d7 d 6d8 d 6d9 d 6d: d 6d; d 6d< d	 6d= d 6d> d 6d? d 6d@ d 6dA d 6dB d
 6dC d+ 6dD d/ 6dE d0 6dF d2 6Z d d d d d d	 d d d d g
 Z d d d+ d g Z d d d d d	 d
 d d d d g
 Z dG „  Z e dH „ Z dI e f dJ „  ƒ  YZ dK „  Z dL „  Z e	 dM „ Z e dN „ Z e e e e e e e dO „ Z dP „  Z dQ e f dR „  ƒ  YZ e e e e e dS „ Z dT e f dU „  ƒ  YZ dV e f dW „  ƒ  YZ dX e f dY „  ƒ  YZ dZ „  Z  d S([   iÿÿÿÿ(   t   division(   t   SorryNt   hklt   ccp4_mapt	   xplor_mapt   pdbt   cift   philt   hhrt   alnt   seqt   xmlt   pklt   txtt   entt   mtzt   scat   cnst   xplort   cvt   reft   fobst   mmcift   fat   faat   pirt   datt   fastat   mapt   ccp4t   mrct   paramst   efft   deft   paramt   picklet   logt   htmlt   geot   alit   clustalt   imgt   osct   mccdt   cbft   smit   sdft   gzt   rosettat   Zt   bz2t   zipt   Modelt   Reflectionst
   Restraintst   Sequences	   XPLOR maps   CCP4 mapt
   Parameterst   XMLs   Python picklet   Texts   Reflections (MTZ)s   Sequence alignments   HHpred alignments   Detector imaget   SMILESs   Structure data files   Rosetta fragmentsc         C   sf   |  t  k s t |  ƒ ‚ g  t  |  D] } d | ^ q# } d t |  d j | ƒ d j | ƒ f } | S(   Ns   *.%ss   %s file (%s)|%ss   , t   ;(   t   standard_file_extensionst   AssertionErrort   standard_file_descriptionst   join(   t   formatt   extt	   wildcardst   wildcard_str(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   get_wildcard_string^   s
    !
c         C   sj   g  |  D] } t  | ƒ ^ q } | rW t j d k rG | j d d ƒ qW | j d ƒ n  d j | ƒ } | S(   Nt   darwini    s   All files (*.*)|*.*t   |(   RE   t   syst   platformt   insertt   appendR@   (   t   formatst   include_anyRA   RC   t   wildcards_str(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   get_wildcard_stringse   s    t   FormatErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyRP   o   s   c         C   s_   |  j  d ƒ s< |  j  d ƒ s< |  j  d ƒ s< |  j  d ƒ r[ d j |  j d ƒ d  ƒ }  n  |  S(   Ns   =hklf3s   =hklf4s   =amplitudess   =intensitiest    t   =iÿÿÿÿ(   t   endswithR@   t   split(   t	   file_name(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   strip_shelx_format_extensionr   s    c         C   sU   t  |  ƒ }  t j j |  ƒ \ } } | d k rK t j j | ƒ \ } } n  | | f S(   Ns   .gz(   RX   t   ost   patht   splitext(   RW   t   baseRB   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR[   x   s
    c         C   sg   t  |  ƒ \ } } | d k r" d  S| d k r2 d Sx. | j ƒ  D]  \ } } | d | k r? | Sq? Wd  S(   NRS   s   .mtzR   i   (   R[   t   Nonet	   iteritems(   RW   t
   extensionsR\   RB   t
   known_typet   known_extensions(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   guess_file_type   s    c            sD   ˆ d  k r t ‰ n  ‡ f d †  ‰  ‡  f d †  } |  j | ƒ |  S(   Nc            sQ   xJ t  ˆ  ƒ D]< \ } } t j | g  ƒ } |  d | k r t ˆ  ƒ | Sq Wd S(   Ni   i    (   t	   enumerateR=   t   gett   len(   RB   t   nRA   R_   (   t
   sort_order(    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _score_extension�   s
    c            sd   t  |  ƒ \ } } t  | ƒ \ } } ˆ  | ƒ } ˆ  | ƒ } | | k rL d S| | k r\ d Sd Sd  S(   Niÿÿÿÿi   i    (   R[   (   t   f1t   f2t   base1t   ext1t   base2t   ext2t   s1t   s2(   Rh   (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _sort“   s    (   R]   t   standard_file_typest   sort(   t
   file_namesRg   Rq   (    (   Rh   Rg   s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   sort_by_file_typeŠ   s    	c   	      C   sñ   |  } t  |  ƒ }  |  | k r3 | d k r3 d } n  t j j |  ƒ sX t d |  ƒ ‚ n• t j j |  ƒ rŒ | s t d ƒ ‚ qí t |  ƒ Sna t j j |  ƒ s­ t d ƒ ‚ n@ | d k rÂ t	 } n  | d | d | d | d | d	 | d
 | ƒ Sd S(   sÑ  
  Main input method, wrapper for any_file_input class.

  :param file_name: path to file (relative or absolute)
  :param get_processed_file: TODO
  :param valid_types: file types to consider
  :param allow_directories: process directory if given as file_name
  :param force_type: read as this format, don't try any others
  :param input_class: optional substitute for any_file_input, with additional
    parsers
  :param raise_sorry_if_errors: raise a Sorry exception if parsing fails (used
    with force_type)
  :param raise_sorry_if_not_expected_format: raise a Sorry exception if the
    file extension does not match the parsed file type
  :returns: any_file_input object, or an instance of the input_class param
  R   s   Couldn't find the file %ss3   This application does not support folders as input.s   %s is not a valid file.RW   t   get_processed_filet   valid_typest
   force_typet   raise_sorry_if_errorst"   raise_sorry_if_not_expected_formatN(
   RX   R]   RY   RZ   t   existsR   t   isdirt   directory_inputt   isfilet   any_file_input(	   RW   Rv   Rw   t   allow_directoriesRx   t   input_classRy   Rz   t   file_name_raw(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   any_file¡   s(    		c         C   s^   t  j j |  ƒ \ } } | d k rT t  j j | ƒ \ } } | d k rT | } qT n  | | f S(   Ns   .gzs   .pdbs   .ents   .cif(   s   .gz(   s   .pdbs   .ents   .cif(   RY   RZ   R[   (   RW   t	   file_baset   file_extRm   Rn   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR[   Ð   s    R   c           B   s7  e  Z d  Z e Z e Z e e d „ Z e	 d „  ƒ Z
 e	 d „  ƒ Z d „  Z e	 d „  ƒ Z e	 d „  ƒ Z e	 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 e d „ Z  d „  Z! d d d „ Z# e$ j% d „ Z& RS(   s�   
  Container for file data of any supported type.  Usually obtained via the
  any_file() function rather than being instantiated directly.
  c         C   si  | |  _  | |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ g  |  _ i  |  _	 t
 | ƒ } t j j | ƒ |  _ | |  _ t | ƒ \ } }	 |	 j ƒ  }	 | d k r-t |  d | d  ƒ }
 |
 d  k rÚ t d | ƒ ‚ q@| r#y |
 ƒ  Wq*t k
 r} t d | | t | ƒ f ƒ ‚ q*Xq@|
 ƒ  nxô | D]ì } |	 d |  j | k r4|	 d k r4t |  d | ƒ }
 |  j j | ƒ y |
 ƒ  WnŽ t k
 r¡‚  q t k
 r¹} | ‚ q t k
 r} | ró|	 d k rót d t | ƒ ƒ ‚ n  t | ƒ |  j	 | <d  |  _ d  |  _ q XPq4q4W|  j d  k r@|  j ƒ  n  |  j d  k	 re|  j |  j |  _ n  d  S(   NR]   s
   _try_as_%ss7   Couldn't force file type to '%s' - unrecognized format.s(   Couldn't read '%s' as file type '%s': %si   s   .txts   .pdbs   .mtzs   .cifs   .scas   .xmls   .phils   File format error:
(   Ns   None(   s   .txt(   s   .pdbs   .mtzs   .cifs   .scas   .xmls   .phil(   Rw   t
   _file_nameR]   t   _file_objectt
   _file_typet   _file_servert   file_descriptiont   _cached_filet   _tried_typest   _errorsRX   RY   RZ   t   getsizet	   file_sizeRv   R[   t   lowert   getattrR   t	   Exceptiont   strt   __extensions__RK   t   KeyboardInterruptRP   t   try_all_typest   __descriptions__t	   file_type(   t   selfRW   Rv   Rw   Rx   Ry   Rz   t   file_name_cleanR„   R…   t   read_methodt   eR˜   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   __init__á   sb    										 
		c         C   s   |  j  S(   N(   R†   (   R™   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyRW   $  s    c         C   s   |  j  S(   s"  
    Return a string representing the generic data type, for example 'pdb' or
    'hkl'.  Note that this is not necessarily the same as the underlying
    format, for example 'pdb' can mean either PDB or mmCIF format, and 'hkl'
    could mean MTZ, CIF, XDS, Scalepack, or SHELX format.
    (   Rˆ   (   R™   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR˜   (  s    c         C   s   | |  _  d  S(   N(   Rˆ   (   R™   R˜   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   set_file_type2  s    c         C   s   |  j  S(   s   Synonym for file_content()(   R‡   (   R™   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   file_object5  s    c         C   s   |  j  S(   sB   Return the underlying format-specific object containing file data.(   R‡   (   R™   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   file_content:  s    c      	   C   sh   d d l  m } |  j d k ra |  j d k ra | d d d t d |  j g d t j ƒ |  _ qa n  |  j S(	   sì   
    For reflection files only, returns an
    :py:class:`iotbx.reflection_file_utils.reflection_file_server` object
    containing the extracted Miller arrays.  Note that this will implicitly
    merge any non-unique observations.
    iÿÿÿÿ(   t   reflection_file_serverR   t   crystal_symmetryt   force_symmetryt   reflection_filest   errN(	   t   iotbx.reflection_file_utilsR¡   R‰   R]   Rˆ   t   TrueR‡   RH   t   stderr(   R™   R¡   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   file_server?  s    c         C   s‘   d d l  } y | j j j |  j ƒ } Wn% t k
 rO } t t | ƒ ƒ ‚ n X| j j ƒ  d k r{ t d |  j ƒ ‚ n  d |  _	 | |  _
 d S(   sJ   
    PDB parser, actually tries both 'classic' PDB and mmCIF formats.
    iÿÿÿÿNi    s&   No ATOM or HETATM records found in %s.R   (   t   iotbx.pdb.hierarchyR   t	   hierarchyt   inputRW   t
   ValueErrorR   R“   t   models_sizeRˆ   R‡   (   R™   t   iotbxt   pdb_inpRœ   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_pdbQ  s    	c         C   sY   d d l  m } | t |  j ƒ ƒ } | j ƒ  d  k	 sC t d ƒ ‚ d |  _ | |  _ d  S(   Niÿÿÿÿ(   t   any_reflection_files   Not a valid reflections file.R   (	   t   iotbx.reflection_file_readerR²   R“   RW   R˜   R]   R>   Rˆ   R‡   (   R™   R²   t   hkl_file(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_hkl_  s
    	c   
      C   s+  t  j j |  j ƒ d } | d k s+ t ‚ d d  l } d d l m } d d l m	 } | t
 |  j ƒ ƒ } | j ƒ  d  k	 r“ | |  _ d	 |  _ n” d d
 l m } d d l m } y4 | d |  j ƒ } | | | j ƒ |  _ d |  _ Wn= t k
 r&}	 | j j d |  j d t ƒ |  _ d |  _ n Xd  S(   Ni   s   .ccp4s   .imgs   .oscs   .mccdiÿÿÿÿ(   R²   (   R¡   R   (   t	   cif_input(   t   input_hierarchy_pairRW   R   t	   file_patht   strictR   (   s   .ccp4s   .imgs   .oscs   .mccd(   RY   RZ   R[   RW   R>   t	   iotbx.cifR³   R²   R¦   R¡   R“   R˜   R]   R‡   Rˆ   t   iotbx.pdb.mmcifR¶   Rª   R·   R«   R’   R   t   readert   False(
   R™   R…   R¯   R²   R¡   t   cif_fileR¶   R·   t   cif_inRœ   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_cifg  s&    	c         C   s_   d d l  m } | d |  j d t ƒ } t | j ƒ d k sI t d ƒ ‚ d |  _ | |  _ d  S(   Niÿÿÿÿ(   t   parseRW   t   process_includesi    s   Empty parameter file.R   (	   t
   iotbx.philRÁ   RW   R§   Re   t   objectsR>   Rˆ   R‡   (   R™   t
   parse_philt   phil_object(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_phil~  s
    !	c         C   s°   |  j  j d ƒ s t ‚ d d l m } | |  j  ƒ \ } } | d  k	 sV t d ƒ ‚ t | ƒ d k st t d ƒ ‚ x# | D] } d | j k s{ t ‚ q{ W| |  _ d |  _	 d  S(	   Ns   .ccp4iÿÿÿÿ(   t   any_sequence_formats   No sequence data found in file.i    s   Misformatted data in file.t   -R
   (
   RW   RU   R>   t   iotbx.bioinformaticsRÈ   R]   Re   t   sequenceR‡   Rˆ   (   R™   RÈ   RÄ   t   non_compliantt   seq_obj(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_seq…  s    	c         C   sJ   d d l  m } | |  j ƒ } | j d k s4 t ‚ | |  _ d |  _ d  S(   Niÿÿÿÿ(   t   any_hh_fileRS   R   (   RS   N(   RÊ   RÏ   RW   t   queryR]   R>   R‡   Rˆ   (   R™   RÏ   t	   hh_object(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_hhr›  s
    	c         C   s5   d d l  m } | |  j ƒ } | |  _ d |  _ d  S(   Niÿÿÿÿ(   t   any_alignment_fileR	   (   RÊ   RÓ   RW   R‡   Rˆ   (   R™   RÓ   t
   aln_object(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_aln¢  s    	c         C   sC   d d  l  } | j j j d t |  j ƒ ƒ } d |  _ | |  _ d  S(   NiÿÿÿÿRW   R   (   t   iotbx.xplor.mapR   R   R¼   R“   RW   Rˆ   R‡   (   R™   R¯   t
   map_object(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_xplor_map¨  s    !	c         C   s@   d d  l  } | j j d t |  j ƒ ƒ } d |  _ | |  _ d  S(   NiÿÿÿÿRW   R   (   t   iotbx.ccp4_mapR   t
   map_readerR“   RW   Rˆ   R‡   (   R™   R¯   R×   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_ccp4_map®  s    	c         C   s1   t  j t |  j d ƒ ƒ } d |  _ | |  _ d  S(   Nt   rbR   (   t   cPicklet   loadt   openRW   Rˆ   R‡   (   R™   t
   pkl_object(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_pkl´  s    	c         C   s:   t  |  j ƒ j ƒ  } | j d ƒ } d |  _ | |  _ d  S(   Nt   asciiR   (   Rß   RW   t   readt   decodeRˆ   R‡   (   R™   t   file_as_stringt   file_as_ascii(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_txt¹  s    	c         C   s:   d d  l  } | j j j |  j ƒ } d |  _ | |  _ d  S(   NiÿÿÿÿR   (   t   xml.dom.minidomt   domt   minidomRÁ   RW   Rˆ   R‡   (   R™   R   t   xml_in(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_xml¿  s    	c         C   s?   d d l  m } | |  j ƒ } | j ƒ  d |  _ | |  _ d  S(   Niÿÿÿÿ(   t   ImageFactoryR)   (   t   iotbx.detectorsRí   RW   Rã   Rˆ   R‡   (   R™   Rí   R)   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   _try_as_imgÅ  s
    
	c         C   s¯   x¨ |  j  D]� } | |  j k r% q
 n  t |  d | ƒ } y | ƒ  WnN t k
 rY ‚  q
 t k
 r“ } t | ƒ |  j | <d  |  _ d  |  _	 q
 q
 X|  j d  k	 r
 Pq
 q
 Wd  S(   Ns
   _try_as_%s(
   Rw   RŒ   R‘   R•   R’   R“   R�   R]   Rˆ   R‡   (   R™   t   filetypeR›   Rœ   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR–   Ì  s     		c         C   sN   |  j  d k r |  j j j ƒ  S|  j  d k rA |  j j ƒ  j ƒ  St ƒ  ‚ d S(   sl   
    Extract the crystal symmetry (if any).  Only valid for model (PDB/mmCIF)
    and reflection files.
    R   R   N(   Rˆ   R‡   R¬   R¢   R    t   NotImplementedError(   R™   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR¢   Ý  s
    c         C   sØ   d } | r¥ |  j  } | d k r5 d |  j  d } q¥ | d k rU d |  j  d } q¥ | d k ru d |  j  d	 } q¥ | d
 k r• d |  j  d	 } q¥ d |  j  } n  |  j d k r¼ d | Sd |  j |  j | f Sd S(   s<   
    Format a string containing the file type and size.
    RS   i€–˜ s
    (%.1f MB)g    €„.Ai@B s
    (%.2f MB)i † s    (%d KB)g     @�@iè  s
    (%.1f KB)s    (%d B)s   Unknown file%ss   %s%sN(   R�   Rˆ   R]   R—   (   R™   t   show_file_sizet   file_size_strR�   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt	   file_infoé  s     	c         C   sV   | d k r |  S|  j | k r# |  St d d | t |  j ƒ t |  j ƒ f ƒ ‚ d S(   sT   
    Verify that the automatically determined file type is the expected format.
    s3   Expected file type '%s' for %s, got '%s'.  This is s6   almost certainly a bug; please contact the developers.N(   R]   Rˆ   R   R“   RW   (   R™   t   expected_type(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   assert_file_type   s    c      	   C   sÕ   | d k	 rV |  j | k rÑ t d d t j |  j d ƒ t j | d ƒ f ƒ ‚ qÑ n{ t | ƒ d k sn t ‚ |  j | k rÑ t d d t j |  j d ƒ d j g  | D] } t j | d ƒ ^ q¦ ƒ f ƒ ‚ n  |  S(   s†   
    Verify that the automatically determined file type is the expected format,
    with the option to consider multiple formats.
    s6   This file format ('%s') is not supported as input for s0   this field; only files of type '%s' are allowed.t   Unknowni    s8   this field; only the following types are supported:
  %ss   
  N(   R]   Rˆ   R   R?   Rd   Re   R>   R@   (   R™   Rõ   t   multiple_formatst   f(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   check_file_type  s    	/c         C   s,  |  j  d k r | d IJn7 | d |  j IJ| d |  j  t j |  j  d ƒ f IJ|  j  d k rÃ | d t |  j j j ƒ  ƒ IJd j	 |  j j j
 ƒ  ƒ } | d k r(| d	 IJ| | IJq(ne |  j  d
 k rxS |  j j D]  } | d IJ| j d | ƒ qß Wn" |  j  d k r(|  j j | ƒ n  d S(   s:   
    Print out some basic information about the file.
    s"   File type could not be determined.s   File name: %ss   Format: %s (%s)t   unknownR   s   Atoms in file: %ds   
RS   s   Title section:R   Rù   R   N(   Rˆ   R]   RW   R?   Rd   Re   R‡   R¬   t   atomsR@   t   title_sectionR©   t   miller_arrayst   show_comprehensive_summaryt   show_summary(   R™   t   outt   titlet   array(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR   "  s"     

N(    ('   RQ   RR   t   __doc__R=   R”   R?   R—   R½   R�   t   propertyRW   R˜   Rž   RŸ   R    R©   R±   Rµ   RÀ   RÇ   RÎ   RÒ   RÕ   RØ   RÛ   Rá   Rç   Rì   Rï   R–   R¢   R§   Rô   Rö   R]   Rú   RH   t   stdoutR   (    (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR   Ø   s<   =
																	c         C   s¿   | r | d k s t ‚ t j j |  ƒ s> t d |  ƒ ‚ n} t j j |  ƒ rr | se t d ƒ ‚ q» t |  ƒ SnI t j j |  ƒ s“ t d ƒ ‚ n( | d k r¨ t	 } n  | d |  d | ƒ Sd S(   sä   
  mimics any_file, but without parsing - will instead guess the file type from
  the extension.  for most output files produced by cctbx/phenix this is
  relatively safe; for files of unknown provenance it is less effective.
  s   Couldn't find the file %ss3   This application does not support folders as input.s   %s is not a valid file.RW   Rw   N(
   R]   R>   RY   RZ   R{   R   R|   R}   R~   t   any_file_fast_input(   RW   Rv   Rw   R€   Rx   R�   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   any_file_fast9  s    	R  c           B   s   e  Z e Z e Z d  „  Z RS(   c         C   sÜ   | |  _  | |  _ d  |  _ d  |  _ d  |  _ d  |  _ t | ƒ \ } } x1 | D]) } | d |  j | k rO | |  _ qO qO W|  j d  k	 r¡ |  j	 |  j |  _ n  |  j d k rØ d t
 f d „  ƒ  Y} | | ƒ |  _ n  d  S(   Ni   R   t   fake_data_objectc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   | |  _  d  S(   N(   RB   (   R™   RB   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR�   i  s    c         S   s.   |  j  d k r d S|  j  d k r& d Sd Sd  S(   Ns   .mtzs   CCP4 MTZs   .scat	   Scalepacks   Data (other)(   RB   (   R™   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR˜   k  s
      (   RQ   RR   R�   R˜   (    (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR	  h  s   	(   Rw   RW   R]   RŸ   R˜   R©   RŠ   R[   R”   R—   t   object(   R™   RW   Rw   R„   R…   R˜   R	  (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR�   W  s    						(   RQ   RR   R=   R”   R?   R—   R�   (    (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR  T  s   R}   c           B   s   e  Z d  „  Z e d „ Z RS(   c         C   sF   | |  _  t j | ƒ |  _ d  |  _ d |  _ t j j	 | ƒ |  _
 d  S(   Nt   dir(   RW   t   dircachet   listdirRŸ   R]   R©   R˜   RY   RZ   RŽ   R�   (   R™   t   dir_name(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR�   r  s
    			c         C   s   d S(   Nt   Folder(    (   R™   Rò   (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyRô   y  s    (   RQ   RR   R�   R½   Rô   (    (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR}   q  s   	t   group_filesc           B   s   e  Z d  e d „ Z RS(   R   c         C   sJ  d d  l  } | |  _ g  |  _ g  |  _ g  |  _ g  } g  } g  } x� | D]y } t | ƒ }	 |	 | k rµ t | ƒ \ }
 } | j |
 ƒ | j t j	 j
 | ƒ ƒ |  j j | g ƒ qI | j | ƒ qI Wt | ƒ d k rë t d | ƒ ‚ n  t t | ƒ ƒ t | ƒ k rt d ƒ ‚ n  x+| D]#} t d | d t | ƒ d d | ƒ } | d k ri|  j j | ƒ q| d  k	 r›| j | ƒ } |  j | j | ƒ q| r2t j	 j
 | ƒ } t d | d | d | ƒ } | d k rí|  j j | ƒ qB| d  k	 r| j | ƒ } |  j | j | ƒ qB|  j j | ƒ q|  j j | ƒ qWd  S(	   Niÿÿÿÿi    s3   Can't find any files of the expected format ('%s').s)   Multiple files with identical root names.RW   t	   base_namet	   templatesRS   (   t	   iotbx.pdbRt   t   grouped_filest   ungrouped_filest   ambiguous_filesRb   R[   RK   RY   RZ   t   dirnameRe   R   t   sett   find_closest_base_nameR]   t   index(   R™   Rt   t   template_formatt   group_by_directoryR¯   R  t   other_filest   template_dirsRW   R˜   R\   RB   t
   group_namet   iR  (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR�   }  sX    						(   RQ   RR   R§   R�   (    (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR  |  s   c         C   sÙ   g  } x< | D]4 } |  j  | ƒ s1 | j  | ƒ r | j | ƒ q q Wt | ƒ d k r_ | d St | ƒ d k rÕ g  | D] } t j j | |  g ƒ ^ qx } t | ƒ } | j | ƒ d k rÁ d S| | j | ƒ Sn  d  S(   Ni   i    RS   (
   t
   startswithRK   Re   RY   RZ   t   commonprefixt   maxt   countR  R]   (   RW   R  R  t   groupsR\   t   gt
   prefix_lent   max_common_prefix(    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyR  ²  s    +(!   t
   __future__R    t   libtbx.utilsR   RÝ   RY   t   reRH   Rr   R=   t   compression_extensionsR?   t   supported_file_typest   binary_typest   ascii_typesRE   R§   RO   RP   RX   R[   Rb   R]   Ru   R½   Rƒ   R  R   R  R  R}   R  R  (    (    (    s?   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/file_reader.pyt   <module>   s˜    





		
		(	ÿ c6