ó
"˜ÎIc           @   s•   d  d l  Z  d Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d l m Z m Z d  d l	 m
 Z
 d	 d d
 „  ƒ  YZ d S(   iÿÿÿÿNsh   
Consumer class that builds a Structure object. This is used by 
the PDBParser and MMCIFparser classes.
(   t	   Structure(   t   Model(   t   Chain(   t   Residuet   DisorderedResidue(   t   Atomt   DisorderedAtom(   t   PDBConstructionExceptiont   StructureBuilderc           B   s˜   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d d
 „ Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s¡   
    Deals with contructing the Structure object. The StructureBuilder class is used
    by the PDBParser classes to translate a file to a Structure object.
    c         C   s   d |  _  i  |  _ d  S(   Ni    (   t   line_countert   header(   t   self(    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyt   __init__   s    	c         C   s=   | j  ƒ  } x* | D]" } | j ƒ  } | d k r d Sq Wd S(   s=   Return 1 if all atoms in the residue have a non blank altloc.t    i    i   (   t   get_unpacked_listt
   get_altloc(   R   t   residuet	   atom_listt   atomt   altloc(    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyt   _is_completely_disordered#   s    c         C   s   | |  _  d  S(   N(   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/StructureBuilder.pyt
   set_header.   s    c         C   s   | |  _  d S(   s¢   
        The line counter keeps track of the line in the PDB file that 
        is being parsed.
        
        Arguments:
        o line_counter - int
        N(   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/StructureBuilder.pyt   set_line_counter1   s    c         C   s   t  | ƒ |  _ d S(   sa   Initiate a new Structure object with given id.

        Arguments:
        o id - string
        N(   R    t	   structure(   R   t   structure_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/StructureBuilder.pyt   init_structure;   s    c         C   s&   t  | ƒ |  _ |  j j |  j ƒ d S(   sb   Initiate a new Model object with given id.
        
        Arguments:
        o id - int
        N(   R   t   modelR   t   add(   R   t   model_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/StructureBuilder.pyt
   init_modelC   s    c         C   sh   |  j  j | ƒ rB |  j  | |  _ t j j d | |  j f ƒ n" t | ƒ |  _ |  j  j |  j ƒ d S(   sc   Initiate a new Chain object with given id.

        Arguments:
        o chain_id - string
        s/   WARNING: Chain %s is discontinuous at line %i.
N(	   R   t   has_idt   chaint   syst   stderrt   writeR	   R   R   (   R   t   chain_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/StructureBuilder.pyt
   init_chainL   s    c         C   s   | |  _  d S(   sU   Flag a change in segid.
        
        Arguments:
        o segid - string
        N(   t   segid(   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/StructureBuilder.pyt   init_seg[   s    c   
      C   sÈ  | d k r( | d k r( d | } q( n  | | | f } | d k r–|  j  j | ƒ r–t j j d | | | |  j f ƒ |  j  | } | j ƒ  d k rñ | j | ƒ r¿ | |  _ | j	 | ƒ qt
 | | |  j ƒ } | j | ƒ | |  _ d Sq“|  j | ƒ s(d |  _ t d | | | | f ƒ ‚ n  |  j  j | ƒ t
 | | |  j ƒ } t | ƒ } |  j  j | ƒ | j | ƒ | j | ƒ | |  _ d Sq–n  t
 | | |  j ƒ }	 |  j  j |	 ƒ |	 |  _ d S(   s&  
        Initiate a new Residue object.

        Arguments:
        o resname - string, e.g. "ASN"
        o field - hetero flag, "W" for waters, "H" for 
            hetero residues, otherwise blank.
        o resseq - int, sequence identifier
        o icode - string, insertion code
        R   t   Ht   H_s8   WARNING: Residue ('%s', %i, '%s') redefined at line %i.
i   Ns6   Blank altlocs in duplicate residue %s ('%s', %i, '%s')(   R   R   R    R!   R"   R	   t   is_disorderedt   disordered_has_idR   t   disordered_selectR   R%   t   disordered_addR   t   NoneR   t   detach_childR   R   (
   R   t   resnamet   fieldt   resseqt   icodet   res_idt   duplicate_residuet   new_residuet   disordered_residueR   (    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyt   init_residuec   sB    				
c         C   sŠ  |  j  } | d k r d S| j | ƒ rv | | }	 |	 j ƒ  }
 |
 | k rv | } t j j d |
 | |  j f ƒ qv n  t | | | | | | | ƒ } |  _	 | d k ry| j | ƒ rF| | }	 |	 j
 ƒ  d k râ |	 j | ƒ qv| j | ƒ t | ƒ } | j | ƒ | j | ƒ | j |	 ƒ | j ƒ  t j j d |  j ƒ q†t | ƒ } | j | ƒ | j | ƒ | j ƒ  n | j | ƒ d S(   s  
        Initiate a new Atom object.

        Arguments:
        o name - string, atom name, e.g. CA, spaces should be stripped
        o coord - Numeric array (Float0, size 3), atomic coordinates
        o b_factor - float, B factor
        o occupancy - float
        o altloc - string, alternative location specifier
        o fullname - string, atom name including spaces, e.g. " CA "
        Ns@   WARNING: atom names %s and %s differ only in spaces at line %i.
R   i   sA   WARNING: disordered atom found with blank altloc before line %i.
(   R   R-   R   t   get_fullnameR    R!   R"   R	   R   R   R)   R,   R.   R   R   t   flag_disordered(   R   t   namet   coordt   b_factort	   occupancyR   t   fullnamet   serial_numberR   t   duplicate_atomt   duplicate_fullnameR   t   disordered_atom(    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyt	   init_atom    s:    	
%

c         C   s   |  j  j | ƒ d S(   s)   Set anisotropic B factor of current Atom.N(   R   t
   set_anisou(   R   t   anisou_array(    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyRD   ä   s    c         C   s   |  j  j | ƒ d S(   s?   Set standard deviation of anisotropic B factor of current Atom.N(   R   t
   set_siguij(   R   t   siguij_array(    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyRF   è   s    c         C   s   |  j  j | ƒ d S(   s8   Set standard deviation of atom position of current Atom.N(   R   t
   set_sigatm(   R   t   sigatm_array(    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyRH   ì   s    c         C   s   |  j  |  j _  |  j S(   s   Return the structure.(   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/StructureBuilder.pyt   get_structureð   s    c         C   s   d  S(   N(    (   R   t
   spacegroupt   cell(    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyt   set_symmetryø   s    N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R$   R&   R7   R-   RC   RD   RF   RH   RJ   RM   (    (    (    s‹   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureBuilder.pyR      s    				
						=D				(    (   R    RP   R    R   R   R   R   R   R   t   PDBExceptionsR   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/StructureBuilder.pyt   <module>   s   