o
    Rŀg                     @   s    d Z G dd deZdd ZdS )aZ  Code to parse the keywlist.txt file from SwissProt/UniProt.

See:
 - https://www.uniprot.org/docs/keywlist.txt

Classes:
 - Record            Stores the information about one keyword or one category
   in the keywlist.txt file.

Functions:
 - parse             Parses the keywlist.txt file and returns an iterator to
   the records it contains.

c                   @   s   e Zd ZdZdd ZdS )Recorda  Store information of one keyword or category from the keywords list.

    This record stores the information of one keyword or category in the
    keywlist.txt as a Python dictionary. The keys in this dictionary are
    the line codes that can appear in the keywlist.txt file::

        ---------  ---------------------------     ----------------------
        Line code  Content                         Occurrence in an entry
        ---------  ---------------------------     ----------------------
        ID         Identifier (keyword)            Once; starts a keyword entry
        IC         Identifier (category)           Once; starts a category entry
        AC         Accession (KW-xxxx)             Once
        DE         Definition                      Once or more
        SY         Synonyms                        Optional; once or more
        GO         Gene ontology (GO) mapping      Optional; once or more
        HI         Hierarchy                       Optional; once or more
        WW         Relevant WWW site               Optional; once or more
        CA         Category                        Once per keyword entry; absent
                                                   in category entries

    c                 C   s    t |  dD ]}g | |< qdS )zInitialize the class.DESYGOHIWWN)dict__init__)selfkeyword r   J/var/www/html/myenv/lib/python3.10/site-packages/Bio/SwissProt/KeyWList.pyr	   -   s   

zRecord.__init__N)__name__
__module____qualname____doc__r	   r   r   r   r   r      s    r   c                 c   s    t  }| D ]$}|dr|dd  |d<  n|dr*|dd  |d<  nq| D ][}|dr6 nS|dd }|d	krYd
|d |d< d
|d |d< |V  t  }q-|dd dkr|dd  }|dv rr|||< q-|dv r~|| | q-td|  dq-| D ]}qdS )zParse the keyword list from file handle.

    Returns a generator object which yields keyword entries as
    Bio.SwissProt.KeyWList.Record() object.
    zID      NIDzIC   ICz%-------------------------------------   z// r   r   z   )r   r   ACCAr   zCannot parse line '')r   
startswithstripjoinappend
ValueError)handlerecordlinekeyvaluer   r   r   parse4   s<   



	r$   N)r   r   r   r$   r   r   r   r   <module>   s   