ó
"˜ÎIc           @   sŠ   d  d l  m Z d  d l m Z m Z d Z i  Z d e d <d e d <d e d	 <d
 e d <d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   PDBConstructionException(   t   Entityt   DisorderedEntityWrappers)   Residue class, used by Structure objects.i   t   Ni   t   CAi   t   Ci   t   Ot   Residuec           B   sh   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z RS(   s>   
    Represents a residue. A Residue object stores atoms.
    c         C   s8   d |  _  d |  _ | |  _ | |  _ t j |  | ƒ d  S(   Nt   Ri    (   t   levelt
   disorderedt   resnamet   segidR   t   __init__(   t   selft   idR   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/Residue.pyR      s
    				c         C   s;   |  j  ƒ  } |  j ƒ  \ } } } | | | | f } d | S(   Ns&   <Residue %s het=%s resseq=%s icode=%s>(   t   get_resnamet   get_id(   R   R   t   hetflagt   resseqt   icodet   full_id(    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyt   __repr__"   s    c         C   s»   | j  ƒ  } | j  ƒ  } | | k r= t | j ƒ  | j ƒ  ƒ St j | ƒ rY t | } n d } t j | ƒ r{ t | } n d } | rš | rš t | | ƒ S| r¤ d S| r® d St | | ƒ S(   sÁ   Sort the Atom objects.

        Atoms are sorted alphabetically according to their name, 
        but N, CA, C, O always come first.

        Arguments:
        o a1, a2 - Atom objects
        iÿÿÿÿi   N(   t   get_namet   cmpt
   get_altloct   _atom_name_dictt   has_keyt   None(   R   t   a1t   a2t   name1t   name2t   index1t   index2(    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyt   _sort*   s"    	c         C   sH   | j  ƒ  } |  j | ƒ r4 t d | |  f ƒ ‚ n  t j |  | ƒ d S(   s}   Add an Atom object.

        Checks for adding duplicate atoms, and raises a
        PDBConstructionException if so.
        s#   Atom %s defined twice in residue %sN(   R   t   has_idR    R   t   add(   R   t   atomt   atom_id(    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyR%   I   s
    c         C   s   |  j  j |  j ƒ d  S(   N(   t
   child_listt   sortR#   (   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/Residue.pyR)   U   s    c         C   s   d |  _  d S(   s   Set the disordered flag.i   N(   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/Residue.pyt   flag_disorderedX   s    c         C   s   |  j  S(   s2   Return 1 if the residue contains disordered atoms.(   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/Residue.pyt   is_disordered\   s    c         C   s   |  j  S(   N(   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/Residue.pyR   `   s    c         C   sS   |  j  ƒ  } g  } x: | D]2 } | j ƒ  r> | | j ƒ  } q | j | ƒ q W| S(   sI   
        Returns the list of all atoms, unpack DisorderedAtoms."
        (   t   get_listR+   t   disordered_get_listt   append(   R   t	   atom_listt   undisordered_atom_listR&   (    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyt   get_unpacked_listc   s    c         C   s   |  j  S(   N(   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/Residue.pyt	   get_segidp   s    (   t   __name__t
   __module__t   __doc__R   R   R#   R%   R)   R*   R+   R   R1   R2   (    (    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyR      s   										t   DisorderedResiduec           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sÅ   
    DisorderedResidue is a wrapper around two or more Residue objects. It is
    used to represent point mutations (e.g. there is a Ser 60 and a Cys 60 residue,
    each with 50 % occupancy).
    c         C   s   t  j |  | ƒ d  S(   N(   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/Residue.pyR   z   s    c         C   s;   |  j  ƒ  } |  j ƒ  \ } } } | | | | f } d | S(   Ns0   <DisorderedResidue %s het=%s resseq=%i icode=%s>(   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/Residue.pyR   }   s    c         C   s|   |  j  ƒ  } | j ƒ  d k sk | j ƒ  } | j ƒ  \ } } } | j | ƒ t d | | | | f ƒ ‚ n  | j | ƒ d  S(   Ni   s2   Blank altlocs in duplicate residue %s (%s, %i, %s)(   t   disordered_getR+   R   R   R%   R    (   R   R&   t   residueR   t   hetR   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/Residue.pyR%   ƒ   s    c         C   s%   x |  j  ƒ  D] } | j ƒ  q Wd S(   s,   Sort the atoms in the child Residue objects.N(   R-   R)   (   R   R8   (    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyR)   ‘   s    c         C   sV   | j  ƒ  } |  j ƒ  } | j | ƒ |  j | ƒ s; t ‚ | |  | <|  j | ƒ d S(   sp   Add a residue object and use its resname as key.

        Arguments:
        o residue - Residue object
        N(   R   t
   get_parentt
   set_parentt   disordered_has_idt   AssertionErrort   disordered_select(   R   R8   R   t   chain(    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyt   disordered_add–   s    
(   R3   R4   R5   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/Residue.pyR6   t   s   				N(   t   PDBExceptionsR    R   R   R5   R   R   R6   (    (    (    s‚   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Residue.pyt   <module>   s   



_