
    Ri                     2    d Z  G d de      Z G d d      Zy)z<Objects to represent NEXUS standard data type matrix coding.c                       e Zd ZdZy)
NexusErrorz1Provision for the management of Nexus exceptions.N)__name__
__module____qualname____doc__     N/home/agent/.friday_env/lib/python3.12/site-packages/Bio/Nexus/StandardData.pyr   r      s    ;r	   r   c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
StandardDatazCreate a StandardData iterable object.

    Each coding specifies t [type] => (std [standard], multi [multistate] or
    uncer [uncertain]) and d [data]
    c                    g | _         d| _        t        |t              st	        d      d}d}dg d}t        |      D ]  \  }}|r|dk(  rd}nv|d   j                  |       %|r|dk(  rd}nW|d   j                  |       D|d	k(  rd
}d|d<   Q|dk(  rd
}d|d<   ^|dv rt	        d||fz        |d   j                  |       | j                   j                  |j                                dg d} y)zInitialize the class.    zAThe coding data given to a StandardData object should be a stringFstd)td)r   }(Tmultir   {uncer)r   r   z:Improper character %s at position %i of a coding sequence.N)_data_current_pos
isinstancestrr   	enumerateappendcopy)selfdatamulti_codinguncertain_codingcoding_listposcodings          r
   __init__zStandardData.__init__   s@   
 $$S 
  !+$T? &	0KCS=#(L  $++F3!S=',$  $++F3 S=#'L'.K$s]'+$'.K$z)$T!3-( 
  $++F3 JJk..01 %B/KM&	0r	   c                 ,    t        | j                        S )z4Return the length of the coding, use len(my_coding).)lenr   r   s    r
   __len__zStandardData.__len__P   s    4::r	   c                      | j                   |   S )zPull out child by index.r   )r   args     r
   __getitem__zStandardData.__getitem__T   s    zz#r	   c                     | S )zIterate over the items.r   r)   s    r
   __iter__zStandardData.__iter__X   s    r	   c                     	 | j                   | j                     }| xj                  dz  c_        |S # t        $ r d| _        t        dw xY w)zReturn next item.   r   N)r   r   
IndexErrorStopIteration)r   return_codings     r
   __next__zStandardData.__next__\   sU    	! JJt'8'89M
 "    	* !DT)	*s	   2 A
c                     | j                   S )z(Return the full coding as a python list.r,   r)   s    r
   rawzStandardData.rawg   s    zzr	   c                     d}| j                   D ]Y  }|d   dk(  r|ddj                  |d         z   dz   z  })|d   dk(  r|ddj                  |d         z   d	z   z  }O||d   d
   z  }[ |S )z>Return the full coding as a python string, use str(my_coding). r   r   r   r   r   r   r   r   r   )r   join)r   
str_returnr%   s      r
   __str__zStandardData.__str__k   s    
jj 	-Fc{g%cBGGF3K$883>>
'cBGGF3K$883>>
fSk!n,
	- r	   N)r   r   r   r   r&   r*   r.   r0   r6   r8   r=   r   r	   r
   r   r      s+    60p	!
r	   r   N)r   	Exceptionr   r   r   r	   r
   <module>r?      s#    C< <d dr	   