ó
Pz/Ic           @   sé   d  d l  m Z d  d l Z d  d l m Z d  d l m Z d Z d d d „  ƒ  YZ e d k rå d  d l Z e j	 d	 Z
 e ƒ  Z e j d
 e
 ƒ Z xM e j ƒ  D]< Z e GHx. e j ƒ  D]  Z e GHd e e j ƒ  ƒ GHqº Wq¢ Wn  d S(   iÿÿÿÿ(   t   lettersN(   t
   MMCIF2Dict(   t   StructureBuilders'   mmCIF parser (partly implemented in C).t   MMCIFParserc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s5   t  | ƒ |  _ t ƒ  |  _ |  j | ƒ |  j j ƒ  S(   N(   R   t   _mmcif_dictR   t   _structure_buildert   _build_structuret   get_structure(   t   selft   structure_idt   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/MMCIFParser.pyR      s    c   4      C   s!  |  j  } | d } | d } | d } | d } t t | d ƒ } t t | d ƒ } t t | d ƒ }	 | d }
 | d	 } | d
 } | d } yF | d } | d } | d } | d } | d } | d } d } Wn t k
 rñ d } n X| j d ƒ r| d } n
 | d } d  } d  } d } |  j } | j | ƒ | j | ƒ | j	 d ƒ xòt
 d t | ƒ ƒ D]Û} | | } | | } |	 | } | | } | | } |
 | } | d k rÇd } n  | | }  | | }! | | }" | | }# | | }$ |$ d k rd }% n d }% | | k rg| } | j | ƒ |  } |  j |  ƒ \ }& }' | j | |% |' |& ƒ n@ | |  k r§|  } |  j |  ƒ \ }& }' | j | |% |' |& ƒ n  t j | | | f d ƒ }( | j |! |( |" |# | |! ƒ | d k rp| | | | | | | | | | | | f }) t t |) ƒ }* t j |* d ƒ }+ | j |+ ƒ qpqpWyÄ t | d ƒ }, t | d ƒ }- t | d ƒ }. t | d ƒ }/ t | d ƒ }0 t | d ƒ }1 t j |, |- |. |/ |0 |1 f d ƒ }2 | d  }3 |3 d d! !}3 |3 d  k rt ‚ n  | j |3 |2 ƒ Wn n Xd  S("   Ns   _atom_site.label_atom_ids   _atom_site.label_comp_ids   _atom_site.label_seq_ids   _atom_site.label_asym_ids   _atom_site.Cartn_xs   _atom_site.Cartn_ys   _atom_site.Cartn_zs   _atom_site.label_alt_ids   _atom_site.B_iso_or_equivs   _atom_site.occupancys   _atom_site.group_PDBs   _atom_site.aniso_U[1][1]s   _atom_site.aniso_U[1][2]s   _atom_site.aniso_U[1][3]s   _atom_site.aniso_U[2][2]s   _atom_site.aniso_U[2][3]s   _atom_site.aniso_U[3][3]i   i    s   _atom_site.auth_seq_idt    t   .t   HETATMt   Ht   fs   _cell.length_as   _cell.length_bs   _cell.length_cs   _cell.angle_alphas   _cell.angle_betas   _cell.angle_gammas   _symmetry.space_group_name_H-Miÿÿÿÿ(   R   t   mapt   floatt   KeyErrort   has_keyt   NoneR   t   init_structuret
   init_modelt   init_segt   xranget   lent
   init_chaint
   _get_icodet   init_residuet   numpyt   arrayt	   init_atomt
   set_anisout	   Exceptiont   set_symmetry(4   R   R	   t
   mmcif_dictt   atom_id_listt   residue_id_listt   seq_id_listt   chain_id_listt   x_listt   y_listt   z_listt   alt_listt   b_factor_listt   occupancy_listt   fieldname_listt	   aniso_u11t	   aniso_u12t	   aniso_u13t	   aniso_u22t	   aniso_u23t	   aniso_u33t
   aniso_flagt   current_chain_idt   current_residue_idt   current_model_idt   structure_buildert   it   xt   yt   zt   resnamet   chainidt   altloct   resseqt   namet
   tempfactort	   occupancyt	   fieldnamet   hetatm_flagt   icodet
   int_resseqt   coordt   ut   mapped_anisout   anisou_arrayt   at   bt   ct   alphat   betat   gammat   cellt
   spacegroup(    (    s†   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIFParser.pyR      sª    	
















	





	




	

$
	c         C   sN   | d } | t  k r2 | } t | d d !ƒ } n d } t | ƒ } | | f S(   ss   Tries to return the icode. In MMCIF files this is just part of
        resseq! In PDB files, it's a separate field.iÿÿÿÿi    R   (   R    t   int(   R   RA   t   last_resseq_charRG   RH   (    (    s†   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIFParser.pyR   x   s    
(   t   __name__t
   __module__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/MMCIFParser.pyR      s   		^t   __main__i   t   tests   Found %d residues.(    (   t   stringR    R   R   R   t   __doc__R   RW   t   syst   argvR
   t   pR   t	   structuret   get_listt   modelt   chainR   (    (    (    s†   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/MMCIFParser.pyt   <module>   s   r	