
:>"^                 @   s   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
 e d d  Z e d	 k r d d
 l m Z e d d  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.
    )print_function)	as_handle)single_letter_alphabet)Seq)	SeqRecordc             c   s  t  |  d  }  x' |  j   } | s( P| j d  s Pq WxM| r| d d k re t d |   g  } x< | j d  r | j | d d  j    |  j   } qn W| j   } g  } xG |  j   } | s P| d d k r P| j | j   j d d	   q Wd	 j |  } | j	 d
  r4| d d  } d
 | k rLt d   t
 t | |  d | d | } d j |  | j d <| Vq? W| st  Wd QRXd S)a/  Iterate over IntelliGenetics records (as SeqRecord objects).

    handle - input file
    alphabet - optional alphabet

    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

    rUz;;r   ;z)Records should start with ';' and not:
%r   N  1z5Potential terminator digit one found within sequence.idname
comment)r   readline
startswith
ValueErrorappendstriprstripreplacejoinendswithr   r   annotationsAssertionError)handleZalphabetlineZcomment_linestitleZ	seq_linesZseq_strrecord r!   3/tmp/pip-build-ww9dw3qa/biopython/Bio/SeqIO/IgIO.py
IgIterator   sB    '	#	!	r#   __main__)run_doctestverboseN)__doc__
__future__r   ZBio.Filer   ZBio.Alphabetr   ZBio.Seqr   ZBio.SeqRecordr   r#   __name__Z
Bio._utilsr%   r!   r!   r!   r"   <module>   s   ]