B
    ‰°b¾  ã               @   s   d Z G dd„ dƒZdd„ ZdS )a?  Handle the SCOP DEScription file.

The file format is described in the scop
"release notes.":http://scop.berkeley.edu/release-notes-1.55.html
The latest DES file can be found
"elsewhere at SCOP.":http://scop.mrc-lmb.cam.ac.uk/scop/parse/

"Release 1.55":http://scop.berkeley.edu/parse/des.cla.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 )
ÚRecorda  Holds information for one node in the SCOP hierarchy.

    Attributes:
     - sunid - SCOP unique identifiers
     - nodetype - One of 'cl' (class), 'cf' (fold), 'sf' (superfamily),
       'fa' (family), 'dm' (protein), 'sp' (species), 'px' (domain).
       Additional node types may be added.
     - sccs - SCOP concise classification strings. e.g. b.1.2.1
     - name - The SCOP ID (sid) for domains (e.g. d1anu1), currently empty for other node types
     - description - e.g. "All beta proteins","Fibronectin type III",

    Nc             C   s0   d| _ d| _d| _d| _d| _|r,|  |¡ dS )zInitialize the class.Ú N)ÚsunidÚnodetypeÚsccsÚnameÚdescriptionÚ_process)ÚselfÚline© r   ú+lib/python3.7/site-packages/Bio/SCOP/Des.pyÚ__init__   s    zRecord.__init__c             C   s^   |  ¡ }| d¡}t|ƒdkr*td| ƒ‚|\}| _| _| _| _| jdkrPd| _t|ƒ| _	dS )z˜Parse DES records (PRIVATE).

        Records consist of 5 tab deliminated fields,
        sunid, node type, sccs, node name, node description.
        ú	é   z#I don't understand the format of %sú-r   N)
ÚrstripÚsplitÚlenÚ
ValueErrorr   r   r   r   Úintr   )r	   r
   Úcolumnsr   r   r   r   r   )   s    

zRecord._processc             C   sf   g }|  | j¡ |  | j¡ |  | j¡ | jr<|  | j¡ n
|  d¡ |  | j¡ d tt|ƒ¡d S )z@Represent the SCOP description record as a tab-separated string.r   r   Ú
)	Úappendr   r   r   r   r   ÚjoinÚmapÚstr)r	   Úsr   r   r   Ú__str__A   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 DES file as a Des record for each line.

    Arguments:
     - handle - file-like object

    ú#N)Ú
startswithr   )Zhandler
   r   r   r   ÚparseO   s    

r$   N)r!   r   r$   r   r   r   r   Ú<module>   s   >