o
    Rŀg                     @   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ur| | dS dS )zInitialize the class.  N)pdbid	fragments_parse)selfstrr   r   E/var/www/html/myenv/lib/python3.10/site-packages/Bio/SCOP/Residues.py__init__#   s
   zResidues.__init__c           	      C   s   |  }t|}|d ur|d| _|d}|dks$|dks$|dkr&d S g }|dD ]E}t|}|d u r?td| | \}}}}|dkrRtd| |rh|d d	kratd
| |d d }nd}|	|||f q-t
|| _d S )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postfixr   r   r
   r   *   s,   


zResidues._parsec                 C   s   d}| j r
| j d }| js|d S g }| jD ]%\}}}g }|r'|| d |r3|| d|  |d| q|d| S )z/Represent the SCOP residues record as a string.r    r   r   r   )r   r   r   join)r   prefixstrsr   r   r    sr   r   r
   __str__J   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
   

