o
    RŀgR                     @   s^   d Z ddlmZ ddlmZ ddlmZ G dd deZedkr-dd	l	m
Z
 e
dd
 dS dS )a<  Bio.SeqIO support for the "ig" (IntelliGenetics or MASE) file format.

This module is for reading and writing IntelliGenetics format files as
SeqRecord objects.  This file format appears to be the same as the MASE
multiple sequence alignment format.

You are expected to use this module via the Bio.SeqIO functions.
    )Seq)	SeqRecord   )SequenceIteratorc                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )
IgIteratorz!Parser for IntelliGenetics files.c                    s   t  j|ddd dS )a  Iterate over IntelliGenetics records (as SeqRecord objects).

        source - file-like object opened in text mode, or a path to a file

        The optional free format file header lines (which start with two
        semi-colons) are ignored.

        The free format commentary lines at the start of each record (which
        start with a semi-colon) are recorded as a single string with embedded
        new line characters in the SeqRecord's annotations dictionary under the
        key 'comment'.

        Examples
        --------
        >>> with open("IntelliGenetics/TAT_mase_nuc.txt") as handle:
        ...     for record in IgIterator(handle):
        ...         print("%s length %i" % (record.id, len(record)))
        ...
        A_U455 length 303
        B_HXB2R length 306
        C_UG268A length 267
        D_ELI length 309
        F_BZ163A length 309
        O_ANT70 length 342
        O_MVP5180 length 348
        CPZGAB length 309
        CPZANT length 309
        A_ROD length 390
        B_EHOA length 420
        D_MM251 length 390
        STM_STM length 387
        VER_AGM3 length 354
        GRI_AGM677 length 264
        SAB_SAB1C length 219
        SYK_SYK length 330

        tIntelliGenetics)modefmtN)super__init__)selfsource	__class__ B/var/www/html/myenv/lib/python3.10/site-packages/Bio/SeqIO/IgIO.pyr      s   &zIgIterator.__init__c                 C   s   |  |}|S )z9Start parsing the file, and return a SeqRecord generator.)iterate)r   handlerecordsr   r   r   parseA   s   
zIgIterator.parsec                 c   s   |D ]	}| ds nqdS |d dkrtd||rg }| dr9||dd   t|}| ds%| }g }|D ]}|d dkrK n|| dd qAd}d|}|d	ri|dd
 }d	|v rqtdt	t
|||dd|idV  |s|rJ dS )z5Iterate over the records in the IntelliGenetics file.z;;Nr   ;z'Records should start with ';' and not:
r     1z5Potential terminator digit one found within sequence.comment
)idnameannotations)
startswith
ValueErrorappendstripnextrstripreplacejoinendswithr   r   )r   r   linecomment_linestitle	seq_linesseq_strr   r   r   r   F   sH   




)zIgIterator.iterate)__name__
__module____qualname____doc__r   r   r   __classcell__r   r   r   r   r      s
    (r   __main__)run_doctest)verboseN)r2   Bio.Seqr   Bio.SeqRecordr   
Interfacesr   r   r/   
Bio._utilsr5   r   r   r   r   <module>   s   	h