o
    Rŀg                     @   s0   d Z dd Zdd ZG dd deZdd Zd	S )
a+  Parse the enzyme.dat file from Enzyme at ExPASy.

See https://www.expasy.org/enzyme/

Tested with the release of 03-Mar-2009.

Functions:
 - read       Reads a file containing one ENZYME entry
 - parse      Reads a file containing multiple ENZYME entries

Classes:
 - Record     Holds ENZYME data.

c                 c   s    	 t | }|s
dS |V  q)zParse ENZYME records.

    This function is for parsing ENZYME files containing multiple
    records.

    Arguments:
     - handle   - handle to the file.

    TN)__read)handlerecord r   E/var/www/html/myenv/lib/python3.10/site-packages/Bio/ExPASy/Enzyme.pyparse   s   
r   c                 C   s    t | }|  }|rtd|S )zRead one ENZYME record.

    This function is for parsing ENZYME files containing
    exactly one record.

    Arguments:
     - handle   - handle to the file.

    z!More than one ENZYME record found)r   read
ValueError)r   r   	remainderr   r   r   r   (   s
   
r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	Recorda  Holds information from an ExPASy ENZYME record as a Python dictionary.

    Each record contains the following keys:

    - ID: EC number
    - DE: Recommended name
    - AN: Alternative names (if any)
    - CA: Catalytic activity
    - CF: Cofactors (if any)
    - PR: Pointers to any Prosite documentation entries that correspond to the
      enzyme
    - DR: Pointers to any Swiss-Prot protein sequence entries that correspond
      to the enzyme
    - CC: Comments

    c                 C   sN   t |  d| d< d| d< g | d< d| d< d| d< g | d< g | d< g | d	< d
S )zInitialize the class. IDDEANCACFCCPRDRN)dict__init__selfr   r   r   r   L   s   
zRecord.__init__c                 C   sX   | d r%| d r| j j d| d  d| d  dS | j j d| d  dS | j j dS )z@Return the canonical string representation of the Record object.r   r   z (z, )z ( ))	__class____name__r   r   r   r   __repr__X   s
   "zRecord.__repr__c                 C   sr   d| d  d| d  dt | d  d| d  d	 d
| d  dt | d  dt | d  dt| d  g}d|S )z=Return a readable string representation of the Record object.zID: r   zDE: r   zAN: r   zCA: 'r   'zCF: r   zCC: r   zPR: r   zDR: %d Recordsr   
)reprlenjoin)r   outputr   r   r   __str__b   s   




zRecord.__str__N)r   
__module____qualname____doc__r   r   r"   r   r   r   r   r
   :   s
    
r
   c           
      C   s  d }| D ]}|d d |dd    }}|dkr!t }||d< q|dkr.|d  |7  < q|dkrT|d rL|d d dsL|d d  d| 7  < q|d | q|d	kra|d	  |7  < q|d
kr| dd}|D ]}|d\}}| | g}	|d
 |	 qoq|dkr|d r|d  d| 7  < q||d< q|dkr|dsJ |dd   d}|d | q|dkr|dr|d |dd   q|dr|d r|d d  |dd  7  < q|dkr|r|  S qq|rtdd S )N      r   r   r   . r   r   ;,r   r   z	PROSITE; 	   r   z-!-    z       z//zUnexpected end of stream)rstripr
   endswithappendsplitstrip
startswithr   )
r   r   linekeyvalue	pair_datapairt1t2rowr   r   r   r   t   sV   


r   N)r%   r   r   r   r
   r   r   r   r   r   <module>   s
   :