
:>"^g  ã               @   sD   d  Z  d d „  Z d d „  Z Gd 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#   x t  |  ƒ } | s P| Vq Wd S)z¡Parse ENZYME records.

    This function is for parsing ENZYME files containing multiple
    records.

    Arguments:
     - handle   - handle to the file.

    N)Ú__read)ÚhandleÚrecord© r   ú6/tmp/pip-build-ww9dw3qa/biopython/Bio/ExPASy/Enzyme.pyÚparse   s
    
r   c             C   s.   t  |  ƒ } |  j ƒ  } | r* t d ƒ ‚ | S)z¥Read 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 the Prosite documentation entrie(s) that
      correspond to the enzyme (if any)
    - DR: Pointers to the Swiss-Prot protein sequence entrie(s)
      that correspond to the enzyme (if any)
    - CC: Comments

    c             C   sa   t  j |  ƒ 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   s`   |  d rN |  d r3 d |  j  j |  d |  d f Sd |  j  j |  d f Sn d |  j  j Sd  S)Nr   r   z%s (%s, %s)z%s (%s)z%s ( ))Ú	__class__Ú__name__)r   r   r   r   Ú__repr__X   s
    

zRecord.__repr__c             C   s‡   d |  d d |  d d t  |  d ƒ d |  d d	 d
 |  d d t  |  d ƒ d t  |  d ƒ d t |  d ƒ g } d j | ƒ S)Nz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__a   s    zRecord.__str__N)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r    r   r   r   r   r
   :   s   	r
   c       
      C   s‘  d  } xr|  D]j} | d  d … | d d  … j  ƒ  } } | d k r\ t ƒ  } | | d <q | d k ry | d | 7<q | d k rÔ | d rÀ | d d j d ƒ rÀ | d d d | 7<qw| d j | ƒ q | d	 k rñ | d	 | 7<q | d
 k rg| j  d ƒ j d ƒ } x_| D]D } | j d ƒ \ } } | j ƒ  | j ƒ  g }	 | d
 j |	 ƒ qWq | d k rŸ| d r’| d d | 7<qw| | d <q | d k rí| j d ƒ sÀt ‚ | d d  … j  d ƒ } | d j | ƒ q | d k r^| j d ƒ r&| d j | d d  … ƒ qw| j d ƒ rw| d rw| d d | d d  … 7<q | d k r | r | Sq q W| rt d ƒ ‚ d  S)Né   é   r   r   r   é   Ú.ú r   r   ú;ú,r   r   z	PROSITE; é	   r   z-!- é   z    é   z//zUnexpected end of streaméÿÿÿÿr.   r.   )	Úrstripr
   ÚendswithÚappendÚsplitÚstripÚ
startswithÚAssertionErrorr   )
r   r   ÚlineÚkeyÚvalueZ	pair_dataÚpairÚt1Út2Úrowr   r   r   r   r   sN    '	"
r   N)r#   r   r   r   r
   r   r   r   r   r   Ú<module>   s   8