o
    Rŀg-"                     @   sH   d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd deZ	dS )	a\  Bio.AlignIO support for "emboss" alignment output from EMBOSS tools.

You are expected to use this module via the Bio.AlignIO functions (or the
Bio.SeqIO functions if you want to work directly with the gapped sequences).

This module contains a parser for the EMBOSS pairs/simple file format, for
example from the alignret, water and needle tools.
    )MultipleSeqAlignment)AlignmentIterator)Seq)	SeqRecordc                   @   s   e Zd ZdZdZdd ZdS )EmbossIteratorzEmboss alignment iterator.

    For reading the (pairwise) alignments from EMBOSS tools in what they
    call the "pairs" and "simple" formats.
    Nc              	   C   sn  | j }| jdu r| }n| j}d| _|st| dkr+| }|s%t| dksd}d}g }i }|d dkr|dd dd}|d   }|dkrt|d  }t	|dks_J t
|D ])}	| }|dd  dd}|	d t|d  ksJ ||d   qct	||ksJ |dkrt|d  }|d	krt|d  d
d |d	< |dkrt|d  d
d |d< |dkrt|d  d
d |d< |dkrt|d  |d< | }|d dks9|du rtd|du rtd| jdur| j|krtd|| jf dgt	| }
g }d}|rmt	|dkrD|dd  dd}|dd  dd}t	|dkrBt	|dkrB|\}}|\}}||kr}|dddkrrt|}t|}n$t|d }t|}n|dddksJ t|t|d }t|}|dk s||krtd||f ||| ks||| dt	| ksJ t	||kr|| ||kr|dddksJ |n'|||  t	|
| ddkrtdt	|
| dd|||
| ||f |
|  |7  < ||| t	|
| dd kr6tdt	|
| dd|||
| || ||f |d7 }||krAd}n	 n| dkrLntd|d| }| dksf| dkrj|| _n|s&|dkstJ | jdur| jt	|krtdt	|| jf g }t||
D ]\}}t	||krtd|tt|||d qt||dS )z)Parse the next alignment from the handle.Nz(#=======================================r   #   :aligned_sequenceslengthidentity/
similaritygapsscorezNumber of sequences missing!zLength of sequences missing!z5Found %i records in this alignment, told to expect %i       -z!Expected index %i in range [0,%i)zFFound %i chars so far for sequence %i (%s, %r), line says start %i:
%szNFound %i chars so far for sequence %i (%s, %r, start=%i), file says end %i:
%sz#Unrecognised EMBOSS pairwise line: 
z(#---------------------------------------zeError parsing alignment - sequences of different length? You could be using an old version of EMBOSS.)iddescription)annotations)handle_headerreadlineStopIterationrstripsplitlowerstripintlenrangeappendfloat
ValueErrorrecords_per_alignmentreplacereprzipr   r   r   )selfr   linelength_of_seqsnumber_of_seqsidsheader_dictpartskeyiseqs
seq_startsindexid_startseq_endr   startseqendrecords r=   H/var/www/html/myenv/lib/python3.10/site-packages/Bio/AlignIO/EmbossIO.py__next__   s  

 



,

""
YzEmbossIterator.__next__)__name__
__module____qualname____doc__r   r?   r=   r=   r=   r>   r      s    r   N)
rC   	Bio.Alignr   Bio.AlignIO.Interfacesr   Bio.Seqr   Bio.SeqRecordr   r   r=   r=   r=   r>   <module>   s   	