ó
•™xTc           @   s5  d  d l  m Z d  d l Z d  d l m Z d  d l m Z d  d l	 m
 Z e j j d ƒ rq d  d l m Z n d 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 m  Z! d  d l" m# Z$ d  d l% m& Z& d  d l' m( Z( d  d l) Z) d „  Z* d „  Z+ e+ d „ Z, d S(   iÿÿÿÿ(   t   divisionN(   t   crystal_symmetry_from_hkl(   t   crystal_symmetry_from_reft   ccp4io(   t   crystal_symmetry_from_mtz(   t   crystal_symmetry_from_ins(   t   crystal_symmetry_from_inp(   t   crystal_symmetry_from_sdb(   t   crystal_symmetry_from_pdb(   t   crystal_symmetry_from_map(   t   crystal_symmetry_from_cif(   t   crystal(   t   canonical_pathc         C   s"  |  j  d ƒ } d	 } d	 } t | ƒ d k rD | d  } | d } n> t | ƒ d k r_ | } n# t | ƒ d k r~ | d } n d	 S| d	 k	 rÜ y# g  | D] } t | ƒ ^ q˜ } WqÜ t k
 rÇ ‚  qÜ t k
 rØ d	 SXn  y t j d | d | ƒ SWn% t k
 r‚  n t k
 rd	 SXd	 S(
   sè   
     Interprets a symmetry-string object in the following format:
     a, b, c, alpha, beta, gamma, space-group
     Please be aware that this is comma delimited, so you may not
     have commas within the space-group substring.
  t   ,i   iÿÿÿÿi   i   i    t	   unit_cellt   space_groupN(   t   splitt   Nonet   lent   floatt   KeyboardInterruptt	   ExceptionR   t   symmetry(   t   stringt   partsR   R   t   number(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/crystal_symmetry_from_any.pyt   from_string   s0    
	#  c         C   s¨   t  |  ƒ t  t j ƒ  ƒ k r" |  Sxy t t t t t t t	 t
 t t t f D]P } | d k rb qJ n  y | j |  ƒ SWqJ t k
 r‰ ‚  qJ t k
 r™ qJ XqJ Wt |  ƒ S(   s¢  
     extract_from takes a file name or a string description.
     If given a file name, it attempts to open the file with all the known
     symmetry-containing file-types and extract the symmetry information.
     If all of these fail, it attempts to interpret the input string
     according to the function cyrstal_symmetry_from_any.from_string.
     If given a crystal.symmetry it returns the crystal.symmetry.
  N(   t   typeR   R   t   from_scalepack_hklt   from_xds_hklt   from_dtrek_reft   from_mtzt   from_shelx_inst   from_cns_inpt   from_cns_sdbt   from_pdbt   from_solve_inpt   from_xplor_mapt   from_cifR   t   extract_fromR   R   R   (   t	   file_namet   fmt(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/crystal_symmetry_from_any.pyR'   5   s,    	    c         C   sÉ   t  ƒ  } x¹ |  D]± } | d  k r( q n  t j j | ƒ s@ q n  t | ƒ } | | k r^ q n  | j | ƒ y | d | ƒ } Wn$ t k
 r” ‚  q t k
 r¤ q X| d  k	 r | j	 | ƒ q q Wd  S(   NR(   (
   t   setR   t   ost   patht   isfileR   t   addR   R   t   append(   t
   file_namest   target_listt   extract_functiont   file_names_doneR(   t   crystal_symmetry(    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/crystal_symmetry_from_any.pyt   extract_and_appendQ   s$    	     (-   t
   __future__R    t   libtbx.load_envt   libtbxt   iotbx.scalepackR   R   t	   iotbx.xdsR   t   iotbx.dtrekR   R   t   envt
   has_modulet	   iotbx.mtzR   R   R   t   iotbx.shelxR   R    t	   iotbx.cnsR   R!   R   R"   t	   iotbx.pdbR   R#   t   iotbx.solveR$   t   iotbx.xplorR	   R%   t	   iotbx.cifR
   R&   t   cctbxR   t   libtbx.pathR   R+   R   R'   R5   (    (    (    sM   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/crystal_symmetry_from_any.pyt   <module>   s(   		