ó
<lÄIc           @   s8   d  Z  d „  Z d „  Z d d d „  ƒ  YZ d „  Z d S(   s[  
This module provides code to work with the prosite dat file from
Prosite.
http://www.expasy.ch/prosite/

Tested with:
Release 20.43, 10-Feb-2009


Functions:
read                  Reads a Prosite file containing one Prosite record
parse                 Iterates over records in a Prosite file.

Classes:
Record                Holds Prosite data.
c         c   s,   x% t  r' t |  ƒ } | s Pn  | Vq Wd S(   s‹   Parse Prosite records.

    This function is for parsing Prosite 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/Prosite.pyt   parse   s
    	c         C   s1   t  |  ƒ } |  j ƒ  } | r- t d ƒ ‚ n  | S(   s   Read one Prosite record.

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

    handle   - handle to the file.s"   More than one Prosite 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/Prosite.pyR   &   s
    t   Recordc           B   s   e  Z d  Z d „  Z RS(   sñ  Holds information from a Prosite record.

    Members:
    name           ID of the record.  e.g. ADH_ZINC
    type           Type of entry.  e.g. PATTERN, MATRIX, or RULE
    accession      e.g. PS00387
    created        Date the entry was created.  (MMM-YYYY)
    data_update    Date the 'primary' data was last updated.
    info_update    Date data other than 'primary' data was last updated.
    pdoc           ID of the PROSITE DOCumentation.
    
    description    Free-format description.
    pattern        The PROSITE pattern.  See docs.
    matrix         List of strings that describes a matrix entry.
    rules          List of rule definitions (from RU lines).  (strings)
    prorules       List of prorules (from PR lines). (strings)

    NUMERICAL RESULTS
    nr_sp_release  SwissProt release.
    nr_sp_seqs     Number of seqs in that release of Swiss-Prot. (int)
    nr_total       Number of hits in Swiss-Prot.  tuple of (hits, seqs)
    nr_positive    True positives.  tuple of (hits, seqs)
    nr_unknown     Could be positives.  tuple of (hits, seqs)
    nr_false_pos   False positives.  tuple of (hits, seqs)
    nr_false_neg   False negatives.  (int)
    nr_partial     False negatives, because they are fragments. (int)

    COMMENTS
    cc_taxo_range  Taxonomic range.  See docs for format
    cc_max_repeat  Maximum number of repetitions in a protein
    cc_site        Interesting site.  list of tuples (pattern pos, desc.)
    cc_skip_flag   Can this entry be ignored?
    cc_matrix_type
    cc_scaling_db
    cc_author
    cc_ft_key
    cc_ft_desc
    cc_version     version number (introduced in release 19.0)

    DATA BANK REFERENCES - The following are all
                           lists of tuples (swiss-prot accession,
                                            swiss-prot name)
    dr_positive
    dr_false_neg
    dr_false_pos
    dr_potential   Potential hits, but fingerprint region not yet available.
    dr_unknown     Could possibly belong

    pdb_structs    List of PDB entries.

    c         C   s  d |  _  d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ g  |  _	 g  |  _
 g  |  _ g  |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d  |  _ d  |  _ d |  _ d |  _ g  |  _ d |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ g  |  _ d  S(   Nt    (   NN(   NN(   NN(   NN(    t   namet   typet	   accessiont   createdt   data_updatet   info_updatet   pdoct   descriptiont   patternt   matrixt   rulest   prorulest   postprocessingt   nr_sp_releaset
   nr_sp_seqst   Nonet   nr_totalt   nr_positivet
   nr_unknownt   nr_false_post   nr_false_negt
   nr_partialt   cc_taxo_ranget   cc_max_repeatt   cc_sitet   cc_skip_flagt   dr_positivet   dr_false_negt   dr_false_post   dr_potentialt
   dr_unknownt   pdb_structs(   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/Prosite.pyt   __init__i   s>    																														(   t   __name__t
   __module__t   __doc__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/Prosite.pyR   5   s   3c         C   sÍ  d d  l  } d  } xŸ|  D]“} | d  | d j ƒ  } } | d k r© t ƒ  } | j d ƒ } t | ƒ d k rƒ t d | ƒ ‚ n  | d | _ | d j d	 ƒ | _ q | d
 k rÊ | j d ƒ | _	 q | d k r‚| j d	 ƒ j d ƒ } | d j
 d ƒ s*| d j
 d ƒ s*| d j
 d ƒ r=t d | ƒ ‚ n  | d j d ƒ | _ | d j d ƒ | _ | d j d ƒ | _ q | d k rš| | _ q | d k r¸| j | 7_ q | d k r×| j j | ƒ q | d k rÿ| j j | j d ƒ ƒ q | d k r| j j | ƒ q | d k rÜ| j d ƒ } xp| D]•} | sRq@n  g  | j d ƒ D] }	 |	 j ƒ  ^ qb\ }
 } |
 d k r¼| j d ƒ \ } } | | _ t | ƒ | _ q@|
 d k rÚt | ƒ | _ q@|
 d k røt | ƒ | _ q@|
 d@ k r¹| j d# | ƒ } | s;t d$ t | ƒ | f ƒ ‚ n  t t t | j  ƒ  ƒ ƒ } |
 d k rn| | _! qÕ|
 d  k r†| | _" qÕ|
 d! k rž| | _# qÕ|
 d" k rÕ| | _$ qÕq@t d% t |
 ƒ | f ƒ ‚ q@Wq | d& k r¥| j d ƒ } x²| D] } | sþ| d'  d( k r!qþn  | j% d ƒ d k r<qþn  g  | j d ƒ D] }	 |	 j ƒ  ^ qL\ }
 } |
 d) k r‚| | _& qþ|
 d* k rš| | _' qþ|
 d+ k rÚ| j d ƒ \ } } | j( j t | ƒ | f ƒ qþ|
 d, k rò| | _) qþ|
 d- k r
| | _* qþ|
 d. k r"| | _+ qþ|
 d/ k r:| | _, qþ|
 d0 k rR| | _- qþ|
 d1 k rj| | _. qþ|
 d2 k r‚| | _/ qþt d% t |
 ƒ | f ƒ ‚ qþWq | d3 k rÚ| j d ƒ } xé| D]} | sÙqÇn  g  | j d ƒ D] }	 |	 j0 ƒ  ^ qé\ } } } | d4 k r/| j1 j | | f ƒ qÇ| d5 k rT| j2 j | | f ƒ qÇ| d6 k ry| j3 j | | f ƒ qÇ| d7 k rž| j4 j | | f ƒ qÇ| d8 k rÃ| j5 j | | f ƒ qÇt d9 | ƒ ‚ qÇWq | d: k r| j ƒ  } x· | D] } | j6 j | j d ƒ ƒ qùWq | d; k rM| j d ƒ } | j7 j | ƒ q | d< k rn| j d ƒ | _8 q | d& k r€q q | d= k rœ| s˜q n  Pq t d> | ƒ ‚ q Wd  S| sÉt d? ƒ ‚ n  | S(A   Niÿÿÿÿi   i   t   IDs   ; s)   I don't understand identification line
%si    i   t   .t   ACt   ;t   DTs	   (CREATED)s   (DATA UPDATE)s   (INFO UPDATE)s   I don't understand date line
%ss
    (CREATED)s    (DATA UPDATE)s    (INFO UPDATE)t   DEt   PAt   MAt   PPt   RUt   NRt   =s   /RELEASEt   ,s
   /FALSE_NEGs   /PARTIALs   /TOTALs	   /POSITIVEs   /UNKNOWNs
   /FALSE_POSs   (\d+)\((\d+)\)s!   Broken data %s in comment line
%ss"   Unknown qual %s in comment line
%st   CCi   s   Automatic scalings   /TAXO-RANGEs   /MAX-REPEATs   /SITEs
   /SKIP-FLAGs   /MATRIX_TYPEs   /SCALING_DBs   /AUTHORs   /FT_KEYs   /FT_DESCs   /VERSIONt   DRt   Tt   Ft   Nt   Pt   ?s   I don't understand type flag %st   3Dt   PRt   DOs   //s   Unknown keyword %s founds   Unexpected end of stream.(   s   /TOTALs	   /POSITIVEs   /UNKNOWNs
   /FALSE_POS(9   t   reR   t   rstripR   t   splitt   lenR   R
   R   R   t   endswithR   R   R   R   R   R   t   appendR   t   extendR   t   lstripR   t   intR   R   R   t   matcht	   Exceptiont   reprt   tuplet   mapt   groupsR   R   R   R   t   countR    R!   R"   R#   t   cc_matrix_typet   cc_scaling_dbt	   cc_authort	   cc_ft_keyt
   cc_ft_desct
   cc_versiont   stripR$   R&   R%   R'   R(   R)   R   R   (   R   RF   R   t   linet   keywordt   valuet   colst   datest   colt   wordt   qualt   datat   releaset   seqst   mt   hitst   post   desct   refst   reft   accR
   R   t   idR   (    (    s…   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/ExPASy/Prosite.pyR   ’   s   	.	.1 N(    (   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/Prosite.pyt   <module>   s   		]