
    Ri                     B    d Z  G d d      Zedk(  rddlmZ  e        yy)z6Useful utilities for helping in parsing GenBank files.c                   2    e Zd ZdZdgZefdZd Zd Zd Zy)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                     || _         y)z-Initialize with the keys we should deal with.N)_to_process)self
to_processs     I/home/agent/.friday_env/lib/python3.12/site-packages/Bio/GenBank/utils.py__init__zFeatureValueCleaner.__init__#   s
    %    c                 N    | j                   j                   d| j                  dS )z,Return a string representation of the class.())	__class____name__r   )r   s    r	   __repr__zFeatureValueCleaner.__repr__'   s'    ..))*!D,<,<+?qAAr   c                     || j                   v r	 t        | d|       } ||      }|S # t        $ r t        d|       dw xY w)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cleaners       r	   clean_valuezFeatureValueCleaner.clean_value+   sd     t'''X!$'((<= ENE " X$'A(%LMSWWXs	   ) Ac                 D    |j                         }dj                  |      S )zEConcatenate a translation value to one long protein string (PRIVATE). )splitjoin)r   r   translation_partss      r	   _clean_translationz&FeatureValueCleaner._clean_translation9   s    !KKMww())r   N)	r   
__module____qualname____doc__keys_to_processr
   r   r   r     r   r	   r   r   	   s(    . %oO"1 &B*r   r   __main__    )run_doctestN)r#   r   r   
Bio._utilsr(   r%   r   r	   <module>r*      s,    =3* 3*l z&M r   