
:>"^«	  ã               @   s<   d  Z  d d l m Z Gd d „  d e ƒ Z d d „  Z d S)a  Handle the SCOP DOMain file.

The DOM file has been officially deprecated. For more information see
the SCOP"release notes.":http://scop.berkeley.edu/release-notes-1.55.html
The DOM files for older releases can be found
"elsewhere at SCOP.":http://scop.mrc-lmb.cam.ac.uk/scop/parse/
é   )ÚResiduesc               @   s=   e  Z d  Z d Z d d d „ Z d d „  Z d d „  Z d S)	ÚRecordzúHolds information for one SCOP domain.

    Attribues:
     - sid - The SCOP ID of the entry, e.g. d1anu1
     - residues - The domain definition as a Residues object
     - hierarchy - A string specifying where this domain is in the hierarchy.

    Nc             C   s2   d |  _  g  |  _ d |  _ | r. |  j | ƒ d S)zInitialize the class.Ú N)ÚsidÚresiduesÚ	hierarchyÚ_process)ÚselfÚline© r   ú1/tmp/pip-build-ww9dw3qa/biopython/Bio/SCOP/Dom.pyÚ__init__   s
    			zRecord.__init__c             C   st   | j  ƒ  } | j d ƒ } t | ƒ d k r= t d | ƒ ‚ | \ |  _ } } |  _ t | ƒ |  _ | |  j _ d S)zƒParse DOM records (PRIVATE).

        Records consist of 4 tab deliminated fields;
        sid, pdbid, residues, hierarchy
        ú	é   z#I don't understand the format of %sN)	ÚrstripÚsplitÚlenÚ
ValueErrorr   r   r   r   Úpdbid)r	   r
   Úcolumnsr   Úresr   r   r   r   $   s    zRecord._processc             C   sY   g  } | j  |  j ƒ | j  t |  j ƒ j d d ƒ ƒ | j  |  j ƒ d j | ƒ d S)z;Represent the SCOP domain record as a tab-separated string.ú r   Ú
)Úappendr   Ústrr   Úreplacer   Újoin)r	   Úsr   r   r   Ú__str__9   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)zoIterate over a DOM file as a Dom record for each line.

    Arguments:
     - handle -- file-like object.

    ú#N)Ú
startswithr   )Úhandler
   r   r   r   ÚparseB   s    r&   N)r"   r   Úobjectr   r&   r   r   r   r   Ú<module>   s   0