B
    ‰°bó  ã               @   s6   d Z G dd„ dƒZG dd„ deƒZG dd„ deƒZdS )z=Class that maps (chain_id, residue_id) to a residue property.c               @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )ÚAbstractPropertyMapz4Define base class, map holder of residue properties.c             C   s   || _ || _|| _dS )zInitialize the class.N)Úproperty_dictÚproperty_keysÚproperty_list)Úselfr   r   r   © r   ú:lib/python3.7/site-packages/Bio/PDB/AbstractPropertyMap.pyÚ__init__   s    zAbstractPropertyMap.__init__c             C   s   |S )z#Return entity identifier (PRIVATE).r   )r   Z	entity_idr   r   r   Ú_translate_id   s    z!AbstractPropertyMap._translate_idc             C   s   |   |¡}|| jkS )a|  Check if the mapping has a property for this residue.

        :param chain_id: chain id
        :type chain_id: char

        :param res_id: residue id
        :type res_id: char

        Examples
        --------
        This is an incomplete but illustrative example::

            if (chain_id, res_id) in apmap:
                res, prop = apmap[(chain_id, res_id)]

        )r	   r   )r   ÚidÚtranslated_idr   r   r   Ú__contains__   s    
z AbstractPropertyMap.__contains__c             C   s   |   |¡}| j| S )a  Return property for a residue.

        :param chain_id: chain id
        :type chain_id: char

        :param res_id: residue id
        :type res_id: int or (char, int, char)

        :return: some residue property
        :rtype: anything (can be a tuple)
        )r	   r   )r   Úkeyr   r   r   r   Ú__getitem__,   s    
zAbstractPropertyMap.__getitem__c             C   s
   t | jƒS )z€Return number of residues for which the property is available.

        :return: number of residues
        :rtype: int
        )Úlenr   )r   r   r   r   Ú__len__;   s    zAbstractPropertyMap.__len__c             C   s   | j S )z«Return the list of residues.

        :return: list of residues for which the property was calculated
        :rtype: [(chain_id, res_id), (chain_id, res_id),...]
        )r   )r   r   r   r   ÚkeysC   s    zAbstractPropertyMap.keysc             c   s*   x$t dt| jƒƒD ]}| j| V  qW dS )a  Iterate over the (entity, property) list.

        Handy alternative to the dictionary-like access.

        :return: iterator

        Examples
        --------
        >>> entity_property_list = [
        ...     ('entity_1', 'property_1'),
        ...     ('entity_2', 'property_2')
        ... ]
        >>> map = AbstractPropertyMap({}, [], entity_property_list)
        >>> for (res, property) in iter(map):
        ...     print(res, property)
        entity_1 property_1
        entity_2 property_2

        é    N)Úranger   r   )r   Úir   r   r   Ú__iter__K   s    zAbstractPropertyMap.__iter__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r   r   r   r   r   r   r   r   r   r      s   r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚAbstractResiduePropertyMapz(Define class for residue properties map.c             C   s   t  | |||¡ dS )zInitialize the class.N)r   r   )r   r   r   r   r   r   r   r   f   s    z#AbstractResiduePropertyMap.__init__c             C   s$   |\}}t |tƒr |d|dff}|S )z.Return entity identifier on residue (PRIVATE).ú )Ú
isinstanceÚint)r   Úent_idÚchain_idÚres_idr   r   r   r	   j   s    
z(AbstractResiduePropertyMap._translate_idN)r   r   r   r   r   r	   r   r   r   r   r   c   s   r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚAbstractAtomPropertyMapz%Define class for atom properties map.c             C   s   t  | |||¡ dS )zInitialize the class.N)r   r   )r   r   r   r   r   r   r   r   u   s    z AbstractAtomPropertyMap.__init__c             C   sH   t |ƒdkr|\}}}}n|\}}}d}t|tƒrD|d|df||f}|S )z,Return entity identifier on atoms (PRIVATE).é   Nr   )r   r   r   )r   r   r   r    Z	atom_nameZicoder   r   r   r	   y   s    

z%AbstractAtomPropertyMap._translate_idN)r   r   r   r   r   r	   r   r   r   r   r!   r   s   r!   N)r   r   r   r!   r   r   r   r   Ú<module>   s   X