o
    Rŀg                     @   s4   d Z G dd dZedkrddlmZ e  dS dS )z6Useful utilities for helping in parsing GenBank files.c                   @   s:   e Zd ZdZdgZefddZdd Zdd Zd	d
 ZdS )FeatureValueCleanera)  Provide specialized capabilities for cleaning up values in features.

    This class is designed to provide a mechanism to clean up and process
    values in the key/value pairs of GenBank features. This is useful
    because in cases like::

         /translation="MED
         YDPWNLRFQSKYKSRDA"

    you'll otherwise end up with white space in it.

    This cleaning needs to be done on a case by case basis since it is
    impossible to interpret whether you should be concatenating everything
    (as in translations), or combining things with spaces (as might be
    the case with /notes).

    >>> cleaner = FeatureValueCleaner(["translation"])
    >>> cleaner
    FeatureValueCleaner(['translation'])
    >>> cleaner.clean_value("translation", "MED\nYDPWNLRFQSKYKSRDA")
    'MEDYDPWNLRFQSKYKSRDA'
    translationc                 C   s
   || _ dS )z-Initialize with the keys we should deal with.N)_to_process)self
to_process r   E/var/www/html/myenv/lib/python3.10/site-packages/Bio/GenBank/utils.py__init__#   s   
zFeatureValueCleaner.__init__c                 C   s   | j j d| jdS )z,Return a string representation of the class.())	__class____name__r   )r   r   r   r   __repr__'   s   zFeatureValueCleaner.__repr__c                 C   sJ   || j v r#z
t| d| }W n ty   td| dw ||}|S )zClean the specified value and return it.

        If the value is not specified to be dealt with, the original value
        will be returned.
        _clean_zNo function to clean key: N)r   getattrAttributeErrorAssertionError)r   key_namevaluecleanerr   r   r   clean_value+   s   
zFeatureValueCleaner.clean_valuec                 C   s   |  }d|S )zEConcatenate a translation value to one long protein string (PRIVATE). )splitjoin)r   r   translation_partsr   r   r   _clean_translation9   s   
z&FeatureValueCleaner._clean_translationN)	r   
__module____qualname____doc__keys_to_processr   r   r   r   r   r   r   r   r   	   s    r   __main__    )run_doctestN)r   r   r   
Bio._utilsr!   r   r   r   r   <module>   s   6
