B
    b                 @   s0   d Z G dd dZedkr,ddlmZ e  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'
    Ztranslationc             C   s
   || _ dS )z-Initialize with the keys we should deal with.N)_to_process)selfZ
to_process r   0lib/python3.7/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   sL   || j krHyt| d| }W n" tk
r>   td| dY nX ||}|S )zClean 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: %sN)r   getattrAttributeErrorAssertionError)r   Zkey_namevalueZ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   Ztranslation_partsr   r   r   _clean_translation;   s    z&FeatureValueCleaner._clean_translationN)	r
   
__module____qualname____doc__Zkeys_to_processr   r   r   r   r   r   r   r   r   	   s   r   __main__    )run_doctestN)r   r   r
   Z
Bio._utilsr   r   r   r   r   <module>   s   8