ó
ª Ic           @   sl   d  Z  d d l Td d d „  ƒ  YZ d d d „  ƒ  YZ d d d „  ƒ  YZ d	 „  Z d
 e f d „  ƒ  YZ d S(   st   Handle the SCOP CLAssification file, which describes SCOP domains.

The file format is described in the scop
"release notes.":http://scop.mrc-lmb.cam.ac.uk/scop/release-notes.html
The latest CLA file can be found
"elsewhere at SCOP.":http://scop.mrc-lmb.cam.ac.uk/scop/parse/
  
"Release 1.73": http://scop.mrc-lmb.cam.ac.uk/scop/parse/dir.cla.scop.txt_1.73
(July 2008)

iÿÿÿÿ(   t   *t   Recordc           B   s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s÷  Holds information for one SCOP domain

    sid         --  SCOP identifier. e.g. d1danl2

    residues    --  The domain definition as a Residues object

    sccs        --  SCOP concise classification strings.  e.g. b.1.2.1

    sunid       --  SCOP unique identifier for this domain

    hierarchy   --  A sequence of tuples (nodetype, sunid) describing the
                    location of this domain in the SCOP hierarchy.
                    See the Scop module for a description of nodetypes.
    c         C   sG   d |  _  d  |  _ d |  _ d |  _ g  |  _ | rC |  j | ƒ n  d  S(   Nt    (   t   sidt   Nonet   residuest   sccst   sunidt	   hierarchyt   _process(   t   selft   line(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyt   __init__&   s    					c   	      C   sã   | j  ƒ  } | j d ƒ } t | ƒ d k r@ t d | ƒ ‚ n  | \ |  _ } } |  _ |  _ } t | ƒ |  _ | |  j _	 t
 |  j ƒ |  _ xN | j d ƒ D]= } | j d ƒ \ } } t
 | ƒ } |  j j | | g ƒ qž Wd  S(   Ns   	i   s#   I don't understand the format of %st   ,t   =(   t   rstript   splitt   lent
   ValueErrorR   R   R   t   ResiduesR   t   pdbidt   intR   t   append(	   R
   R   t   columnsR   R   R   t   htt   keyt   value(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyR	   /   s    !c         C   s»   g  } | j  |  j ƒ | t |  j ƒ j d ƒ 7} | j  |  j ƒ | j  |  j ƒ g  } x0 |  j D]% } | j  d j t	 t | ƒ ƒ ƒ qb W| j  d j | ƒ ƒ d j t	 t | ƒ ƒ d S(   Nt    R   R   s   	s   
(
   R   R   t   strR   R   R   R   R   t   joint   map(   R
   t   st   hR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyt   __str__?   s    #N(   t   __name__t
   __module__t   __doc__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/SCOP/Cla.pyR      s   		t   Iteratorc           B   s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s   Iterates over a CLA file.
    c         C   s{   d d l  } | j d t ƒ d d l m } m } t | ƒ | k	 re t | ƒ | k	 re t d ƒ ‚ n  | |  _ | |  _	 d S(   s  Create an object that iterates over a CLA file.

        handle -- file-like object.

        parser -- an optional Parser object to chang the results into
                  another form.  If set to None, then the raw contents
                  of the file will be returned.

        iÿÿÿÿNsM   Bio.SCOP.Cla.Iterator is deprecated. Please use Bio.SCOP.Cla.parse() instead.(   t   FileTypet   InstanceTypes,   I expected a file handle or file-like object(
   t   warningst   warnt   DeprecationWarningt   typesR&   R'   t   typet	   TypeErrort   _handlet   _parser(   R
   t   handlet   parserR(   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/SCOP/Cla.pyR   P   s    
$	c         C   sW   x1 |  j  j ƒ  } | s d S| d d k r Pq q W|  j d k	 rS |  j j | ƒ S| S(   s   Retrieve the next CLA record.i    t   #N(   R.   t   readlineR   R/   t   parse(   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/SCOP/Cla.pyt   nextb   s      c         C   s   t  |  j d  ƒ S(   N(   t   iterR5   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/SCOP/Cla.pyt   __iter__l   s    N(   R"   R#   R$   R   R   R5   R7   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyR%   M   s   	
t   Parserc           B   s    e  Z d  Z d „  Z d „  Z RS(   s(   Parses tab-deliminated CLA records.
    c         C   s    d d  l  } | j d t ƒ d  S(   Niÿÿÿÿsº   Bio.SCOP.Cla.Parser is deprecated.
        Instead of

        parser = Cla.Parser()
        record = parser.parse(entry)

        please use

        record = Cla.Record(entry)
        (   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/SCOP/Cla.pyR   s   s    	c         C   s
   t  | ƒ S(   s   Returns a Cla Record (   R   (   R
   t   entry(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyR4   €   s    (   R"   R#   R$   R   R4   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyR8   p   s   	c         c   s5   x. |  D]& } | j  d ƒ r" q n  t | ƒ Vq Wd S(   s‰   Iterates over a CLA file, returning a Cla record for each line
    in the file.

    Arguments:

        handle -- file-like object.
    R2   N(   t
   startswithR   (   R0   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyR4   …   s    t   Indexc           B   s    e  Z d  Z d „  Z d „  Z RS(   sX   A CLA file indexed by SCOP identifiers, allowing rapid
       random access into a file.c         C   sž   t  j |  ƒ | |  _ t |  j ƒ } zg d } xZ t rŠ | j ƒ  } | sM Pn  t | ƒ } | j } | d k r{ | |  | <n  | j	 ƒ  } q1 WWd | j
 ƒ  Xd S(   sN   
        Arguments:
        
          filename  -- The file to index
        i    N(   t   dictR   t   filenamet   opent   TrueR3   R   R   R   t   tellt   close(   R
   R=   t   ft   positionR   t   recordR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyR   –   s    		 	c         C   s\   t  j |  | ƒ } t |  j ƒ } z) | j | ƒ | j ƒ  } t | ƒ } Wd | j ƒ  X| S(   s'    Return an item from the indexed file. N(   R<   t   __getitem__R>   R=   t   seekR3   R   RA   (   R
   R   RC   RB   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/SCOP/Cla.pyRE   ¬   s    (   R"   R#   R$   R   RE   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Cla.pyR;   “   s   	N(    (    (    (   R$   R   R   R%   R8   R4   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/SCOP/Cla.pyt   <module>   s   
6#	