
:>"^L  ã               @   s    d  Z  Gd d „  d e ƒ Z d S)z6Useful utilities for helping in parsing GenBank files.c               @   sF   e  Z d  Z d Z d g Z e 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 end up with a value with \012s and spaces in it like::

        "MED\012 YDPWEL..."

    which you probably don't want.

    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).
    Útranslationc             C   s   | |  _  d S)z-Initialize with the keys we should deal with.N)Ú_to_process)ÚselfZ
to_process© r   ú6/tmp/pip-build-ww9dw3qa/biopython/Bio/GenBank/utils.pyÚ__init__!   s    zFeatureValueCleaner.__init__c             C   s[   | |  j  k rW y# t |  d | ƒ } | | ƒ } Wn" t k
 rV t d | ƒ ‚ Yn X| S)z—Clean the specified value and return it.

        If the value is not specified to be dealt with, the original value
        will be returned.
        z	_clean_%szNo function to clean key: %s)r   ÚgetattrÚAttributeErrorÚAssertionError)r   Zkey_nameÚvalueZcleanerr   r   r   Úclean_value%   s    zFeatureValueCleaner.clean_valuec             C   s   | j  ƒ  } d j | ƒ S)zEConcatenate a translation value to one long protein string (PRIVATE).Ú )ÚsplitÚjoin)r   r   Ztranslation_partsr   r   r   Ú_clean_translation3   s    z&FeatureValueCleaner._clean_translationN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Zkeys_to_processr   r   r   r   r   r   r   r   	   s
   	r   N)r   Úobjectr   r   r   r   r   Ú<module>   s   