
    {Ti                     l    d Z ddlZ ej                  d      Z ej                  d      Z G d d      Zy)z.A collection of residues from a PDB structure.    Nz^(\w\w\w\w)(?:$|\s+|_)(.*)z \(?(\w:)?(-?\w*)-?(-?\w*)\)?(.*)c                   $    e Zd ZdZddZd Zd Zy)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                 H    d| _         d| _        || j                  |       yy)zInitialize the class.  N)pdbid	fragments_parse)selfstrs     D/home/agent/.local/lib/python3.12/site-packages/Bio/SCOP/Residues.py__init__zResidues.__init__#   s&    
?KK     c                    |j                         }t        j                  |      }|'|j                  d      | _        |j                  d      }|dk(  s
|dk(  s|dk(  ry g }|j                  d      D ]  }t        j                  |      }|t        d|       |j                         \  }}}}|dk7  rt        d|       |r|d   d	k7  rt        d
|       |d d }nd}|j                  |||f        t        |      | _        y )N      r   -z(-),z!I don't understand the format of :z I don't understand the chain in )strip	_pdbid_rematchgroupr   split_fragment_re
ValueErrorgroupsappendtupler	   )	r   r   mr	   fragmentchainstartendpostfixs	            r   r
   zResidues._parse*   s   iik OOC =DJ''!*C"9s
cUl			# 	2H""8,Ay #DXJ!OPP)*&E5#w"} #DXJ!OPP9#$'Gz%RSScr
eUC01!	2" y)r   c                 T   d}| j                   r| j                   dz   }| j                  s|dz   S g }| j                  D ]V  \  }}}g }|r|j                  | d       |r|j                  | d|        |j                  dj                  |             X |dj                  |      z   S )z/Represent the SCOP residues record as a string.r    r   r   r   )r   r	   r   join)r   prefixstrsr#   r$   r%   ss          r   __str__zResidues.__str__J   s    ::ZZ#%F~~C<!% 	$E5#AE7!%E7!C5)*KK
#	$ &&r   )N)__name__
__module____qualname____doc__r   r
   r-   r   r   r   r   r      s    &*@'r   r   )r1   recompiler   r   r   r   r   r   <module>r4      s;    5 	BJJ45	rzz=>K' K'r   