ó
°áåHc           @   sg  d  d l  Z d  d l Z d  d l m Z d Z d e f d „  ƒ  YZ e d k rcd  d l Z e	 e j
 ƒ d k ry d GHn  e j
 d	 Z e e ƒ Z d
 Z d GHxÃ e d k r_e d ƒ Z e d k rÑ e j ƒ  n  e d k rÿ x e j ƒ  D] Z e GHqê Wq  n  yD e e Z e e ƒ e g  ƒ k r=x e D] Z e GHq+Wn e GHWq  e k
 r[d GHq  Xq  Wn  d S(   iÿÿÿÿN(   t   UserDicts%   Turn an mmCIF file into a dictionary.t
   MMCIF2Dictc           B   sM   e  Z d  Z d Z d Z d Z d Z d Z d Z d „  Z	 d „  Z
 d	 „  Z RS(
   i   i   i   i   i   i   i   c         C   sn   i  |  _  g  |  j  d  <t j j | ƒ s7 t d ƒ ‚ n  t j j j	 j
 | ƒ |  j ƒ  t j j j	 j ƒ  d  S(   Ns   File not found.(   t   datat   Nonet   ost   patht   isfilet   IOErrort   Biot   PDBt   mmCIFt   MMCIFlext	   open_filet   _make_mmcif_dictt
   close_file(   t   selft   filename(    (    s…   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIF2Dict.pyt   __init__   s    	
c         C   s  |  j  } |  j } |  j } |  j } |  j } |  j } |  j } t j j	 j
 j } d }	 g  }
 d  } | ƒ  \ } } |  j } x| r| | k r‰|	 rSx: | | k rÒ g  } | | <|
 j | ƒ | ƒ  \ } } q™ Wd }	 d } d } t |
 ƒ } xD | d k r7| | } | d } |
 | j | ƒ | ƒ  \ } } qô W| | d k r†d GHq†qù| ƒ  \ } } | | | <| d k  r€d GHqùd  } np | | k rªd }	 g  }
 d  } nO | | k rÔ| d | | d d !<d  } n% d GH| G| GH| d  j | ƒ d  } | d  k r~ | ƒ  \ } } q~ q~ Wd  S(	   Ni    i   i   s,   ERROR: broken name-data pair (data missing)!i   s2   ERROR: broken name-data pair (name-non data pair)!i   s,   ERROR: broken name-data pair (missing name)!(   t   NAMEt   LOOPt   DATAt
   SEMICOLONSt   DOUBLEQUOTEDt   QUOTEDt   SIMPLER   R	   R
   R   t	   get_tokenR   R   t   appendt   len(   R   R   R   R   R   R   R   R   R   t	   loop_flagt	   temp_listt   current_namet   tokent   valuet
   mmcif_dictt   new_listt   data_countert   post	   nr_fieldst
   next_tokenR   (    (    s…   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIF2Dict.pyR   "   sb    									


				c         C   s   |  j  | S(   N(   R   (   R   t   key(    (    s…   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIF2Dict.pyt   __getitem__r   s    (   t   __name__t
   __module__R   R   R   R   R   R   R   R   R   R(   (    (    (    s…   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIF2Dict.pyR      s   		Pt   __main__i   s"   Usage: python MMCIF2Dict filename.i   t    s8   Now type a key ('q' to end, 'k' for a list of all keys):t   qs   MMCIF dictionary key ==> t   ks   No such key found.(   t   os.pathR   t   Bio.PDB.mmCIF.MMCIFlexR   R    t   __doc__R   R)   t   sysR   t   argvR   R!   t   inputt	   raw_inputt   exitt   keysR'   R    t   typet   itemt   KeyError(    (    (    s…   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIF2Dict.pyt   <module>   s8   i	
	