ó
ª Ic           @   sL   d  Z  d d	 d „  ƒ  YZ d „  Z d d
 d „  ƒ  YZ d d d „  ƒ  YZ d S(   s‘   Handle the SCOP HIErarchy files, which describe the SCOP hierarchy in
terms of SCOP unique identifiers (sunid).

The file format is described in the scop
"release notes.":http://scop.berkeley.edu/release-notes-1.55.html 
The latest HIE file can be found
"elsewhere at SCOP.":http://scop.mrc-lmb.cam.ac.uk/scop/parse/
  
"Release 1.55":http://scop.berkeley.edu/parse/dir.hie.scop.txt_1.55 (July 2001)
t   Recordc           B   s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   sÄ   Holds information for one node in the SCOP hierarchy.

    sunid      -- SCOP unique identifiers of this node

    parent     --  Parents sunid

    children   -- Sequence of childrens sunids
    c         C   s5   d |  _  d |  _ g  |  _ | r1 |  j | ƒ n  d  S(   Nt    (   t   sunidt   parentt   childrent   _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/Hie.pyt   __init__   s
    			c         C   sÚ   | j  ƒ  } | j d ƒ } t | ƒ d k r@ t d | ƒ ‚ n  | \ } } } | d k rg d |  _ n t | ƒ |  _ | d k rŽ d |  _ n t | ƒ |  _ | d k rµ d |  _ n! | j d ƒ } t t | ƒ |  _ d S(	   s™   Parses HIE records.

        Records consist of 3 tab deliminated fields; node's sunid,
        parent's sunid, and a list of children's sunids.
        s   	i   s#   I don't understand the format of %st   -R   t   ,N(    (	   t   rstript   splitt   lent
   ValueErrorR   t   intR   R   t   map(   R   R   t   columnsR   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/Hie.pyR   #   s    c         C   s¼   g  } | j  t |  j ƒ ƒ |  j r> | j  t |  j ƒ ƒ n, |  j d k r] | j  d ƒ n | j  d ƒ |  j rž t t |  j ƒ } | j  d j | ƒ ƒ n | j  d ƒ d j | ƒ d S(   Ni    t   0R	   R
   s   	s   
(   t   appendt   strR   R   R   R   t   join(   R   t   st	   child_str(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Hie.pyt   __str__F   s    		N(   t   __name__t
   __module__t   __doc__t   NoneR   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/Hie.pyR       s   	#c         c   s    x |  D] } t  | ƒ Vq Wd S(   s‰   Iterates over a HIE file, returning a Hie record for each line
    in the file.

    Arguments:

        handle -- file-like object.
    N(   R    (   t   handleR   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Hie.pyt   parse\   s    t   Iteratorc           B   s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s   Iterates over a HIE 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 HIE file.

        handle -- file-like object.

        parser -- an optional Parser object to change the results into
                  another form.  If set to None, then the raw contents
                  of the file will be returned.
                  
        iÿÿÿÿNsM   Bio.SCOP.Hie.Iterator is deprecated. Please use Bio.SCOP.Hie.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   R   t   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/Hie.pyR   k   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 HIE record.i    t   #N(   R(   t   readlineR   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/Hie.pyt   next}   s      c         C   s   t  |  j d  ƒ S(   N(   t   iterR-   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/Hie.pyt   __iter__‡   s    N(   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/SCOP/Hie.pyR   h   s   	
t   Parserc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s    d d  l  } | j d t ƒ d  S(   Niÿÿÿÿsº   Bio.SCOP.Hie.Parser is deprecated.
        Instead of

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

        please use

        record = Hie.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/Hie.pyR   Œ   s    	c         C   s
   t  | ƒ S(   s   Returns a Hie 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/Hie.pyR   ™   s    (   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/Hie.pyR0   ‹   s   	N(    (    (    (   R   R    R   R   R0   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SCOP/Hie.pyt   <module>   s   I	#