B
    ‰°b÷  ã               @   s2   d Z ddlZe d¡Ze d¡ZG dd„ dƒZdS )z.A collection of residues from a PDB structure.é    Nz^(\w\w\w\w)(?:$|\s+|_)(.*)z \(?(\w:)?(-?\w*)-?(-?\w*)\)?(.*)c               @   s*   e Zd ZdZd	dd„Zdd„ Zdd„ ZdS )
ÚResiduesaà  A collection of residues from a PDB structure.

    This class provides code to work with SCOP domain definitions. These
    are concisely expressed as one or more chain fragments. For example,
    "(1bba A:10-20,B:)" indicates residue 10 through 20 (inclusive) of
    chain A, and every residue of chain B in the pdb structure 1bba. The pdb
    id and brackets are optional. In addition "-" indicates every residue of
    a pbd structure with one unnamed chain.

    Start and end residue ids consist of the residue sequence number and an
    optional single letter insertion code. e.g. "12", "-1", "1a", "1000"


    pdbid -- An optional PDB id, e.g. "1bba"

    fragments -- A sequence of tuples (chainID, startResID, endResID)

    Nc             C   s"   d| _ d| _|dk	r|  |¡ dS )zInitialize the class.Ú © N)ÚpdbidÚ	fragmentsÚ_parse)ÚselfÚstrr   r   ú0lib/python3.7/site-packages/Bio/SCOP/Residues.pyÚ__init__$   s    zResidues.__init__c       	      C   sò   |  ¡ }t |¡}|d k	r0| d¡| _| d¡}|dksH|dksH|dkrLd S g }x’| d¡D ]„}t |¡}|d kr~td| ƒ‚| ¡ \}}}}|dkr¢td| ƒ‚|rÌ|d d	kr¾td
| ƒ‚|d d… }nd}| 	|||f¡ q\W t
|ƒ| _d S )Né   é   r   ú-z(-)ú,z#I don't understand the format of %séÿÿÿÿú:z"I don't understand the chain in %s)ÚstripÚ	_pdbid_reÚmatchÚgroupr   ÚsplitÚ_fragment_reÚ
ValueErrorÚgroupsÚappendÚtupler   )	r   r	   Úmr   ÚlÚchainÚstartÚendZpostfixr   r   r
   r   +   s,    


zResidues._parsec             C   s†   d}| j r| j d }| js"|d S g }xP| jD ]F\}}}g }|rN| d| ¡ |rd| d||f ¡ | d |¡¡ q.W |d |¡ S )z/Represent the SCOP residues record as a string.r   ú r   z%s:z%s-%sr   )r   r   r   Újoin)r   ÚprefixZstrsr   r   r    Úsr   r   r
   Ú__str__K   s    
zResidues.__str__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r%   r   r   r   r
   r      s   
 r   )r)   ÚreÚcompiler   r   r   r   r   r   r
   Ú<module>   s   

