
:>"^(  ã               @   s\   d  Z  d d l m Z Gd d „  d e ƒ Z Gd d „  d e ƒ Z Gd d „  d e ƒ Z d	 S)
z=Class that maps (chain_id, residue_id) to a residue property.é    )Úprint_functionc               @   sj   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   ú@/tmp/pip-build-ww9dw3qa/biopython/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  | ƒ } | |  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  | ƒ } |  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	   ÚkeysE   s    zAbstractPropertyMap.keysc             c   s3   x, t  d t |  j ƒ ƒ D] } |  j | Vq Wd S)a
  Iterate over the (entity, property) list.

        Handy alternative to the dictionary-like access.

        :return: iterator

        Examples
        --------
        >>> for (res, property) in iter(map):
        ...     print(res, property)
        ...

        r   N)Úranger   r   )r   Úir   r   r	   Ú__iter__M   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  j |  | | | ƒ d S)zInitialize the class.N)r   r
   )r   r   r   r   r   r   r	   r
   b   s    z#AbstractResiduePropertyMap.__init__c             C   s4   | \ } } t  | t ƒ r0 | d | d f f } | S)z.Return entity identifier on residue (PRIVATE).ú )Ú
isinstanceÚint)r   Úent_idÚchain_idÚres_idr   r   r	   r   f   s    z(AbstractResiduePropertyMap._translate_idN)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)ÚAbstractAtomPropertyMapz%Define class for atom properties map.c             C   s   t  j |  | | | ƒ d S)zInitialize the class.N)r   r
   )r   r   r   r   r   r   r	   r
   q   s    z AbstractAtomPropertyMap.__init__c             C   sj   t  | ƒ d k r' | \ } } } } n | \ } } } d } t | t ƒ rf | 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   u   s    z%AbstractAtomPropertyMap._translate_idN)r   r   r   r   r
   r   r   r   r   r	   r"   n   s   r"   N)r   Ú
__future__r   Úobjectr   r   r"   r   r   r   r	   Ú<module>   s   R