
    Ri1                     j    d Z  G d d      Z G d d      Z G d d      Z G d d      Zd	 Zd
 Zd Zy)a  Parse Unigene flat file format files such as the Hs.data file.

Here is an overview of the flat file format that this parser deals with:

   Line types/qualifiers::

       ID           UniGene cluster ID
       TITLE        Title for the cluster
       GENE         Gene symbol
       CYTOBAND     Cytological band
       EXPRESS      Tissues of origin for ESTs in cluster
       RESTR_EXPR   Single tissue or development stage contributes
                    more than half the total EST frequency for this gene.
       GNM_TERMINUS genomic confirmation of presence of a 3' terminus;
                    T if a non-templated polyA tail is found among
                    a cluster's sequences; else
                    I if templated As are found in genomic sequence or
                    S if a canonical polyA signal is found on
                      the genomic sequence
       GENE_ID      Entrez gene identifier associated with at least one
                    sequence in this cluster;
                    to be used instead of LocusLink.
       LOCUSLINK    LocusLink identifier associated with at least one
                    sequence in this cluster;
                    deprecated in favor of GENE_ID
       HOMOL        Homology;
       CHROMOSOME   Chromosome.  For plants, CHROMOSOME refers to mapping
                    on the arabidopsis genome.
       STS          STS
            ACC=         GenBank/EMBL/DDBJ accession number of STS
                         [optional field]
            UNISTS=      identifier in NCBI's UNISTS database
       TXMAP        Transcript map interval
            MARKER=      Marker found on at least one sequence in this
                         cluster
            RHPANEL=     Radiation Hybrid panel used to place marker
       PROTSIM      Protein Similarity data for the sequence with
                    highest-scoring protein similarity in this cluster
            ORG=         Organism
            PROTGI=      Sequence GI of protein
            PROTID=      Sequence ID of protein
            PCT=         Percent alignment
            ALN=         length of aligned region (aa)
       SCOUNT       Number of sequences in the cluster
       SEQUENCE     Sequence
            ACC=         GenBank/EMBL/DDBJ accession number of sequence
            NID=         Unique nucleotide sequence identifier (gi)
            PID=         Unique protein sequence identifier (used for
                         non-ESTs)
            CLONE=       Clone identifier (used for ESTs only)
            END=         End (5'/3') of clone insert read (used for
                         ESTs only)
            LID=         Library ID; see Hs.lib.info for library name
                         and tissue
            MGC=         5' CDS-completeness indicator; if present, the
                         clone associated with this sequence is believed
                         CDS-complete. A value greater than 511 is the gi
                         of the CDS-complete mRNA matched by the EST,
                         otherwise the value is an indicator of the
                         reliability of the test indicating CDS
                         completeness; higher values indicate more
                         reliable CDS-completeness predictions.
           SEQTYPE=      Description of the nucleotide sequence.
                         Possible values are mRNA, EST and HTC.
           TRACE=        The Trace ID of the EST sequence, as provided by
                         NCBI Trace Archive

c                   $    e Zd ZdZddZd Zd Zy)SequenceLinea  Store the information for one SEQUENCE line from a Unigene file.

    Initialize with the text part of the SEQUENCE line, or nothing.

    Attributes and descriptions (access as LOWER CASE):
     - ACC=         GenBank/EMBL/DDBJ accession number of sequence
     - NID=         Unique nucleotide sequence identifier (gi)
     - PID=         Unique protein sequence identifier (used for non-ESTs)
     - CLONE=       Clone identifier (used for ESTs only)
     - END=         End (5'/3') of clone insert read (used for ESTs only)
     - LID=         Library ID; see Hs.lib.info for library name and tissue
     - MGC=         5' CDS-completeness indicator; if present,
       the clone associated with this sequence
       is believed CDS-complete. A value greater than 511
       is the gi of the CDS-complete mRNA matched by the EST,
       otherwise the value is an indicator of the reliability
       of the test indicating CDS completeness;
       higher values indicate more reliable CDS-completeness
       predictions.
     - SEQTYPE=     Description of the nucleotide sequence. Possible values
       are mRNA, EST and HTC.
     - TRACE=       The Trace ID of the EST sequence, as provided by NCBI
       Trace Archive

    Nc                     d| _         d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        ||| _        | j                  |       yy)Initialize the class. FN)accnidlidpidcloneimageis_imageendmgcseqtypetracetext_init_from_textselfr   s     L/home/agent/.friday_env/lib/python3.12/site-packages/Bio/UniGene/__init__.py__init__zSequenceLine.__init__i   so    


DI  &     c                     |j                  d      }|D ]O  }|j                  d      \  }}|dk(  r|d d dk(  rd| _        |dd  | _        t        | |j	                         |       Q y )N; =CLONE   IMAGET   )splitr   r   setattrlowerr   r   partspartkeyvals         r   r   zSequenceLine._init_from_textz   sk    

4  	,Dzz#HCg~r7g%$(DM!$QRDJD#))+s+	,r   c                     | j                   S )z/Return UniGene SequenceLine object as a string.r   r   s    r   __repr__zSequenceLine.__repr__       yyr   N__name__
__module____qualname____doc__r   r   r+    r   r   r   r   N   s    4'",r   r   c                   $    e Zd ZdZddZd Zd Zy)ProtsimLinea|  Store the information for one PROTSIM line from a Unigene file.

    Initialize with the text part of the PROTSIM line, or nothing.

    Attributes and descriptions (access as LOWER CASE)
    ORG=         Organism
    PROTGI=      Sequence GI of protein
    PROTID=      Sequence ID of protein
    PCT=         Percent alignment
    ALN=         length of aligned region (aa)
    Nc                     d| _         d| _        d| _        d| _        d| _        ||| _        | j                  |       yyr   r   N)orgprotgiprotidpctalnr   r   r   s     r   r   zProtsimLine.__init__   sE    DI  & r   c                     |j                  d      }|D ]1  }|j                  d      \  }}t        | |j                         |       3 y )Nr   r   r    r!   r"   r#   s         r   r   zProtsimLine._init_from_text   sB    

4  	,Dzz#HCD#))+s+	,r   c                     | j                   S )z.Return UniGene ProtsimLine object as a string.r)   r*   s    r   r+   zProtsimLine.__repr__   r,   r   r-   r.   r3   r   r   r5   r5      s    
	',r   r5   c                   $    e Zd ZdZddZd Zd Zy)STSLinea;  Store the information for one STS line from a Unigene file.

    Initialize with the text part of the STS line, or nothing.

    Attributes and descriptions (access as LOWER CASE)

    ACC=         GenBank/EMBL/DDBJ accession number of STS [optional field]
    UNISTS=      identifier in NCBI's UNISTS database
    Nc                 V    d| _         d| _        ||| _        | j                  |       yyr7   )r   unistsr   r   r   s     r   r   zSTSLine.__init__   s0    DI  & r   c                     |j                  d      }|D ]1  }|j                  d      \  }}t        | |j                         |       3 y )N r   r>   r#   s         r   r   zSTSLine._init_from_text   sA    

3 	,Dzz#HCD#))+s+	,r   c                     | j                   S )z*Return UniGene STSLine object as a string.r)   r*   s    r   r+   zSTSLine.__repr__   r,   r   r-   r.   r3   r   r   rA   rA      s    ',r   rA   c                       e Zd ZdZd Zd Zy)Recordat  Store a Unigene record.

    Here is what is stored::

        self.ID           = ''  # ID line
        self.species      = ''  # Hs, Bt, etc.
        self.title        = ''  # TITLE line
        self.symbol       = ''  # GENE line
        self.cytoband     = ''  # CYTOBAND line
        self.express      = []  # EXPRESS line, parsed on ';'
                                # Will be an array of strings
        self.restr_expr   = ''  # RESTR_EXPR line
        self.gnm_terminus = ''  # GNM_TERMINUS line
        self.gene_id      = ''  # GENE_ID line
        self.locuslink    = ''  # LOCUSLINK line
        self.homol        = ''  # HOMOL line
        self.chromosome   = ''  # CHROMOSOME line
        self.protsim      = []  # PROTSIM entries, array of Protsims
                                # Type ProtsimLine
        self.sequence     = []  # SEQUENCE entries, array of Sequence entries
                                # Type SequenceLine
        self.sts          = []  # STS entries, array of STS entries
                                # Type STSLine
        self.txmap        = []  # TXMAP entries, array of TXMap entries

    c                     d| _         d| _        d| _        d| _        d| _        g | _        d| _        d| _        d| _        d| _	        d| _
        d| _        g | _        g | _        g | _        g | _        yr7   )IDspeciestitlesymbolcytobandexpress
restr_exprgnm_terminusgene_id	locuslinkhomol
chromosomeprotsimsequenceststxmapr*   s    r   r   zRecord.__init__   ss    


r   c                     d| j                   j                   d| j                   d| j                   d| j                   S )z>Represent the UniGene Record object as a string for debugging.<z> rE   )	__class__r/   rJ   rM   rL   r*   s    r   r+   zRecord.__repr__   s8    4>>**+2dggYa}Adjj\RRr   N)r/   r0   r1   r2   r   r+   r3   r   r   rH   rH      s    6&Sr   rH   c              #   2   K   	 t        |       }|sy| w)zGRead and load a UniGene records, for files containing multiple records.N)_read)handlerecords     r   parsera      s"     
v	 s   c                 p    t        |       }|st        d      | j                         }|rt        d      |S )z4Read and load a UniGene record, one record per file.zNo SwissProt record foundz$More than one SwissProt record found)r^   
ValueErrorread)r_   r`   	remainders      r   rd   rd   	  s9    6]F455I?@@Mr   c                    d}d }| D ]K  }|d | j                         ||d  j                         }}|j                         }|dk(  r5t               }||_        |j                  j                  d      d   |_        t|dk(  r||_        |dk(  r||_        |dk(  r||_        |dk(  r||_        |d	k(  r(|d
k(  rd|_	        |dk(  rd|_	        t        d|       |dk(  r4|j                  d      D cg c]  }|j                          c}|_        |dk(  r4|j                  d      D cg c]  }|j                          c}|_        G|dk(  r	||_        U|dk(  r	||_        c|dk(  r(t!        |      }|j"                  j%                  |       |dk(  rt'        |      }|dk(  r(t)        |      }	|j*                  j%                  |	       |dk(  r(t-        |      }
|j.                  j%                  |
       |dk(  r?t1        |j*                        k7  r#t        d|t1        |j*                        fz        |c S t        d|        |rt        d      y c c}w c c}w )N   rJ   .    TITLEGENEGENE_ID	LOCUSLINKHOMOLYESTNOzCannot parse HOMOL line EXPRESS|
RESTR_EXPR
CHROMOSOMECYTOBANDPROTSIMSCOUNTSEQUENCESTSz//zkThe number of sequences specified in the record (%d) does not agree with the number of sequences found (%d)zUnknown tag zUnexpected end of stream.)rstriprH   rJ   r    rK   rL   rM   rR   rS   rT   rc   striprO   rP   rU   rN   r5   rV   appendintr   rW   rA   rX   len)r_   	UG_INDENTr`   linetagvaluewordrV   scountrW   rX   s              r   r^   r^     sU   IF 23*9%,,.YZ0@0G0G0IU{{}$;XFFI#YY__S1!4FNG^ FLF]!FMI"FNK$FG^~#$# #;D6!BCCI7<{{37GHtdjjlHFNL :?++c:J K$ KFL  %FJ#FOI!%(GNN!!'*H_ZFJ#E*HOO""8,E\%.CJJc"D[6??#v- Rs6??345 
 M|C5122e23f 455 9 I Ks   4I$-I)N)r2   r   r5   rA   rH   ra   rd   r^   r3   r   r   <module>r      sH   CL8 8v! !H >1S 1Sh	76r   