o
    Rŀg                     @   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 )
RecordzHolds information for one node in the SCOP hierarchy.

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

    Nc                 C   s(   d| _ d| _g | _|r| | dS dS )zInitialize the class. N)sunidparentchildren_process)selfline r	   @/var/www/html/myenv/lib/python3.10/site-packages/Bio/SCOP/Hie.py__init__!   s   zRecord.__init__c                 C   s   |  }|d}t|dkrtd| |\}}}|dkr#d| _nt|| _|dkr0d| _nt|| _|dkr>d| _d
S |d}dd	 |D | _d
S )zParse 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 -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r!| d n| d | jr8| 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)strr   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__r   )__name__
__module____qualname____doc__r   r   r#   r	   r	   r	   r
   r      s
    
	"r   c                 c   s&    | D ]}| drqt|V  qd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'   r   r+   r	   r	   r	   r
   <module>   s   I