ó
@¨®Ic           @   s=  d  Z  d Z d d d „  ƒ  YZ d d d „  ƒ  YZ e d k r9d d l m Z d d	 l Z e d
 d ƒ Z e j	 d e j
 d ƒ Z e ƒ  Z e j e ƒ e j d ƒ e d d ƒ Z e j	 d e j
 d ƒ Z e j	 d e j
 d ƒ Z e d ƒ Z e j e ƒ e j e ƒ e j e ƒ e j e d d ƒe j ƒ  n  d	 S(   s   Output of PDB files.sC   %s%5i %-4s%c%3s %c%4i%c   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s
t   Selectc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s§   
    Default selection (everything) during writing - can be used as base class
    to implement selective output. This selects which entities will be written out.
    c         C   s   d S(   Ns   <Select all>(    (   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/PDBIO.pyt   __repr__   s    c         C   s   d S(   s<   
        Overload this to reject models for output.
        i   (    (   R   t   model(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/PDBIO.pyt   accept_model   s    c         C   s   d S(   s<   
        Overload this to reject chains for output.
        i   (    (   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/PDBIO.pyt   accept_chain   s    c         C   s   d S(   s>   
        Overload this to reject residues for output.
        i   (    (   R   t   residue(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/PDBIO.pyt   accept_residue!   s    c         C   s   d S(   s;   
        Overload this to reject atoms for output.
        i   (    (   R   t   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/PDBIO.pyt   accept_atom'   s    (   t   __name__t
   __module__t   __doc__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/PDBIO.pyR       s   				t   PDBIOc           B   sD   e  Z d  Z d d „ Z d d d „ Z d „  Z e ƒ  d d „ Z RS(   s  
    Write a Structure object (or a subset of a Structure object) as a PDB file.


    Example:
        >>> p=PDBParser()
        >>> s=p.get_structure("1fat", "1fat.pdb")
        >>> io=PDBIO()
        >>> io.set_structure(s)
        >>> io.save("out.pdb")
    i    c         C   s   | |  _  d S(   sy   
        @param use_model_flag: if 1, force use of the MODEL record in output.
        @type use_model_flag: int
        N(   t   use_model_flag(   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/PDBIO.pyt   __init__:   s    s     c         C   sž   | d k r d } n d } | j  ƒ  } | j ƒ  } | j ƒ  \ } } } | j ƒ  } | j ƒ  } | | | | | | | | | | | | | | |	 |
 f } t | S(   s-   
        Returns an ATOM PDB string.
        t    t   HETATMs   ATOM  (   t   get_fullnamet
   get_altloct	   get_coordt   get_bfactort   get_occupancyt   _ATOM_FORMAT_STRING(   R   R	   t   hetfieldt   segidt   atom_numbert   resnamet   resseqt   icodet   chain_idt   elementt   charget   record_typet   namet   altloct   xt   yt   zt   bfactort	   occupancyt   args(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/PDBIO.pyt   _get_atom_lineC   s    	c         C   s   | |  _  d  S(   N(   t	   structure(   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/PDBIO.pyt   set_structureX   s    c         C   s  |  j  } t | t ƒ r0 t | d ƒ } d } n | } d } t |  j ƒ d k sZ |  j rc d } n d } xš|  j j ƒ  D]‰} | j | ƒ s” qy n  d }	 d }
 | r¶ | j	 d ƒ n  x| j ƒ  D]	} | j
 | ƒ sÞ qÃ n  | j ƒ  } d } xÃ | j ƒ  D]µ } | j | ƒ sqý n  | j ƒ  \ } } } | j ƒ  } | j ƒ  } xj | j ƒ  D]\ } | j | ƒ rRd } d }	 | | | | |
 | | | | ƒ } | j	 | ƒ |
 d }
 qRqRWqý W| rÃ | j	 d ƒ qÃ qÃ W| rì|	 rì| j	 d ƒ n  | ry | j	 d ƒ qy qy W| r| j ƒ  n  d S(	   s  
        @param file: output file
        @type file: string or filehandle 

        @param select: selects which entities will be written.
        @type select: 
            select hould have the following methods:
                - accept_model(model)
                - accept_chain(chain)
                - accept_residue(residue)
                - accept_atom(atom)
            These methods should return 1 if the entity
            is to be written out, 0 otherwise.

            Typically select is a subclass of L{Select}.
        t   wi   i    s   MODEL 
s   TER
s   ENDMDL
s   END
N(   R+   t
   isinstancet
   basestringt   opent   lenR,   R   t   get_listR   t   writeR   t   get_idt   get_unpacked_listR   t   get_resnamet	   get_segidR
   t   close(   R   t   filet   selectt	   write_endt   get_atom_linet   fpt
   close_filet
   model_flagR   t   model_residues_writtenR   R   R   t   chain_residues_writtenR   R   R   R   R   R   R	   t   s(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/PDBIO.pyt   save[   sV    			(   R   R   R   R   R+   R-   R    RD   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/PDBIO.pyR   .   s
   
	t   __main__iÿÿÿÿ(   t	   PDBParserNt
   PERMISSIVEi   t   tests   out1.pdbs   out2.pdbR.   t   test1t   test2i   R<   (    (    (   R   R   R    R   R   t   Bio.PDB.PDBParserRF   t   syst   pt   get_structuret   argvRC   t   ioR-   RD   R1   R>   t   s1t   s2R9   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/PDBIO.pyt   <module>   s(   "t	