
:>"^ž  ã               @   s,   d  Z  Gd d „  d e ƒ Z d d „  Z d S)a¬  Handle the SCOP HIErarchy files.

The SCOP Hierarchy files 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).
c               @   s=   e  Z d  Z d Z d d d „ Z d d „  Z d d „  Z d S)	ÚRecordzÍHolds information for one node in the SCOP hierarchy.

    Attributes:
     - sunid - SCOP unique identifiers of this node
     - parent - Parents sunid
     - children - Sequence of childrens sunids

    Nc             C   s2   d |  _  d |  _ g  |  _ | r. |  j | ƒ d S)zInitialize the class.Ú N)ÚsunidÚparentÚchildrenÚ_process)ÚselfÚline© r	   ú1/tmp/pip-build-ww9dw3qa/biopython/Bio/SCOP/Hie.pyÚ__init__!   s
    			zRecord.__init__c             C   sÛ   | j  ƒ  } | j d ƒ } t | ƒ d k r= t d | ƒ ‚ | \ } } } | d k rd d |  _ n t | ƒ |  _ | d k r‹ d |  _ n t | ƒ |  _ | d k r² f  |  _ n% | j d ƒ } d d „  | Dƒ |  _ d	 S)
z¢Parse HIE records (PRIVATE).

        Records consist of 3 tab deliminated fields; node's sunid,
        parent's sunid, and a list of children's sunids.
        ú	é   z#I don't understand the format of %sú-r   ú,c             S   s   g  |  ] } t  | ƒ ‘ q Sr	   )Úint)Ú.0Úxr	   r	   r
   ú
<listcomp>I   s   	 z#Record._process.<locals>.<listcomp>N)ÚrstripÚsplitÚlenÚ
ValueErrorr   r   r   r   )r   r   Úcolumnsr   r   r   r	   r	   r
   r   )   s    zRecord._processc             C   sº   g  } | j  t |  j ƒ ƒ |  j r> | j  t |  j ƒ ƒ n, |  j d k r] | j  d ƒ n | j  d ƒ |  j rœ | j  d j d d „  |  j Dƒ ƒ ƒ n | j  d ƒ d j | ƒ d S)	z0Represent the SCOP hierarchy record as a string.é    Ú0r   r   c             s   s   |  ] } t  | ƒ Vq d  S)N)Ústr)r   r   r	   r	   r
   ú	<genexpr>Y   s    z!Record.__str__.<locals>.<genexpr>r   Ú
)Úappendr   r   r   r   Újoin)r   Úsr	   r	   r
   Ú__str__K   s    		)zRecord.__str__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r!   r	   r	   r	   r
   r      s   "r   c             c   s2   x+ |  D]# } | j  d ƒ r q t | ƒ Vq Wd S)zmIterate over a HIE file as Hie records for each line.

    Arguments:
     - handle - file-like object.

    ú#N)Ú
startswithr   )Úhandler   r	   r	   r
   Úparse`   s    r)   N)r%   Úobjectr   r)   r	   r	   r	   r
   Ú<module>   s   I