
     i                     D    d dl mZ d dlZd dlZd dlZd Zd Zd Zd	dZdS )
    )divisionNc                 t    t          j        dt          |          z             }t          j        | |          S )zConvert a byte array into an integer array. The number of bytes forming an integer
    is defined by num

    :param in_bytes: the input bytes
    :param num: the number of bytes per int
    :return the integer arrayz>i)numpydtypestr
frombuffer)in_bytesnumdts      j/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/mmtf/converters/numpy_converters.pyconvert_bytes_to_intsr      s0     
TCHH_	%	%BHb)))    c           	          t          j        | t          j        dt          t          j        j        j                  z                       }d |D             S )zConvert a list of bytes to a list of strings. Each string is of length mmtf.CHAIN_LEN

    :param in_bytes: the input bytes
    :return the decoded list of stringsSc                     g | ]>}|                     d                               t          j        j        j                  ?S )ascii)decodestripmmtfutils	constants	NULL_BYTE).0ss     r   
<listcomp>z%decode_chain_list.<locals>.<listcomp>   s:    VVVAHHW##DJ$8$BCCVVVr   )r   r   r   r   r   r   r   	CHAIN_LEN)r	   bstringss     r   decode_chain_listr      sI    
 %+cC
@T@^<_<_6_*`*`aaHVVXVVVVr   c                 F    |                      t          j                  |z  S )zConvert integers to floats by division.
    :param in_ints: the integer array
    :param divider: the divider
    :return the array of floats produced)astyper   float64)in_intsdividers     r   convert_ints_to_floatsr$      s    
 NN5=))G34r      c                     g }d}|                                  D ]0}||k    s||k    r||z  }||z  }|                    |           d}1t          j        |t          j                  S )zUnpack an array of integers using recursive indexing.

    :param int_array: the input array of integers
    :param max: the maximum integer size
    :param min: the minimum integer size
    :return the array of integers after recursive index decodingr   )r   )tolistappendr   asarrayint32)	int_arraymaxminout_arrdecoded_valitems         r   recursive_index_decoder2       s     GK  ""  99c		4KK4KNN;'''KK=u{3333r   )r%   r&   )	
__future__r   r   r   mmtf.utils.constantsr   r   r$   r2    r   r   <module>r6      s               * * *W W W5 5 54 4 4 4 4 4r   