B
    ‰°b–  ã               @   s   d Z G dd„ dƒ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   s$   d| _ d| _g | _|r |  |¡ dS )zInitialize the class.Ú N)ÚsunidÚparentÚchildrenÚ_process)ÚselfÚline© r	   ú+lib/python3.7/site-packages/Bio/SCOP/Hie.pyÚ__init__!   s
    zRecord.__init__c             C   s–   |  ¡ }| d¡}t|ƒdkr*td| ƒ‚|\}}}|dkrDd| _n
t|ƒ| _|dkr^d| _n
t|ƒ| _|dkrxd| _n| 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   r	   ú,c             S   s   g | ]}t |ƒ‘qS r	   )Ú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 }|  t| jƒ¡ | jr,|  t| jƒ¡ n | jdkrB|  d¡ n
|  d¡ | jrp|  d dd„ | jD ƒ¡¡ n
|  d¡ d |¡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__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r!   r	   r	   r	   r
   r      s   
"r   c             c   s(   x"| D ]}|  d¡rqt|ƒV  qW dS )zmIterate over a HIE file as Hie records for each line.

    Arguments:
     - handle - file-like object.

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