o
    Rŀg                     @   sd   d Z dd Zdd ZG dd dZG dd dZd	d
 Zdd Zdd Zdd Zdd Z	d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                 C   s    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line r   E/var/www/html/myenv/lib/python3.10/site-packages/Bio/ExPASy/Prodoc.pyread   s
   r	   c                 c   s    	 t | }|s
dS |V  q)z*Iterate over the records in a Prodoc file.TN)r   )r   r   r   r   r   parse%   s   r
   c                   @      e Zd ZdZd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                 C   s   d| _ g | _d| _g | _dS zInitialize the class. N)	accessionprosite_refstext
referencesselfr   r   r   __init__9   s   
zRecord.__init__N__name__
__module____qualname____doc__r   r   r   r   r   r   .   s    
r   c                   @   r   )	ReferencezHolds information from a Prodoc citation.

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

    c                 C   s   d| _ d| _d| _dS r   )numberauthorscitationr   r   r   r   r   K   s   
zReference.__init__Nr   r   r   r   r   r   A   s    	r   c                 C   sL   |  }|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namer   r   r   __read_prosite_reference_lineU   s
   r'   c                 C   s   |  j |7  _ dS )NT)r   r   r   r   r   r   __read_text_line]   s   r)   c                 C   sZ   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   	referencer   r   r   __read_reference_startb   s   r0   c                 C   st   |  sdS | jd }|dr3|jd dkr&| j|dd   7  _dS | j|dd  7  _dS td| )	NFr   z     ,r,      Tz&I don't understand the reference line
)r-   r   
startswithr   r"   r   	Exceptionr.   r   r   r   __read_reference_lineo   s   

r5   c                 C   s   | drdS dS )N+----FT)r3   r(   r   r   r   __read_copyright_line|   s   
r7   c                 C   sN  | D ]}|  }|r|ds nqd S t }|ds"td| |d dkr/td| |dd |_| D ]}|drEt|| q8 ntd	|d
sVtd| t}| D ]H}|drw|jD ]}|j  |_|j	  |_	qd|  S |d dkr|d dkr|d dkrt
|| t}qZ|drt}qZ|r|||sd }qZt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}    [r*   ]r,    r6   )r"   r3   r   r   r   r'   r)   r   r   r   r0   r5   r7   )r   r   r   	read_liner/   r   r   r   r      sH   




$


r   N)r   r	   r
   r   r   r'   r)   r0   r5   r7   r   r   r   r   r   <module>   s   
	