U
    Qbi                     @   sN   d dl mZ d dlZd dlZedd d ddddZd	ed
< G dd deZdS )    )defaultdictNc                   C   s   dS )N    r   r   r   .lib/python3.8/site-packages/deblur/sequence.py<lambda>       r            )ACGT   -c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )Sequencea	  Sequence object to represent the aligned reads

    Attributes
    ----------
    label : str
        The sequence label
    sequence : str
        The sequence string
    length : int
        The sequence length (aligned)
    unaligned_length : int
        The unaligned sequence length
    frequency : float
        The number of times the sequence have been seen in the dataset
    np_sequence : numpy array of int8
        An int8 numpy representation of the sequence string

    Methods
    -------
    to_fasta
    c                 C   sl   || _ | | _t| j| _| j| jd | _tt	d| j 
d| _tjdd | jD tjd| _d S )Nr   (?<=size=)\w+r   c                 S   s   g | ]}t | qS r   )
trans_dict).0br   r   r   
<listcomp>1   s     z%Sequence.__init__.<locals>.<listcomp>)Zdtype)labeluppersequencelenlengthcountZunaligned_lengthfloatresearchgroup	frequencynpZarrayZint8Znp_sequence)selfr   r   r   r   r   __init__)   s    
 zSequence.__init__c                 C   s(   t | t |ko&| j|jko&| j|jkS N)typer   r!   r#   otherr   r   r   __eq__3   s
    

zSequence.__eq__c                 C   s   |  | S r%   )r)   r'   r   r   r   __ne__8   s    zSequence.__ne__c                 C   s@   t jd| jdd\}}tt| j}d|||f }d|| jf S )zReturns a string with the sequence in fasta format

        Returns
        -------
        str
            The FASTA representation of the sequence
        r   r   )maxsplitz%s%d%sz>%s
%s
)r   splitr   introundr!   r   )r#   prefixsuffixZ	new_countZ	new_labelr   r   r   to_fasta;   s    zSequence.to_fastaN)__name__
__module____qualname____doc__r$   r)   r*   r1   r   r   r   r   r      s
   
r   )collectionsr   r   Znumpyr"   r   objectr   r   r   r   r   <module>	   s
   