ó
DÉIc           @   s;   d  Z  d „  Z d „  Z d e f d „  ƒ  YZ d „  Z d S(   s3  
This module provides code to work with the enzyme.dat file from
Enzyme.
http://www.expasy.ch/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  r' t |  ƒ } | s Pn  | Vq Wd S(   s‰   Parse ENZYME records.

    This function is for parsing ENZYME files containing multiple
    records.

    handle   - handle to the file.N(   t   Truet   __read(   t   handlet   record(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyt   parse   s
    	c         C   s1   t  |  ƒ } |  j ƒ  } | r- t d ƒ ‚ n  | S(   s   Read one ENZYME record.

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

    handle   - handle to the file.s!   More than one ENZYME record found(   R   t   readt
   ValueError(   R   R   t	   remainder(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyR   %   s
    t   Recordc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sÚ  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(
   Nt    t   IDt   DEt   ANt   CAt   CFt   CCt   PRt   DR(   t   dictt   __init__(   t   self(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyR   F   s    






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   s   %s (%s, %s)s   %s (%s)s   %s ( )(   t	   __class__t   __name__(   R   (    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyt   __repr__Q   s    

c         C   s¬   d |  d } | d |  d 7} | d t  |  d ƒ 7} | d |  d d	 7} | d
 |  d 7} | d t  |  d ƒ 7} | d t  |  d ƒ 7} | d t |  d ƒ 7} | S(   Ns   ID: R
   s    DE: R   s    AN: R   s    CA: 'R   t   's    CF: R   s    CC: R   s    PR: R   s    DR: %d RecordsR   (   t   reprt   len(   R   t   output(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyt   __str__\   s    (   R   t
   __module__t   __doc__R   R   R   (    (    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyR   5   s   		c   
      C   sƒ  d  } xd|  D]\} | d  | d j ƒ  } } | d k rP t ƒ  } | | d <q | d k ro | d c | 7<q | d k rÌ | d r¸ | d d j d ƒ r¸ | d d c d | 7<qi| d j | ƒ q | d	 k rë | d	 c | 7<q | d
 k ra| j d ƒ j d ƒ } xW| D]D } | j d ƒ \ } } | j ƒ  | j ƒ  g }	 | d
 j |	 ƒ qWq | d k r›| d rŽ| d c d | 7<qi| | d <q | d k rã| j d ƒ s¼t ‚ | d j d ƒ } | d j | ƒ q | d k rM| j d ƒ r| d j | d ƒ qi| j d ƒ ri| d ri| d d c | d 7<qiq | d k r | r | Sq q q W| rt	 d ‚ n  d  S(   Ni   i   R
   R   R   iÿÿÿÿt   .t    R   R   t   ;t   ,R   R   s	   PROSITE; i	   R   s   -!- i   s       i   s   //s   Unexpected end of stream(
   t   Nonet   rstripR   t   endswitht   appendt   splitt   stript
   startswitht   AssertionErrorR   (
   R   R   t   linet   keyt   valuet	   pair_datat   pairt   t1t   t2t   row(    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyR   i   sN    	"

N(   R   R   R   R   R   R   (    (    (    s„   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Enzyme.pyt   <module>   s   		4