
    Ri                     f    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
  G d	 d
e
      Zy)a?  Bio.SeqIO support for the "swiss" (aka SwissProt/UniProt) file format.

You are expected to use this module via the Bio.SeqIO functions.
See also the Bio.SwissProt module which offers more than just accessing
the sequences as SeqRecord objects.

See also Bio.SeqIO.UniprotIO.py which supports the "uniprot-xml" format.
    )
SeqFeature)	SwissProt)Seq)	SeqRecord   )_TextIOSource)SequenceIteratorc                   6     e Zd ZdZdZdeddf fdZd Z xZS )SwissIteratorzDParser to break up a Swiss-Prot/UniProt file into SeqRecord objects.tsourcereturnNc                 (    t         |   |d       y)a  Iterate over a Swiss-Prot file and return SeqRecord objects.

        Arguments:
         - source - input stream opened in text mode, or a path to a file

        Every section from the ID line to the terminating // becomes
        a single SeqRecord with associated annotation and features.

        This parser is for the flat file "swiss" format as used by:
         - Swiss-Prot aka SwissProt
         - TrEMBL
         - UniProtKB aka UniProt Knowledgebase

        For consistency with BioPerl and EMBOSS we call this the "swiss"
        format. See also the SeqIO support for "uniprot-xml" format.

        Rather than calling it directly, you are expected to use this
        parser via Bio.SeqIO.parse(..., format="swiss") instead.
        r   )fmtN)super__init__)selfr   	__class__s     I/home/agent/.friday_env/lib/python3.12/site-packages/Bio/SeqIO/SwissIO.pyr   zSwissIterator.__init__    s    ( 	[1    c                    t        j                  | j                        }|t        t	        t        |j                        |j                  d   |j                  |j                  |j                        }|j                  D ]J  }t        |      dk  r|d d \  }}| d| }||j                  vs0|j                  j                  |       L |j                  }d|d<   |j                  |d<   |j                   r|j                   |d<   |j"                  r|j"                  \  }}	||d	<   |	|d
<   |j$                  r|j$                  \  }}	||d<   |	|d
<   |j&                  r|j&                  \  }}	||d<   |	|d<   |j(                  r|j(                  |d<   |j*                  j-                  d      |d<   |j.                  |d<   |j0                  |d<   |j2                  r|j2                  |d<   |j4                  r|j4                  |d<   |j6                  rdj9                  |j6                        |d<   |j:                  rg |d<   |j:                  D ]  }
t=        j>                         }dj9                  d |
j6                  D              |_         |
j:                  D ]9  \  }}|dk(  r||_!        |dk(  r||_"         |dk(  r&|dk(  r,tG        d| d       |
jH                  |_$        |
jJ                  |_%        |
jL                  |_'        |d   j                  |        |jP                  r|jP                  |j                  d <   |S )!Nr   )idnamedescriptionfeatures   :proteinmolecule_type
accessionsprotein_existencedatesequence_versiondate_last_sequence_updatedate_last_annotation_updateentry_version	gene_name.organismtaxonomy
ncbi_taxidorganism_hosthost_ncbi_taxid
comment
references c              3   &   K   | ]	  }d |z    yw)z%s=%s;N ).0k_vs     r   	<genexpr>z)SwissIterator.__next__.<locals>.<genexpr>i   s     *Xc8c>*Xs   PubMedMEDLINEDOIAGRICOLAzUnknown key z found in referenceskeywords))r   _readstreamStopIterationr   r   sequencer    
entry_namer   r   cross_referenceslendbxrefsappendannotationsr!   createdsequence_updateannotation_updater'   r)   rstriporganism_classificationtaxonomy_idhost_organismhost_taxonomy_idcommentsjoinr0   r   	Referencer/   	pubmed_id
medline_id
ValueErrorauthorstitlelocationjournalr;   )r   swiss_recordrecordcross_referencedatabase	accessiondbxrefrE   r"   version	referencefeaturekeyvalues                 r   __next__zSwissIterator.__next__6   sO    t{{3%%&&&q)(($00!**
  ,<< 	.O?#a'"1"1"5Hi z9+.FV^^+%%f-	. (('0O$$0$;$;L!))/;/M/MK+,(00MD'"&K.5K*+''(88MD'7;K34.5K*+))(::MD'9=K56+2K(!!'3'='=K$"."7"7">">s"CJ"."F"FJ$0$<$<L!%%+7+E+EK(((-9-J-JK)*  %)YY|/D/D%EK	"""(*K%)44 :	$..0"%((*XYEWEW*X"X"+"6"6 
SJCh,1)	)-2*
*(<u<P)QRR
S #,"3"3 )"+"4"4L)009#:$   -9-B-BFz*r   )	__name__
__module____qualname____doc__modesr   r   rc   __classcell__)r   s   @r   r   r      s$    NE2} 2 2,Er   r   N)rg   Bior   r   Bio.Seqr   Bio.SeqRecordr   
Interfacesr   r	   r   r3   r   r   <module>rn      s-       # % (`$ `r   