
:>"^Æ  ã               @   s,   d  Z  Gd d „  d e ƒ 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   sD   d |  _  d |  _ d |  _ d |  _ d |  _ | r@ |  j | ƒ d S)zInitialize the class.Ú N)ÚsunidÚnodetypeÚsccsÚnameÚdescriptionÚ_process)ÚselfÚline© r   ú1/tmp/pip-build-ww9dw3qa/biopython/Bio/SCOP/Des.pyÚ__init__   s    					zRecord.__init__c             C   s‰   | j  ƒ  } | j d ƒ } t | ƒ d k r= t d | ƒ ‚ | \ } |  _ |  _ |  _ |  _ |  j d k rv d |  _ 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   s‰   g  } | j  |  j ƒ | j  |  j ƒ | j  |  j ƒ |  j rR | j  |  j ƒ n | j  d ƒ | j  |  j ƒ d j 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__)Ú__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 DES file as a Des record for each line.

    Arguments:
     - handle - file-like object

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