
    Xf                     n    d Z d Zd Z G d d          Z G d d          Zd Zd Zd	 Zd
 Zd Z	d Z
dS )a  Code to work with the prosite.doc file from Prosite.

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

Tested with:
 - Release 15.0, July 1998
 - Release 16.0, July 1999
 - Release 20.22, 13 November 2007
 - Release 20.43, 10 February 2009

Functions:
 - read               Read a Prodoc file containing exactly one Prodoc entry.
 - parse              Iterates over entries in a Prodoc file.

Classes:
 - Record             Holds Prodoc data.
 - Reference          Holds data from a Prodoc reference.

c                 n    t          |           }|                                 }|rt          d          |S )z<Read in a record from a file with exactly one Prodoc record.z!More than one Prodoc record found)__readreadline
ValueError)handlerecordlines      1lib/python3.11/site-packages/Bio/ExPASy/Prodoc.pyreadr
      s8    F^^F??D ><===M    c              #   8   K   	 t          |           }|sdS |V  )z*Iterate over the records in a Prodoc file.TN)r   )r   r   s     r	   parser   %   s1       	F	r   c                       e Zd ZdZd ZdS )Recorda  Holds information from a Prodoc record.

    Attributes:
     - accession      Accession number of the record.
     - prosite_refs   List of tuples (prosite accession, prosite name).
     - text           Free format text.
     - references     List of reference objects.

    c                 >    d| _         g | _        d| _        g | _        dS zInitialize the class. N)	accessionprosite_refstext
referencesselfs    r	   __init__zRecord.__init__9   s#    	r   N__name__
__module____qualname____doc__r    r   r	   r   r   .   s-             r   r   c                       e Zd ZdZd ZdS )	ReferencezHolds information from a Prodoc citation.

    Attributes:
     - number     Number of the reference. (string)
     - authors    Names of the authors.
     - citation   Describes the citation.

    c                 0    d| _         d| _        d| _        dS r   )numberauthorscitationr   s    r	   r   zReference.__init__K   s    r   Nr   r   r   r	   r!   r!   A   s-             r   r!   c                     |                                 }|d         dk    rt          d|           |dd                             d          \  }}| j                            ||f           d S )N}z1I don't understand the Prosite reference on line
   z; )rstripr   splitr   append)r   r   accnames       r	   __read_prosite_reference_liner/   U   ss    ;;==DBx3TdTTUUUQrT
  &&IC
T{+++++r   c                 &    | xj         |z  c_         dS )NT)r   r   r   s     r	   __read_text_liner2   ]   s    
KK4KK4r   c                 6   t                      }|dd                                         |_        |d         dk    r"|dd                                          |_        n!|dd                                          |_        | j                            |           d S )Nr)      E   )r!   stripr#   r%   r$   r   r,   r   r   	references      r	   __read_reference_startr:   b   s    IAaCy((IAw#~~ "!""X^^--	 HNN,,	
Y'''''r   c                 B   |                                 sdS | j        d         }|                    d          rV|j        d         dk    r+|xj        |dd                                          z  c_        n|xj        |dd          z  c_        dS t          d|           )	NFr'   z     ,r6      Tz&I don't understand the reference line
)r7   r   
startswithr$   r*   r%   	Exceptionr8   s      r	   __read_reference_liner@   o   s    ::<< u!"%Iw R C''abb!2!22$qrr(*t
DdDD
E
EEr   c                 4    |                     d          rdS dS )N+----FT)r>   r1   s     r	   __read_copyright_linerC   |   s     w u4r   c                    | D ]/}|                                 }|r|                    d          s n0d S t                      }|                    d          st          d|z            |d         dk    rt          d|           |dd         |_        | D ])}|                    d          rt          ||           ( nt          d	          |                    d
          st          d|z            t          }| D ]}|                    d          rJ|j        D ]>}|j                                         |_        |j	                                         |_	        ?|c S |d         dk    r0|d         dk    r$|d         dk    rt          ||           t          }|                    d          rt          }|r |||          sd }t          d	          )Nz//z{PDOCz$Line does not start with '{PDOC':
%sr'   r(   z"I don't understand accession line
r)   z{PSzUnexpected end of stream.z{BEGINz%Line does not start with '{BEGIN':
%sz{END}    [r4   ]r6    rB   )r*   r>   r   r   r   r/   r2   r   r%   r$   r:   r@   rC   )r   r   r   	read_liner9   s        r	   r   r      s     {{}} 	-- 	EtXXF??7## I@4GHHHBx3EtEEFFFAbDzF 6 6??5!! 	)&$7777E4555??8$$ JADHIII I ! !??7## 	!#. ? ?	%.%7%>%>%@%@	"$-$5$<$<$>$>	!!MMM!W^^Q347c>>"64000-II__W%% 	!-II 	!9VT** ! 	
0
1
11r   N)r   r
   r   r   r!   r/   r2   r:   r@   rC   r   r   r   r	   <module>rJ      s    *           &       (, , ,  

( 
( 
(
F 
F 
F  *2 *2 *2 *2 *2r   